Compare commits

...

1395 Commits

Author SHA1 Message Date
pascallanger
dd82cbec63 Update Protocols_Details.md 2024-05-17 17:08:01 +02:00
pascallanger
be4595fe67 Update FX_nrf24l01.ino 2024-05-17 14:45:30 +02:00
pascallanger
54ae77ed7f FX/Q560 new sub protocol 2024-05-17 11:01:54 +02:00
pascallanger
2bdbd7088c Traxxas TQ 1st gen: try 5 2024-05-04 11:36:14 +02:00
pascallanger
1d3ed78622 J6Pro update 2024-05-04 11:34:59 +02:00
pascallanger
79b1c54007 Traxxas TQ 1st gen: try 4 2024-05-03 00:15:03 +02:00
pascallanger
81eb5dc6bc Traxxas TQ 1st gen: try 2 2024-04-29 19:43:24 +02:00
pascallanger
85a0e4bde8 Traxxas TQ 1st gen: try 2 2024-04-27 11:23:19 +02:00
pascallanger
63dfa316e8 Traxxas TQ 1st gen: try 1 2024-04-26 19:25:23 +02:00
pascallanger
9d383432a5 Update SGF22_nrf24l01.ino 2024-04-24 07:00:44 +02:00
pascallanger
6b181db629 SLT try 1e 2024-04-18 10:40:37 +02:00
pascallanger
873279dbe9 SLT new sub_protocol V1_4CH 2024-04-15 14:13:37 +02:00
pascallanger
f35be2984a SLT try 1d 2024-04-14 13:29:28 +02:00
pascallanger
7ddeb31e95 SLT try 1c 2024-04-14 13:23:50 +02:00
pascallanger
7444c44b48 SLT try 1b 2024-04-13 10:22:39 +02:00
pascallanger
08d1dcbed2 SLT try 1a 2024-04-12 18:24:50 +02:00
pascallanger
3e4f4e36c1 SLT try 1 2024-04-12 18:20:01 +02:00
pascallanger
902419dd3d Update Protocols_Details.md 2024-04-08 18:36:42 +02:00
pascallanger
038b3b9225 Update Protocols_Details.md 2024-04-04 17:13:35 +02:00
pascallanger
45f0154f4b Update Protocols_Details.md 2024-04-04 16:15:27 +02:00
pascallanger
e03864e35f Traxxas TQ 6 channels 2024-04-04 16:13:35 +02:00
pascallanger
de35ee09f5 Realacc doc update 2024-04-02 16:42:19 +02:00
pascallanger
c88952c35e REALACC: IDs
Any ID
2024-04-02 12:34:04 +02:00
pascallanger
ffae7dda1d Update SGF22_nrf24l01.ino 2024-03-29 16:24:25 +01:00
pascallanger
4f17f76b39 SGF22: new flag 2024-03-29 16:19:20 +01:00
pascallanger
31ef090508 ASF try 4 2024-03-29 15:55:54 +01:00
pascallanger
04d4e39b87 Update _Config.h 2024-03-27 19:34:28 +01:00
pascallanger
b3537ea75a DSM2_SFC try 3 2024-03-26 16:18:34 +01:00
pascallanger
bccc050165 DSM2_SFC try 2 2024-03-26 14:41:19 +01:00
pascallanger
0f0df176de DSM2_SFC try 1
Servo refresh rate -> frame rate 16.5/11ms
2024-03-26 14:37:26 +01:00
pascallanger
5542e7005d ASF try 3 2024-03-26 11:43:42 +01:00
pascallanger
eb35fefd3e ASF try 2 2024-03-25 15:17:51 +01:00
pascallanger
5acc3a8d01 CYRF6936: Findbestchannels flag addition 2024-03-25 15:11:31 +01:00
pascallanger
9e9c3958c6 ASF: try 1 2024-03-23 11:23:42 +01:00
pascallanger
7f3a93ca4c Kyosho3: increase bind time to 2.5s 2024-03-22 18:24:31 +01:00
pascallanger
debc9de11a New protocol Kyosho3/ASF
Only 1 ID and 1 frequency for now
2024-03-22 18:17:21 +01:00
pascallanger
f117105124 SGF22: Fix none working IDs 2024-03-21 16:33:16 +01:00
pascallanger
2e3520acad DSM2SFC timing update 2024-03-19 20:52:50 +01:00
pascallanger
91af921d98 Update Protocols_Details.md 2024-03-19 15:47:56 +01:00
pascallanger
ab45ec6d1c Update Validate.h 2024-03-19 15:44:29 +01:00
pascallanger
26b0b6bd20 Update DSM_cyrf6936.ino 2024-03-19 15:44:21 +01:00
pascallanger
1b9ce32e89 Update DSM_cyrf6936.ino 2024-03-19 14:11:40 +01:00
pascallanger
332e55831c Update Protocols_Details.md 2024-03-18 17:11:23 +01:00
pascallanger
7051438e5d Update Protocols_Details.md 2024-03-18 17:00:40 +01:00
pascallanger
28467fac57 DSM/DSM2SFC new subprotocol 2024-03-18 16:57:54 +01:00
pascallanger
c7513abad8 Update Multiprotocol.h 2024-03-18 09:02:55 +01:00
pascallanger
e6e13c0fdd Docs update 2024-03-17 15:52:42 +01:00
pascallanger
9579a667fc Update REALACC_nrf24l01.ino 2024-03-17 15:28:33 +01:00
pascallanger
cbedda2471 Merge branch 'master' of https://github.com/pascallanger/DIY-Multiprotocol-TX-Module 2024-03-14 20:23:04 +01:00
pascallanger
f8695befe2 REALACC multi IDs 2024-03-14 20:23:02 +01:00
pascallanger
e951e3146b Update Protocols_Details.md (#955) 2024-03-14 20:22:00 +01:00
pascallanger
4c0b46549f EazyRC multi IDs/RFs 2024-02-28 10:46:10 +01:00
pascallanger
188f8ff9ce Radiolink/RC4G: IDs and RFs 2024-02-26 17:20:08 +01:00
pascallanger
bee6e59582 Update EazyRC_nrf24l01.ino 2024-02-24 09:38:42 +01:00
pascallanger
af47462ba7 EazyRC.2 2024-02-23 19:06:20 +01:00
pascallanger
d6ccd4af54 EazyRC.1 2024-02-23 17:51:38 +01:00
pascallanger
0feedc6fa9 New protocol EazyRC 2024-02-23 17:36:02 +01:00
pascallanger
b5bc7c04fb Rename Traxxas/6519 to Traxxas/TQ 2024-02-23 17:19:09 +01:00
pascallanger
a15371d989 Merge branch 'master' of https://github.com/pascallanger/DIY-Multiprotocol-TX-Module 2024-02-23 11:29:35 +01:00
pascallanger
3c82f37e2b Bumping revision 2024-02-23 11:29:19 +01:00
Ben Lye
4f914a18ae Automated build process updates (#950)
* 4-in-1 air and surface builds

* Disable serial and PPM-only builds for STM32 x-in-1

* More air and surface builds

* Fix 5-in-1 tests

* T18 air, surface, and LBT builds

* Remove CFlie from DIY 5-in-1 AIR

* Bump action versions

* v4 artifact merging

* Improve artifact merge

* Fix merge

* DIY 5-in-1 LBT

* Tweak CI job name

* Add T-Lite 5-in-1 LBT

* CI job restructure
2024-02-23 11:26:30 +01:00
pascallanger
1cbce29970 Remove Radiolink/RC4G when MULTI_AIR 2024-02-23 11:06:48 +01:00
pascallanger
e0c44ed5a8 Remove DSMR when MULTI_AIR 2024-02-23 11:05:02 +01:00
pascallanger
390e5dd654 Remove Kyosho/FHSS&SYNC when MULTI_AIR 2024-02-22 17:40:56 +01:00
pascallanger
968293e599 Remove Hisky/HK310 when MULTI_AIR 2024-02-22 17:29:00 +01:00
pascallanger
09ee173e3b Remove Pelikan/SCX24 when MULTI_AIR
Save flash space
2024-02-22 17:14:20 +01:00
pascallanger
babfee0f9e Update RadioLink_cc2500.ino 2024-02-21 13:43:44 +01:00
pascallanger
72da3c5bc5 Create MULTI_AIR / MULTI_SURFACE 2024-02-21 12:31:23 +01:00
Ben Lye
4df1e65a7f Pelikan SCX24 / HPI TF-41 reversed (#917)
* Pelikan SCX24 / HPI TF-41 reversed

* Save some flash and memory

* Save more flash
2024-02-21 12:17:02 +01:00
pascallanger
1459d690d8 Update SGF22_nrf24l01.ino 2024-02-21 11:41:23 +01:00
pascallanger
8d96066215 Merge XK and Tiger protocols 2024-02-21 11:38:31 +01:00
pascallanger
93a5834dd0 Update TRAXXAS_cyrf6936.ino 2024-02-19 21:53:54 +01:00
pascallanger
5f9ac82ed1 SGF22.5 Multiple IDs, 1 set of frequencies 2024-02-19 18:34:27 +01:00
pascallanger
2108912263 Update TRAXXAS_cyrf6936.ino 2024-02-17 11:03:37 +01:00
pascallanger
72f87cade9 XK: new subprotocol Cars
Removed:
 - deadband which was needed on the planes
- force bind since the cars remember the bind info
-
2024-02-17 11:02:52 +01:00
pascallanger
50bd4850fa Radiolink/RC4G
1 ID / 1 set of frequency
2024-02-16 18:03:32 +01:00
pascallanger
dc1490b9b0 SGF22.4 2024-02-16 10:26:48 +01:00
pascallanger
b18adb0efe SGF22.3 2024-02-16 10:24:44 +01:00
pascallanger
53d5684dfd KN: additional trim and flag 2024-02-15 20:52:01 +01:00
pascallanger
724abbc935 SGF22.2 2024-02-15 18:24:58 +01:00
pascallanger
de610b53fc SGF22.1 2024-02-15 16:28:52 +01:00
pascallanger
dd7ee7bdce SGF22 2024-02-15 16:20:37 +01:00
pascallanger
31a9f6860d New protocol SGF22
Only 1 ID!
2024-02-15 15:51:20 +01:00
pascallanger
4a66ae64c6 Update Protocols_Details.md (#940) 2024-02-06 12:06:34 +01:00
pascallanger
11ae26a431 Update Protocols_Details.md 2024-01-31 19:27:54 +01:00
pascallanger
cdabde5d67 Kyosho FHSS and Syncro
Automatically binding a FHSS or a Syncro RX using FHSS
2024-01-31 19:22:36 +01:00
pascallanger
ce75dd3355 Kyosho FHSS/SYNCRO cleanup 2024-01-30 14:53:28 +01:00
pascallanger
69484b5278 Second try 2024-01-30 14:42:24 +01:00
pascallanger
a90e1f2d3a Update Bluefly_ccnrf.ino
Exclude this protocol since it's not working
2024-01-30 14:36:38 +01:00
pascallanger
5af246bba0 Update _Config.h 2024-01-30 12:33:21 +01:00
pascallanger
75a46858da Update Kyosho_a7105.ino 2024-01-30 12:25:25 +01:00
pascallanger
8ac53657ec Kyosho updqte
fixed crash
2024-01-30 12:06:37 +01:00
pascallanger
2888d3e937 TRAXXAS TQ WIP
It still won't work unless you have some luck. I still need to work on the RF frequency.
2024-01-29 18:59:24 +01:00
pascallanger
3d989a47db Typo... 2024-01-29 18:45:32 +01:00
pascallanger
a7d6d12679 Kyosho Syncro
Sub protocol Syncro for KT-331 and KR-331
2024-01-29 17:00:54 +01:00
pascallanger
457703b881 Update Protocols_Details.md 2024-01-18 12:16:59 +01:00
rdba2k
8e663f2531 Update V911S_ccnrf.ino to add 6G/Senior and light for XK A280 (#929) 2024-01-18 12:07:34 +01:00
pascallanger
8c2fe5f65e Traxxas trial 2023-12-24 15:05:13 +01:00
pascallanger
7549783741 Fix Traxxas for any RX 2023-12-22 21:02:10 +01:00
pascallanger
e6bafaabb7 New protocol: BumbleBee 990A
Preliminary
2023-12-22 21:01:15 +01:00
pascallanger
9286ac84f6 Update MultiChan.txt 2023-12-22 20:58:19 +01:00
pascallanger
ede40ac598 Update Protocols_Details.md (#923) 2023-12-21 18:24:08 +01:00
pascallanger
88fad2dc9f Update Protocols_Details.md (#922) 2023-12-21 18:22:50 +01:00
Frankie Arzu
549d3ad653 Fix for DSM-Auto Bind on Lemon-RX Gen2 (#918)
* #916 Fix for Auto-Bind on Lemon-RX Gen2

Tested with multiple brands (Spektrum, OrangeRX, Lemon-Rx, Admiral).  Even some old DSM 2 receivers.
All work with "Auto" now.   Just in case one needs a LONG bind sending period, when not using "Auto" works the same as before.

* Use 1.8s for Bind Send

Removed the short and long bind count logic.
2023-12-18 12:02:57 +01:00
Frankie Arzu
62aa58d32d Forward Prog v0.56 (#919)
1. NEW Black&White Radios new model setup. Now it can setup completely a plane from zero
2. Color version; simplified code for Tail mixes, and fix Taileron setup
2023-12-17 11:12:14 +01:00
Paul
21a06c2925 FX9603 added to protocol details (#914)
* Allow zero and limit range of enterd values

* FX9603 added to protocol details
2023-12-12 22:43:34 +01:00
pascallanger
9acb3b0e2c DSM.ino: Saved a few bytes 2023-12-01 19:06:15 +01:00
pascallanger
785edde659 Update DSM.ino 2023-12-01 18:29:23 +01:00
pascallanger
7da6d52a84 CYRF data codes are always 16
Removed useless function argument
LOSI now points to the DSM data codes = dependency on DSM
2023-12-01 10:58:56 +01:00
Ben Lye
61cbe45ce2 Disabled protocols in Atmega CYRF builds (#911) 2023-11-30 16:17:21 +01:00
pascallanger
23af33e214 LOSI multi IDs 2023-11-30 16:04:43 +01:00
pascallanger
11db967b8a LOSI multi ID 2023-11-30 16:02:58 +01:00
pascallanger
d419e2b344 Update Losi_cyrf6936.ino 2023-11-30 12:15:02 +01:00
pascallanger
2b69c1184e Update Losi_cyrf6936.ino 2023-11-30 12:10:17 +01:00
pascallanger
1ceed87298 Update Losi_cyrf6936.ino 2023-11-30 09:47:28 +01:00
pascallanger
a1737eab46 PELIKAN: new hopping tables 2023-11-30 09:46:18 +01:00
pascallanger
9cbcafe6cf Update Losi_cyrf6936.ino 2023-11-29 15:40:18 +01:00
pascallanger
495706314f Pelikan: 1 more High ID / frequency table 2023-11-29 15:40:08 +01:00
pascallanger
595511979b Update Losi_cyrf6936.ino 2023-11-27 20:07:12 +01:00
pascallanger
b8d30f47be Update Losi_cyrf6936.ino 2023-11-27 16:59:41 +01:00
pascallanger
b7097bdfb7 LOSI 2023-11-27 15:56:50 +01:00
pascallanger
a682b0e604 Update Losi_cyrf6936.ino 2023-11-22 08:26:03 +01:00
pascallanger
7e7b555809 LOSI: dynamic channel 2023-11-22 07:57:54 +01:00
pascallanger
62ecaa8412 Revert J6Pro changes 2023-11-22 07:57:30 +01:00
pascallanger
5ae052317d Update README.md 2023-11-11 11:50:17 +01:00
pascallanger
f3331ca397 Add pointer to Frank DSM Tools page 2023-11-11 11:48:54 +01:00
pascallanger
ffcfd44127 Bluefly fix? 2023-11-11 01:57:45 +01:00
Ben Lye
5ef944241a Add EU/LBT binaries to the build artifacts (#905)
* Add release LBT builds

* Use friendly build names

* Script cleanup
2023-11-10 17:40:30 +01:00
pascallanger
ab5f75b1b3 BlueFly: New protocol 2023-11-09 18:02:21 +01:00
pascallanger
10ec4dd735 Update Protocols_Details.md 2023-11-09 11:57:26 +01:00
pascallanger
a62d1dcd2e Update Protocols_Details.md 2023-11-08 10:53:57 +01:00
pascallanger
2c9e98e341 Update Protocols_Details.md 2023-10-30 22:48:04 +01:00
pascallanger
0bf94e96b5 E129/C186: New flip flag for C129V2 on CH11 2023-10-30 22:36:09 +01:00
Ben Lye
8d84386c7a Fix LUA script zipping (#898) 2023-10-30 14:44:43 +01:00
Paul
cd721e31d8 Allow zero and limit range of enterd values (#896) 2023-10-24 01:32:38 +02:00
pascallanger
1294ad21cf E129/C186 new circular flight flag 2023-10-23 11:24:37 +02:00
pascallanger
01bc08575f Update Protocols_Details.md 2023-10-10 12:07:16 +02:00
pascallanger
ecfe17915f V761 telemetry fix 2023-10-09 16:53:17 +02:00
pascallanger
f97aa3597d Commented out by default E01X protocol and subprotocols to gain flash space 2023-09-27 15:36:53 +02:00
pascallanger
2e1d763d54 V761 telemetry
A1 (4.4V -> 2.2V), RSSI equal to 100 means that all telem packets are received and TQLY indicates the number of lost telem packets.
2023-09-26 20:04:35 +02:00
Frankie Arzu
93a2cc8b7f Version 0.55 (#883) 2023-09-08 14:33:13 +02:00
pascallanger
abfebb3da4 QIDI-550 model
Using FX/9630
Added trims
!! Need to find out the first RF channel calculation !!
2023-09-02 01:11:37 +02:00
johnnym007
ce5f4ec264 Clone subprotocol for DSM (#877)
* Init WIP

* Adding a gitignore

* removing gitignore

* RX routines added

* Finished adding clone and erase

* Update _Config.h

* Update Multiprotocol.ino

* Ready for testing

* Refactor to call init on cloned/normal change

* Remove vscode files

* remove TODO comment

* remove unnecessary brackets

---------

Co-authored-by: john.moore <john.moore@amulethotkey.com>
2023-08-27 16:08:10 +02:00
pascallanger
a41123deb2 FrSky Archer Bind 2023-08-26 00:04:36 +02:00
pascallanger
fabb65a2bb Fix FrSkyX SPORT 2023-08-12 13:17:06 +02:00
pascallanger
eae1329dfe Add flags for KFPLAN Z61 BF109 2023-08-12 13:16:39 +02:00
Ben Lye
a8ae0a2bd1 Fix builds by using older Arduino CLI (#864)
* Used a fixed version of Arduino CLI

* Bump action versions
2023-06-14 14:08:58 +02:00
Ben Lye
c814cc1bd4 Switch back to non-devel boards for CI/CD (#863) 2023-06-14 13:29:34 +02:00
pascallanger
4e7c1502ff Update Protocols_Details.md 2023-06-04 13:48:04 +02:00
pascallanger
8ddee12de5 Update _Config.h 2023-06-04 12:50:39 +02:00
pascallanger
692bcc1fbb Update Scorpio_cyrf6936.ino 2023-06-04 12:38:09 +02:00
pascallanger
0bb345e3fc J6Pro save some flash space 2023-06-04 12:20:10 +02:00
pascallanger
c193d0b9dd Update Multiprotocol.ino 2023-06-04 12:12:22 +02:00
pascallanger
410ce5cc4c Fixed SX1276 protocol 2023-06-04 12:07:27 +02:00
pascallanger
cefe69a692 Fix SPORT when using FRSKYX (V1) protocol set to EU LBT 2023-06-04 12:03:43 +02:00
pascallanger
daa4ded390 New protocol Scorpio
Model Falco 300
2023-06-04 12:02:37 +02:00
pascallanger
5949fca990 Update Protocols_Details.md (#856) 2023-05-15 08:26:13 +02:00
pascallanger
ed2e2e4f32 Update Protocols_Details.md 2023-05-15 08:17:19 +02:00
Frankie Arzu
b2f8f482bb V0.54 Enhacements (#846)
* #751 DSM Enhancements

 #751 DSM Forward Programming Enhancements (New GUI, etc)

* Make both work on EdgeTx and OpenTX

* #751 Turn OFF simulation by default

Distribution code with RX simulation OFF
Simulation should be only for Development

* #751 Update Readme Documentation

Updated the Readme.txt documentation
and removed compiled luac file that was check in by mistake

* #751 Fix problems With Reset RX

1. Fix problem when trying to Factory Reset. Enter Bind Mode. Save backup, Restore Backup

2. Found a way to advance on the Gyro initial Setup menus.. a bit of a hack, but works.

3. Handle RX resets properly. It needed after initial setup

* #751 Cosmetic and Show Orientation Images

#751
1. Fix problems when text contradictions between Menu/Line Headers and List Values
2. Show Images of RX orientations
3. Able to Hack getting into Initial Setup and other menus who was failing before
4. Custumize the way Flight Mode reports the Value on Screen

* #751 add check for required libraries

Add check that the required files in DSMLIB exist

* #751

Write documentation about the protocol so that we don't forget later what we know, and enable others to understand the logs and maybe help solve problems.

* #766

Change the way to detect that the files exist. now works on both ETX and OTX

* #766 Strange Flickering in OTX

Strange Flickering happening on OTX. Refreshing the screen on every cycle fixed the problem

* #766 Change way of dectecting EdgeTX

Change way of detecting OTX in multiple versions: OTX 2.3.14 and 2.3.15

* #766  make editable Gain Values

Gains and other settings should be editable even when they are VALUE_NOCHANGING. Flight Mode is an exception that is handled properly. Right align numbers.

* #766 More enhacements

Added AR630
Make numbers right justified
Cleanup some log messages and line types.
Updated DSM FWD prog documentation

* #751 more cosmetic things

1. Added AR10360T,
2. Simplify way to configured the hack for more receivers.
3. Change some texts on menus to march spektrum
4. Background color in Spektrum theme to match

* #751 A few final changes

1. Update channel names to include channel number. i.e: Ch5 (Gear)
2,  Fix flight mode display for Heli Receiver
3. i think the unknown lines are to request info about the TX settings

* #751

1. Added Warning Screen
2. Correct handling of Unknown lines in Gyro Settings->Initial Setup

* #751

New v0.51 version.
- Added new menus to configure Model/Wing type.  Without it, the initial setup will not work properly.

* #751 More fixes on mixers and servo reverse

-- Fix problem reversing servos when using vtail/delta mix
-- Properly detect ch order of multimodule

* #751 Updated channel naming and docs

Updated readme documentation
Consistent naming of Ch across the code.

* #751 Fix message displaying data path

* #751  More improvements

1. Much easier to select channels > Ch6 for FMode, Gain and Panic channels
2. B&W version for smaller screens (128x64).. Memory footprint still a problem.
3. Fix a lot typos/misspell/grammar in the documentation

* Create DSM_AR636_TextGen.lua

Script to show Telemetry TextGen screens
for AR636 Receiver.
Really useful for BLADE helis using the AR636

Could replace dsmPID.lua

Still needs to be ported to smaller screens.

* #751 Enhancements for Lua Script tools

Enhancements

* Delete DSM_AR636_TextGen.lua

The TextGen functionality is included in DSM_AR636_Tel.lua. No longer needed

* Version 0.54

1. Fix problem with "Attitude Trim" Menu
2. New "MINimalistic" version for radios with very low memory
3. Externalized menu messages shared by all versions. the idea is to allow to translate it into other languages.
4. Correction of TextGen tools to work on black&white radios (some Lua functional differences). TextGen will be working on EdgeTx 2,8.3

---------

Co-authored-by: pascallanger <pascal_langer@yahoo.fr>
2023-04-16 21:42:31 +02:00
Frankie Arzu
89023d4b55 Remove DSM_AR636_TextGen.lua (#837)
* #751 DSM Enhancements

 #751 DSM Forward Programming Enhancements (New GUI, etc)

* Make both work on EdgeTx and OpenTX

* #751 Turn OFF simulation by default

Distribution code with RX simulation OFF
Simulation should be only for Development

* #751 Update Readme Documentation

Updated the Readme.txt documentation
and removed compiled luac file that was check in by mistake

* #751 Fix problems With Reset RX

1. Fix problem when trying to Factory Reset. Enter Bind Mode. Save backup, Restore Backup

2. Found a way to advance on the Gyro initial Setup menus.. a bit of a hack, but works.

3. Handle RX resets properly. It needed after initial setup

* #751 Cosmetic and Show Orientation Images

#751
1. Fix problems when text contradictions between Menu/Line Headers and List Values
2. Show Images of RX orientations
3. Able to Hack getting into Initial Setup and other menus who was failing before
4. Custumize the way Flight Mode reports the Value on Screen

* #751 add check for required libraries

Add check that the required files in DSMLIB exist

* #751

Write documentation about the protocol so that we don't forget later what we know, and enable others to understand the logs and maybe help solve problems.

* #766

Change the way to detect that the files exist. now works on both ETX and OTX

* #766 Strange Flickering in OTX

Strange Flickering happening on OTX. Refreshing the screen on every cycle fixed the problem

* #766 Change way of dectecting EdgeTX

Change way of detecting OTX in multiple versions: OTX 2.3.14 and 2.3.15

* #766  make editable Gain Values

Gains and other settings should be editable even when they are VALUE_NOCHANGING. Flight Mode is an exception that is handled properly. Right align numbers.

* #766 More enhacements

Added AR630
Make numbers right justified
Cleanup some log messages and line types.
Updated DSM FWD prog documentation

* #751 more cosmetic things

1. Added AR10360T,
2. Simplify way to configured the hack for more receivers.
3. Change some texts on menus to march spektrum
4. Background color in Spektrum theme to match

* #751 A few final changes

1. Update channel names to include channel number. i.e: Ch5 (Gear)
2,  Fix flight mode display for Heli Receiver
3. i think the unknown lines are to request info about the TX settings

* #751

1. Added Warning Screen
2. Correct handling of Unknown lines in Gyro Settings->Initial Setup

* #751

New v0.51 version.
- Added new menus to configure Model/Wing type.  Without it, the initial setup will not work properly.

* #751 More fixes on mixers and servo reverse

-- Fix problem reversing servos when using vtail/delta mix
-- Properly detect ch order of multimodule

* #751 Updated channel naming and docs

Updated readme documentation
Consistent naming of Ch across the code.

* #751 Fix message displaying data path

* #751  More improvements

1. Much easier to select channels > Ch6 for FMode, Gain and Panic channels
2. B&W version for smaller screens (128x64).. Memory footprint still a problem.
3. Fix a lot typos/misspell/grammar in the documentation

* Create DSM_AR636_TextGen.lua

Script to show Telemetry TextGen screens
for AR636 Receiver.
Really useful for BLADE helis using the AR636

Could replace dsmPID.lua

Still needs to be ported to smaller screens.

* #751 Enhancements for Lua Script tools

Enhancements

* Delete DSM_AR636_TextGen.lua

The TextGen functionality is included in DSM_AR636_Tel.lua. No longer needed

---------

Co-authored-by: pascallanger <pascal_langer@yahoo.fr>
2023-03-19 06:19:35 +01:00
Frankie Arzu
66ac007d4c Frankie dsm telemetry lua scripts enhancements (#835)
* #751 DSM Enhancements

 #751 DSM Forward Programming Enhancements (New GUI, etc)

* Make both work on EdgeTx and OpenTX

* #751 Turn OFF simulation by default

Distribution code with RX simulation OFF
Simulation should be only for Development

* #751 Update Readme Documentation

Updated the Readme.txt documentation
and removed compiled luac file that was check in by mistake

* #751 Fix problems With Reset RX

1. Fix problem when trying to Factory Reset. Enter Bind Mode. Save backup, Restore Backup

2. Found a way to advance on the Gyro initial Setup menus.. a bit of a hack, but works.

3. Handle RX resets properly. It needed after initial setup

* #751 Cosmetic and Show Orientation Images

#751
1. Fix problems when text contradictions between Menu/Line Headers and List Values
2. Show Images of RX orientations
3. Able to Hack getting into Initial Setup and other menus who was failing before
4. Custumize the way Flight Mode reports the Value on Screen

* #751 add check for required libraries

Add check that the required files in DSMLIB exist

* #751

Write documentation about the protocol so that we don't forget later what we know, and enable others to understand the logs and maybe help solve problems.

* #766

Change the way to detect that the files exist. now works on both ETX and OTX

* #766 Strange Flickering in OTX

Strange Flickering happening on OTX. Refreshing the screen on every cycle fixed the problem

* #766 Change way of dectecting EdgeTX

Change way of detecting OTX in multiple versions: OTX 2.3.14 and 2.3.15

* #766  make editable Gain Values

Gains and other settings should be editable even when they are VALUE_NOCHANGING. Flight Mode is an exception that is handled properly. Right align numbers.

* #766 More enhacements

Added AR630
Make numbers right justified
Cleanup some log messages and line types.
Updated DSM FWD prog documentation

* #751 more cosmetic things

1. Added AR10360T,
2. Simplify way to configured the hack for more receivers.
3. Change some texts on menus to march spektrum
4. Background color in Spektrum theme to match

* #751 A few final changes

1. Update channel names to include channel number. i.e: Ch5 (Gear)
2,  Fix flight mode display for Heli Receiver
3. i think the unknown lines are to request info about the TX settings

* #751

1. Added Warning Screen
2. Correct handling of Unknown lines in Gyro Settings->Initial Setup

* #751

New v0.51 version.
- Added new menus to configure Model/Wing type.  Without it, the initial setup will not work properly.

* #751 More fixes on mixers and servo reverse

-- Fix problem reversing servos when using vtail/delta mix
-- Properly detect ch order of multimodule

* #751 Updated channel naming and docs

Updated readme documentation
Consistent naming of Ch across the code.

* #751 Fix message displaying data path

* #751  More improvements

1. Much easier to select channels > Ch6 for FMode, Gain and Panic channels
2. B&W version for smaller screens (128x64).. Memory footprint still a problem.
3. Fix a lot typos/misspell/grammar in the documentation

* Create DSM_AR636_TextGen.lua

Script to show Telemetry TextGen screens
for AR636 Receiver.
Really useful for BLADE helis using the AR636

Could replace dsmPID.lua

Still needs to be ported to smaller screens.

* #751 Enhancements for Lua Script tools

Enhancements

---------

Co-authored-by: pascallanger <pascal_langer@yahoo.fr>
2023-03-18 19:31:48 +01:00
Frankie Arzu
139cd4c583 Telemetry TextGen/Screens for BLADE Helis with AR636 (#813)
* #751 DSM Enhancements

 #751 DSM Forward Programming Enhancements (New GUI, etc)

* Make both work on EdgeTx and OpenTX

* #751 Turn OFF simulation by default

Distribution code with RX simulation OFF
Simulation should be only for Development

* #751 Update Readme Documentation

Updated the Readme.txt documentation
and removed compiled luac file that was check in by mistake

* #751 Fix problems With Reset RX

1. Fix problem when trying to Factory Reset. Enter Bind Mode. Save backup, Restore Backup

2. Found a way to advance on the Gyro initial Setup menus.. a bit of a hack, but works.

3. Handle RX resets properly. It needed after initial setup

* #751 Cosmetic and Show Orientation Images

#751
1. Fix problems when text contradictions between Menu/Line Headers and List Values
2. Show Images of RX orientations
3. Able to Hack getting into Initial Setup and other menus who was failing before
4. Custumize the way Flight Mode reports the Value on Screen

* #751 add check for required libraries

Add check that the required files in DSMLIB exist

* #751

Write documentation about the protocol so that we don't forget later what we know, and enable others to understand the logs and maybe help solve problems.

* #766

Change the way to detect that the files exist. now works on both ETX and OTX

* #766 Strange Flickering in OTX

Strange Flickering happening on OTX. Refreshing the screen on every cycle fixed the problem

* #766 Change way of dectecting EdgeTX

Change way of detecting OTX in multiple versions: OTX 2.3.14 and 2.3.15

* #766  make editable Gain Values

Gains and other settings should be editable even when they are VALUE_NOCHANGING. Flight Mode is an exception that is handled properly. Right align numbers.

* #766 More enhacements

Added AR630
Make numbers right justified
Cleanup some log messages and line types.
Updated DSM FWD prog documentation

* #751 more cosmetic things

1. Added AR10360T,
2. Simplify way to configured the hack for more receivers.
3. Change some texts on menus to march spektrum
4. Background color in Spektrum theme to match

* #751 A few final changes

1. Update channel names to include channel number. i.e: Ch5 (Gear)
2,  Fix flight mode display for Heli Receiver
3. i think the unknown lines are to request info about the TX settings

* #751

1. Added Warning Screen
2. Correct handling of Unknown lines in Gyro Settings->Initial Setup

* #751

New v0.51 version.
- Added new menus to configure Model/Wing type.  Without it, the initial setup will not work properly.

* #751 More fixes on mixers and servo reverse

-- Fix problem reversing servos when using vtail/delta mix
-- Properly detect ch order of multimodule

* #751 Updated channel naming and docs

Updated readme documentation
Consistent naming of Ch across the code.

* #751 Fix message displaying data path

* #751  More improvements

1. Much easier to select channels > Ch6 for FMode, Gain and Panic channels
2. B&W version for smaller screens (128x64).. Memory footprint still a problem.
3. Fix a lot typos/misspell/grammar in the documentation

* Create DSM_AR636_TextGen.lua

Script to show Telemetry TextGen screens
for AR636 Receiver.
Really useful for BLADE helis using the AR636

Could replace dsmPID.lua

Still needs to be ported to smaller screens.

---------

Co-authored-by: pascallanger <pascal_langer@yahoo.fr>
2023-02-07 10:48:46 +01:00
richardclli
0fed2486f5 FX9630 protocol support, resolves #801 (#805)
New protocol FX9630
2023-01-16 20:06:27 +01:00
Filip Kotoucek
11c01004bf KF606: subprotocol ZC-Z50v2 Cessna (#797)
Maybe newer iteration of Z50. My plane does not have front propeller.
But if there is one, its just for design. This model does not have front motor.

Thanks @pascallanger for support and reviews.
2023-01-15 21:26:35 +01:00
Frankie Arzu
f49f03d7da Frankie dsm fwrd prg enhancements (#806)
* #751 DSM Enhancements

 #751 DSM Forward Programming Enhancements (New GUI, etc)

* Make both work on EdgeTx and OpenTX

* #751 Turn OFF simulation by default

Distribution code with RX simulation OFF
Simulation should be only for Development

* #751 Update Readme Documentation

Updated the Readme.txt documentation
and removed compiled luac file that was check in by mistake

* #751 Fix problems With Reset RX

1. Fix problem when trying to Factory Reset. Enter Bind Mode. Save backup, Restore Backup

2. Found a way to advance on the Gyro initial Setup menus.. a bit of a hack, but works.

3. Handle RX resets properly. It needed after initial setup

* #751 Cosmetic and Show Orientation Images

#751
1. Fix problems when text contradictions between Menu/Line Headers and List Values
2. Show Images of RX orientations
3. Able to Hack getting into Initial Setup and other menus who was failing before
4. Custumize the way Flight Mode reports the Value on Screen

* #751 add check for required libraries

Add check that the required files in DSMLIB exist

* #751

Write documentation about the protocol so that we don't forget later what we know, and enable others to understand the logs and maybe help solve problems.

* #766

Change the way to detect that the files exist. now works on both ETX and OTX

* #766 Strange Flickering in OTX

Strange Flickering happening on OTX. Refreshing the screen on every cycle fixed the problem

* #766 Change way of dectecting EdgeTX

Change way of detecting OTX in multiple versions: OTX 2.3.14 and 2.3.15

* #766  make editable Gain Values

Gains and other settings should be editable even when they are VALUE_NOCHANGING. Flight Mode is an exception that is handled properly. Right align numbers.

* #766 More enhacements

Added AR630
Make numbers right justified
Cleanup some log messages and line types.
Updated DSM FWD prog documentation

* #751 more cosmetic things

1. Added AR10360T,
2. Simplify way to configured the hack for more receivers.
3. Change some texts on menus to march spektrum
4. Background color in Spektrum theme to match

* #751 A few final changes

1. Update channel names to include channel number. i.e: Ch5 (Gear)
2,  Fix flight mode display for Heli Receiver
3. i think the unknown lines are to request info about the TX settings

* #751

1. Added Warning Screen
2. Correct handling of Unknown lines in Gyro Settings->Initial Setup

* #751

New v0.51 version.
- Added new menus to configure Model/Wing type.  Without it, the initial setup will not work properly.

* #751 More fixes on mixers and servo reverse

-- Fix problem reversing servos when using vtail/delta mix
-- Properly detect ch order of multimodule

* #751 Updated channel naming and docs

Updated readme documentation
Consistent naming of Ch across the code.

* #751 Fix message displaying data path

* #751  More improvements

1. Much easier to select channels > Ch6 for FMode, Gain and Panic channels
2. B&W version for smaller screens (128x64).. Memory footprint still a problem.
3. Fix a lot typos/misspell/grammar in the documentation

Co-authored-by: pascallanger <pascal_langer@yahoo.fr>
2023-01-15 11:27:34 +01:00
Louis Botha
90bb5f8871 Update Protocols_Details.md (#796)
Fixed spelling mistake
2023-01-12 10:59:20 +01:00
Frankie Arzu
401cc76f20 Fix message displaying the DataPath after saving (#787)
* #751 DSM Enhancements

 #751 DSM Forward Programming Enhancements (New GUI, etc)

* Make both work on EdgeTx and OpenTX

* #751 Turn OFF simulation by default

Distribution code with RX simulation OFF
Simulation should be only for Development

* #751 Update Readme Documentation

Updated the Readme.txt documentation
and removed compiled luac file that was check in by mistake

* #751 Fix problems With Reset RX

1. Fix problem when trying to Factory Reset. Enter Bind Mode. Save backup, Restore Backup

2. Found a way to advance on the Gyro initial Setup menus.. a bit of a hack, but works.

3. Handle RX resets properly. It needed after initial setup

* #751 Cosmetic and Show Orientation Images

#751
1. Fix problems when text contradictions between Menu/Line Headers and List Values
2. Show Images of RX orientations
3. Able to Hack getting into Initial Setup and other menus who was failing before
4. Custumize the way Flight Mode reports the Value on Screen

* #751 add check for required libraries

Add check that the required files in DSMLIB exist

* #751

Write documentation about the protocol so that we don't forget later what we know, and enable others to understand the logs and maybe help solve problems.

* #766

Change the way to detect that the files exist. now works on both ETX and OTX

* #766 Strange Flickering in OTX

Strange Flickering happening on OTX. Refreshing the screen on every cycle fixed the problem

* #766 Change way of dectecting EdgeTX

Change way of detecting OTX in multiple versions: OTX 2.3.14 and 2.3.15

* #766  make editable Gain Values

Gains and other settings should be editable even when they are VALUE_NOCHANGING. Flight Mode is an exception that is handled properly. Right align numbers.

* #766 More enhacements

Added AR630
Make numbers right justified
Cleanup some log messages and line types.
Updated DSM FWD prog documentation

* #751 more cosmetic things

1. Added AR10360T,
2. Simplify way to configured the hack for more receivers.
3. Change some texts on menus to march spektrum
4. Background color in Spektrum theme to match

* #751 A few final changes

1. Update channel names to include channel number. i.e: Ch5 (Gear)
2,  Fix flight mode display for Heli Receiver
3. i think the unknown lines are to request info about the TX settings

* #751

1. Added Warning Screen
2. Correct handling of Unknown lines in Gyro Settings->Initial Setup

* #751

New v0.51 version.
- Added new menus to configure Model/Wing type.  Without it, the initial setup will not work properly.

* #751 More fixes on mixers and servo reverse

-- Fix problem reversing servos when using vtail/delta mix
-- Properly detect ch order of multimodule

* #751 Updated channel naming and docs

Updated readme documentation
Consistent naming of Ch across the code.

* #751 Fix message displaying data path

Co-authored-by: pascallanger <pascal_langer@yahoo.fr>
2022-12-20 23:48:23 +01:00
Frankie Arzu
6297810edc Updated Ch naming across all display, and updated Docs (#786)
* #751 DSM Enhancements

 #751 DSM Forward Programming Enhancements (New GUI, etc)

* Make both work on EdgeTx and OpenTX

* #751 Turn OFF simulation by default

Distribution code with RX simulation OFF
Simulation should be only for Development

* #751 Update Readme Documentation

Updated the Readme.txt documentation
and removed compiled luac file that was check in by mistake

* #751 Fix problems With Reset RX

1. Fix problem when trying to Factory Reset. Enter Bind Mode. Save backup, Restore Backup

2. Found a way to advance on the Gyro initial Setup menus.. a bit of a hack, but works.

3. Handle RX resets properly. It needed after initial setup

* #751 Cosmetic and Show Orientation Images

#751
1. Fix problems when text contradictions between Menu/Line Headers and List Values
2. Show Images of RX orientations
3. Able to Hack getting into Initial Setup and other menus who was failing before
4. Custumize the way Flight Mode reports the Value on Screen

* #751 add check for required libraries

Add check that the required files in DSMLIB exist

* #751

Write documentation about the protocol so that we don't forget later what we know, and enable others to understand the logs and maybe help solve problems.

* #766

Change the way to detect that the files exist. now works on both ETX and OTX

* #766 Strange Flickering in OTX

Strange Flickering happening on OTX. Refreshing the screen on every cycle fixed the problem

* #766 Change way of dectecting EdgeTX

Change way of detecting OTX in multiple versions: OTX 2.3.14 and 2.3.15

* #766  make editable Gain Values

Gains and other settings should be editable even when they are VALUE_NOCHANGING. Flight Mode is an exception that is handled properly. Right align numbers.

* #766 More enhacements

Added AR630
Make numbers right justified
Cleanup some log messages and line types.
Updated DSM FWD prog documentation

* #751 more cosmetic things

1. Added AR10360T,
2. Simplify way to configured the hack for more receivers.
3. Change some texts on menus to march spektrum
4. Background color in Spektrum theme to match

* #751 A few final changes

1. Update channel names to include channel number. i.e: Ch5 (Gear)
2,  Fix flight mode display for Heli Receiver
3. i think the unknown lines are to request info about the TX settings

* #751

1. Added Warning Screen
2. Correct handling of Unknown lines in Gyro Settings->Initial Setup

* #751

New v0.51 version.
- Added new menus to configure Model/Wing type.  Without it, the initial setup will not work properly.

* #751 More fixes on mixers and servo reverse

-- Fix problem reversing servos when using vtail/delta mix
-- Properly detect ch order of multimodule

* #751 Updated channel naming and docs

Updated readme documentation
Consistent naming of Ch across the code.

Co-authored-by: pascallanger <pascal_langer@yahoo.fr>
2022-12-20 22:58:38 +01:00
Frankie Arzu
01aef0a822 Frankie dsm fwrd prg enhancements (#785)
* #751 DSM Enhancements

 #751 DSM Forward Programming Enhancements (New GUI, etc)

* Make both work on EdgeTx and OpenTX

* #751 Turn OFF simulation by default

Distribution code with RX simulation OFF
Simulation should be only for Development

* #751 Update Readme Documentation

Updated the Readme.txt documentation
and removed compiled luac file that was check in by mistake

* #751 Fix problems With Reset RX

1. Fix problem when trying to Factory Reset. Enter Bind Mode. Save backup, Restore Backup

2. Found a way to advance on the Gyro initial Setup menus.. a bit of a hack, but works.

3. Handle RX resets properly. It needed after initial setup

* #751 Cosmetic and Show Orientation Images

#751
1. Fix problems when text contradictions between Menu/Line Headers and List Values
2. Show Images of RX orientations
3. Able to Hack getting into Initial Setup and other menus who was failing before
4. Custumize the way Flight Mode reports the Value on Screen

* #751 add check for required libraries

Add check that the required files in DSMLIB exist

* #751

Write documentation about the protocol so that we don't forget later what we know, and enable others to understand the logs and maybe help solve problems.

* #766

Change the way to detect that the files exist. now works on both ETX and OTX

* #766 Strange Flickering in OTX

Strange Flickering happening on OTX. Refreshing the screen on every cycle fixed the problem

* #766 Change way of dectecting EdgeTX

Change way of detecting OTX in multiple versions: OTX 2.3.14 and 2.3.15

* #766  make editable Gain Values

Gains and other settings should be editable even when they are VALUE_NOCHANGING. Flight Mode is an exception that is handled properly. Right align numbers.

* #766 More enhacements

Added AR630
Make numbers right justified
Cleanup some log messages and line types.
Updated DSM FWD prog documentation

* #751 more cosmetic things

1. Added AR10360T,
2. Simplify way to configured the hack for more receivers.
3. Change some texts on menus to march spektrum
4. Background color in Spektrum theme to match

* #751 A few final changes

1. Update channel names to include channel number. i.e: Ch5 (Gear)
2,  Fix flight mode display for Heli Receiver
3. i think the unknown lines are to request info about the TX settings

* #751

1. Added Warning Screen
2. Correct handling of Unknown lines in Gyro Settings->Initial Setup

* #751

New v0.51 version.
- Added new menus to configure Model/Wing type.  Without it, the initial setup will not work properly.

* #751 More fixes on mixers and servo reverse

-- Fix problem reversing servos when using vtail/delta mix
-- Properly detect ch order of multimodule

Co-authored-by: pascallanger <pascal_langer@yahoo.fr>
2022-12-20 10:12:34 +01:00
Frankie Arzu
186730231e Fwrd Programming New Model/Wingtype Setup Menus (#784)
* #751 DSM Enhancements

 #751 DSM Forward Programming Enhancements (New GUI, etc)

* Make both work on EdgeTx and OpenTX

* #751 Turn OFF simulation by default

Distribution code with RX simulation OFF
Simulation should be only for Development

* #751 Update Readme Documentation

Updated the Readme.txt documentation
and removed compiled luac file that was check in by mistake

* #751 Fix problems With Reset RX

1. Fix problem when trying to Factory Reset. Enter Bind Mode. Save backup, Restore Backup

2. Found a way to advance on the Gyro initial Setup menus.. a bit of a hack, but works.

3. Handle RX resets properly. It needed after initial setup

* #751 Cosmetic and Show Orientation Images

#751
1. Fix problems when text contradictions between Menu/Line Headers and List Values
2. Show Images of RX orientations
3. Able to Hack getting into Initial Setup and other menus who was failing before
4. Custumize the way Flight Mode reports the Value on Screen

* #751 add check for required libraries

Add check that the required files in DSMLIB exist

* #751

Write documentation about the protocol so that we don't forget later what we know, and enable others to understand the logs and maybe help solve problems.

* #766

Change the way to detect that the files exist. now works on both ETX and OTX

* #766 Strange Flickering in OTX

Strange Flickering happening on OTX. Refreshing the screen on every cycle fixed the problem

* #766 Change way of dectecting EdgeTX

Change way of detecting OTX in multiple versions: OTX 2.3.14 and 2.3.15

* #766  make editable Gain Values

Gains and other settings should be editable even when they are VALUE_NOCHANGING. Flight Mode is an exception that is handled properly. Right align numbers.

* #766 More enhacements

Added AR630
Make numbers right justified
Cleanup some log messages and line types.
Updated DSM FWD prog documentation

* #751 more cosmetic things

1. Added AR10360T,
2. Simplify way to configured the hack for more receivers.
3. Change some texts on menus to march spektrum
4. Background color in Spektrum theme to match

* #751 A few final changes

1. Update channel names to include channel number. i.e: Ch5 (Gear)
2,  Fix flight mode display for Heli Receiver
3. i think the unknown lines are to request info about the TX settings

* #751

1. Added Warning Screen
2. Correct handling of Unknown lines in Gyro Settings->Initial Setup

* #751

New v0.51 version.
- Added new menus to configure Model/Wing type.  Without it, the initial setup will not work properly.

Co-authored-by: pascallanger <pascal_langer@yahoo.fr>
2022-12-18 19:45:50 +01:00
pascallanger
770a12ffdf EU 2022-12-08 08:28:45 +01:00
pascallanger
40fa242012 Update Protocols_Details.md 2022-12-06 15:53:42 +01:00
Frankie Arzu
c4e70ab4fd Frankie dsm fwrd prg enhancements (#776)
* #751 DSM Enhancements

 #751 DSM Forward Programming Enhancements (New GUI, etc)

* Make both work on EdgeTx and OpenTX

* #751 Turn OFF simulation by default

Distribution code with RX simulation OFF
Simulation should be only for Development

* #751 Update Readme Documentation

Updated the Readme.txt documentation
and removed compiled luac file that was check in by mistake

* #751 Fix problems With Reset RX

1. Fix problem when trying to Factory Reset. Enter Bind Mode. Save backup, Restore Backup

2. Found a way to advance on the Gyro initial Setup menus.. a bit of a hack, but works.

3. Handle RX resets properly. It needed after initial setup

* #751 Cosmetic and Show Orientation Images

#751
1. Fix problems when text contradictions between Menu/Line Headers and List Values
2. Show Images of RX orientations
3. Able to Hack getting into Initial Setup and other menus who was failing before
4. Custumize the way Flight Mode reports the Value on Screen

* #751 add check for required libraries

Add check that the required files in DSMLIB exist

* #751

Write documentation about the protocol so that we don't forget later what we know, and enable others to understand the logs and maybe help solve problems.

* #766

Change the way to detect that the files exist. now works on both ETX and OTX

* #766 Strange Flickering in OTX

Strange Flickering happening on OTX. Refreshing the screen on every cycle fixed the problem

* #766 Change way of dectecting EdgeTX

Change way of detecting OTX in multiple versions: OTX 2.3.14 and 2.3.15

* #766  make editable Gain Values

Gains and other settings should be editable even when they are VALUE_NOCHANGING. Flight Mode is an exception that is handled properly. Right align numbers.

* #766 More enhacements

Added AR630
Make numbers right justified
Cleanup some log messages and line types.
Updated DSM FWD prog documentation

* #751 more cosmetic things

1. Added AR10360T,
2. Simplify way to configured the hack for more receivers.
3. Change some texts on menus to march spektrum
4. Background color in Spektrum theme to match

* #751 A few final changes

1. Update channel names to include channel number. i.e: Ch5 (Gear)
2,  Fix flight mode display for Heli Receiver
3. i think the unknown lines are to request info about the TX settings

* #751

1. Added Warning Screen
2. Correct handling of Unknown lines in Gyro Settings->Initial Setup

Co-authored-by: pascallanger <pascal_langer@yahoo.fr>
2022-12-02 08:53:13 +01:00
Frankie Arzu
2da8b3c42a Frankie dsm fwrd prg enhancements (#773)
* #751 DSM Enhancements

 #751 DSM Forward Programming Enhancements (New GUI, etc)

* Make both work on EdgeTx and OpenTX

* #751 Turn OFF simulation by default

Distribution code with RX simulation OFF
Simulation should be only for Development

* #751 Update Readme Documentation

Updated the Readme.txt documentation
and removed compiled luac file that was check in by mistake

* #751 Fix problems With Reset RX

1. Fix problem when trying to Factory Reset. Enter Bind Mode. Save backup, Restore Backup

2. Found a way to advance on the Gyro initial Setup menus.. a bit of a hack, but works.

3. Handle RX resets properly. It needed after initial setup

* #751 Cosmetic and Show Orientation Images

#751
1. Fix problems when text contradictions between Menu/Line Headers and List Values
2. Show Images of RX orientations
3. Able to Hack getting into Initial Setup and other menus who was failing before
4. Custumize the way Flight Mode reports the Value on Screen

* #751 add check for required libraries

Add check that the required files in DSMLIB exist

* #751

Write documentation about the protocol so that we don't forget later what we know, and enable others to understand the logs and maybe help solve problems.

* #766

Change the way to detect that the files exist. now works on both ETX and OTX

* #766 Strange Flickering in OTX

Strange Flickering happening on OTX. Refreshing the screen on every cycle fixed the problem

* #766 Change way of dectecting EdgeTX

Change way of detecting OTX in multiple versions: OTX 2.3.14 and 2.3.15

* #766  make editable Gain Values

Gains and other settings should be editable even when they are VALUE_NOCHANGING. Flight Mode is an exception that is handled properly. Right align numbers.

* #766 More enhacements

Added AR630
Make numbers right justified
Cleanup some log messages and line types.
Updated DSM FWD prog documentation

* #751 more cosmetic things

1. Added AR10360T,
2. Simplify way to configured the hack for more receivers.
3. Change some texts on menus to march spektrum
4. Background color in Spektrum theme to match

* #751 A few final changes

1. Update channel names to include channel number. i.e: Ch5 (Gear)
2,  Fix flight mode display for Heli Receiver
3. i think the unknown lines are to request info about the TX settings

Co-authored-by: pascallanger <pascal_langer@yahoo.fr>
2022-12-01 08:57:33 +01:00
Frankie Arzu
38a79c816a Frankie dsm fwrd prg enhancements (#772)
* #751 DSM Enhancements

 #751 DSM Forward Programming Enhancements (New GUI, etc)

* Make both work on EdgeTx and OpenTX

* #751 Turn OFF simulation by default

Distribution code with RX simulation OFF
Simulation should be only for Development

* #751 Update Readme Documentation

Updated the Readme.txt documentation
and removed compiled luac file that was check in by mistake

* #751 Fix problems With Reset RX

1. Fix problem when trying to Factory Reset. Enter Bind Mode. Save backup, Restore Backup

2. Found a way to advance on the Gyro initial Setup menus.. a bit of a hack, but works.

3. Handle RX resets properly. It needed after initial setup

* #751 Cosmetic and Show Orientation Images

#751
1. Fix problems when text contradictions between Menu/Line Headers and List Values
2. Show Images of RX orientations
3. Able to Hack getting into Initial Setup and other menus who was failing before
4. Custumize the way Flight Mode reports the Value on Screen

* #751 add check for required libraries

Add check that the required files in DSMLIB exist

* #751

Write documentation about the protocol so that we don't forget later what we know, and enable others to understand the logs and maybe help solve problems.

* #766

Change the way to detect that the files exist. now works on both ETX and OTX

* #766 Strange Flickering in OTX

Strange Flickering happening on OTX. Refreshing the screen on every cycle fixed the problem

* #766 Change way of dectecting EdgeTX

Change way of detecting OTX in multiple versions: OTX 2.3.14 and 2.3.15

* #766  make editable Gain Values

Gains and other settings should be editable even when they are VALUE_NOCHANGING. Flight Mode is an exception that is handled properly. Right align numbers.

* #766 More enhacements

Added AR630
Make numbers right justified
Cleanup some log messages and line types.
Updated DSM FWD prog documentation

* #751 more cosmetic things

1. Added AR10360T,
2. Simplify way to configured the hack for more receivers.
3. Change some texts on menus to march spektrum
4. Background color in Spektrum theme to match

Co-authored-by: pascallanger <pascal_langer@yahoo.fr>
2022-11-29 23:23:10 +01:00
Frankie Arzu
1d8f1a0857 Frankie dsm fwrd prg enhancements (#771)
* #751 DSM Enhancements

 #751 DSM Forward Programming Enhancements (New GUI, etc)

* Make both work on EdgeTx and OpenTX

* #751 Turn OFF simulation by default

Distribution code with RX simulation OFF
Simulation should be only for Development

* #751 Update Readme Documentation

Updated the Readme.txt documentation
and removed compiled luac file that was check in by mistake

* #751 Fix problems With Reset RX

1. Fix problem when trying to Factory Reset. Enter Bind Mode. Save backup, Restore Backup

2. Found a way to advance on the Gyro initial Setup menus.. a bit of a hack, but works.

3. Handle RX resets properly. It needed after initial setup

* #751 Cosmetic and Show Orientation Images

#751
1. Fix problems when text contradictions between Menu/Line Headers and List Values
2. Show Images of RX orientations
3. Able to Hack getting into Initial Setup and other menus who was failing before
4. Custumize the way Flight Mode reports the Value on Screen

* #751 add check for required libraries

Add check that the required files in DSMLIB exist

* #751

Write documentation about the protocol so that we don't forget later what we know, and enable others to understand the logs and maybe help solve problems.

* #766

Change the way to detect that the files exist. now works on both ETX and OTX

* #766 Strange Flickering in OTX

Strange Flickering happening on OTX. Refreshing the screen on every cycle fixed the problem

* #766 Change way of dectecting EdgeTX

Change way of detecting OTX in multiple versions: OTX 2.3.14 and 2.3.15

* #766  make editable Gain Values

Gains and other settings should be editable even when they are VALUE_NOCHANGING. Flight Mode is an exception that is handled properly. Right align numbers.

* #766 More enhacements

Added AR630
Make numbers right justified
Cleanup some log messages and line types.
Updated DSM FWD prog documentation

Co-authored-by: pascallanger <pascal_langer@yahoo.fr>
2022-11-29 07:46:40 +01:00
Frankie Arzu
5901bac374 #766 Fix for editable Gains + Number formatting (#770)
* #751 DSM Enhancements

 #751 DSM Forward Programming Enhancements (New GUI, etc)

* Make both work on EdgeTx and OpenTX

* #751 Turn OFF simulation by default

Distribution code with RX simulation OFF
Simulation should be only for Development

* #751 Update Readme Documentation

Updated the Readme.txt documentation
and removed compiled luac file that was check in by mistake

* #751 Fix problems With Reset RX

1. Fix problem when trying to Factory Reset. Enter Bind Mode. Save backup, Restore Backup

2. Found a way to advance on the Gyro initial Setup menus.. a bit of a hack, but works.

3. Handle RX resets properly. It needed after initial setup

* #751 Cosmetic and Show Orientation Images

#751
1. Fix problems when text contradictions between Menu/Line Headers and List Values
2. Show Images of RX orientations
3. Able to Hack getting into Initial Setup and other menus who was failing before
4. Custumize the way Flight Mode reports the Value on Screen

* #751 add check for required libraries

Add check that the required files in DSMLIB exist

* #751

Write documentation about the protocol so that we don't forget later what we know, and enable others to understand the logs and maybe help solve problems.

* #766

Change the way to detect that the files exist. now works on both ETX and OTX

* #766 Strange Flickering in OTX

Strange Flickering happening on OTX. Refreshing the screen on every cycle fixed the problem

* #766 Change way of dectecting EdgeTX

Change way of detecting OTX in multiple versions: OTX 2.3.14 and 2.3.15

* #766  make editable Gain Values

Gains and other settings should be editable even when they are VALUE_NOCHANGING. Flight Mode is an exception that is handled properly. Right align numbers.

Co-authored-by: pascallanger <pascal_langer@yahoo.fr>
2022-11-28 20:00:16 +01:00
Frankie Arzu
2e7b1dc904 #766 change validation of required files (#768)
* #751 DSM Enhancements

 #751 DSM Forward Programming Enhancements (New GUI, etc)

* Make both work on EdgeTx and OpenTX

* #751 Turn OFF simulation by default

Distribution code with RX simulation OFF
Simulation should be only for Development

* #751 Update Readme Documentation

Updated the Readme.txt documentation
and removed compiled luac file that was check in by mistake

* #751 Fix problems With Reset RX

1. Fix problem when trying to Factory Reset. Enter Bind Mode. Save backup, Restore Backup

2. Found a way to advance on the Gyro initial Setup menus.. a bit of a hack, but works.

3. Handle RX resets properly. It needed after initial setup

* #751 Cosmetic and Show Orientation Images

#751
1. Fix problems when text contradictions between Menu/Line Headers and List Values
2. Show Images of RX orientations
3. Able to Hack getting into Initial Setup and other menus who was failing before
4. Custumize the way Flight Mode reports the Value on Screen

* #751 add check for required libraries

Add check that the required files in DSMLIB exist

* #751

Write documentation about the protocol so that we don't forget later what we know, and enable others to understand the logs and maybe help solve problems.

* #766

Change the way to detect that the files exist. now works on both ETX and OTX

* #766 Strange Flickering in OTX

Strange Flickering happening on OTX. Refreshing the screen on every cycle fixed the problem

* #766 Change way of dectecting EdgeTX

Change way of detecting OTX in multiple versions: OTX 2.3.14 and 2.3.15

Co-authored-by: pascallanger <pascal_langer@yahoo.fr>
2022-11-27 15:10:02 +01:00
Frankie Arzu
7052751261 Frankie dsm fwrd prg enhancements (#763)
* #751 DSM Enhancements

 #751 DSM Forward Programming Enhancements (New GUI, etc)

* Make both work on EdgeTx and OpenTX

* #751 Turn OFF simulation by default

Distribution code with RX simulation OFF
Simulation should be only for Development

* #751 Update Readme Documentation

Updated the Readme.txt documentation
and removed compiled luac file that was check in by mistake

* #751 Fix problems With Reset RX

1. Fix problem when trying to Factory Reset. Enter Bind Mode. Save backup, Restore Backup

2. Found a way to advance on the Gyro initial Setup menus.. a bit of a hack, but works.

3. Handle RX resets properly. It needed after initial setup

* #751 Cosmetic and Show Orientation Images

#751
1. Fix problems when text contradictions between Menu/Line Headers and List Values
2. Show Images of RX orientations
3. Able to Hack getting into Initial Setup and other menus who was failing before
4. Custumize the way Flight Mode reports the Value on Screen

* #751 add check for required libraries

Add check that the required files in DSMLIB exist

* #751

Write documentation about the protocol so that we don't forget later what we know, and enable others to understand the logs and maybe help solve problems.

Co-authored-by: pascallanger <pascal_langer@yahoo.fr>
2022-11-21 09:52:15 +01:00
Frankie Arzu
60047e2c73 Frankie dsm fwrd prg enhancements (#762)
* #751 DSM Enhancements

 #751 DSM Forward Programming Enhancements (New GUI, etc)

* Make both work on EdgeTx and OpenTX

* #751 Turn OFF simulation by default

Distribution code with RX simulation OFF
Simulation should be only for Development

* #751 Update Readme Documentation

Updated the Readme.txt documentation
and removed compiled luac file that was check in by mistake

* #751 Fix problems With Reset RX

1. Fix problem when trying to Factory Reset. Enter Bind Mode. Save backup, Restore Backup

2. Found a way to advance on the Gyro initial Setup menus.. a bit of a hack, but works.

3. Handle RX resets properly. It needed after initial setup

* #751 Cosmetic and Show Orientation Images

#751
1. Fix problems when text contradictions between Menu/Line Headers and List Values
2. Show Images of RX orientations
3. Able to Hack getting into Initial Setup and other menus who was failing before
4. Custumize the way Flight Mode reports the Value on Screen

* #751 add check for required libraries

Add check that the required files in DSMLIB exist

Co-authored-by: pascallanger <pascal_langer@yahoo.fr>
2022-11-20 18:24:47 +01:00
Frankie Arzu
40b393ac4a Frankie DSM fwrd Prog (more improvements) (#760)
* #751 DSM Enhancements

 #751 DSM Forward Programming Enhancements (New GUI, etc)

* Make both work on EdgeTx and OpenTX

* #751 Turn OFF simulation by default

Distribution code with RX simulation OFF
Simulation should be only for Development

* #751 Update Readme Documentation

Updated the Readme.txt documentation
and removed compiled luac file that was check in by mistake

* #751 Fix problems With Reset RX

1. Fix problem when trying to Factory Reset. Enter Bind Mode. Save backup, Restore Backup

2. Found a way to advance on the Gyro initial Setup menus.. a bit of a hack, but works.

3. Handle RX resets properly. It needed after initial setup

* #751 Cosmetic and Show Orientation Images

#751
1. Fix problems when text contradictions between Menu/Line Headers and List Values
2. Show Images of RX orientations
3. Able to Hack getting into Initial Setup and other menus who was failing before
4. Custumize the way Flight Mode reports the Value on Screen

Co-authored-by: pascallanger <pascal_langer@yahoo.fr>
2022-11-20 18:01:16 +01:00
Frankie Arzu
1c6dc01959 Frankie dsm fwrd prg enhancements (#757)
* #751 DSM Enhancements

 #751 DSM Forward Programming Enhancements (New GUI, etc)

* Make both work on EdgeTx and OpenTX

* #751 Turn OFF simulation by default

Distribution code with RX simulation OFF
Simulation should be only for Development

* #751 Update Readme Documentation

Updated the Readme.txt documentation
and removed compiled luac file that was check in by mistake

* #751 Fix problems With Reset RX

1. Fix problem when trying to Factory Reset. Enter Bind Mode. Save backup, Restore Backup

2. Found a way to advance on the Gyro initial Setup menus.. a bit of a hack, but works.

3. Handle RX resets properly. It needed after initial setup

Co-authored-by: pascallanger <pascal_langer@yahoo.fr>
2022-11-18 10:41:59 +01:00
pascallanger
5148449066 FS2A: Turning on/off the LNA during bind. 2022-11-17 20:08:56 +01:00
Frankie Arzu
fcc4d19430 Frankie dsm fwrd prg enhancements (#755)
* #751 DSM Enhancements

 #751 DSM Forward Programming Enhancements (New GUI, etc)

* Make both work on EdgeTx and OpenTX

* #751 Turn OFF simulation by default

Distribution code with RX simulation OFF
Simulation should be only for Development

* #751 Update Readme Documentation

Updated the Readme.txt documentation
and removed compiled luac file that was check in by mistake

Co-authored-by: pascallanger <pascal_langer@yahoo.fr>
2022-11-17 17:50:36 +01:00
richardclli
c80f705fa2 Added MPM for Flysky PL18 PCB and casing design. (#754) 2022-11-17 11:37:11 +01:00
pascallanger
c95db35b41 Update Protocols_Details.md 2022-11-17 10:58:38 +01:00
pascallanger
35f3548992 Compilation option 2022-11-17 10:29:53 +01:00
pascallanger
58f6716035 Update README.md 2022-11-17 09:49:30 +01:00
pascallanger
2b15de0f90 Update README.md 2022-11-17 09:47:22 +01:00
pascallanger
be91409df9 Delete DSM FwdPrg.lua 2022-11-17 09:44:18 +01:00
Frankie Arzu
4d8e440965 Frankie dsm fwrd prg enhancements (#753)
DSM Forward Programming Enhancements (New GUI for Color+Touch and BW, etc). Work on EdgeTx and OpenTX.
2022-11-17 09:42:04 +01:00
pascallanger
2d469d074e Merge branch 'master' of https://github.com/pascallanger/DIY-Multiprotocol-TX-Module 2022-10-30 11:40:11 +01:00
pascallanger
96405d27b5 Extend Kyosho KT-17 bind time 2022-10-30 11:40:07 +01:00
yakulis
75c9fb40a7 Update DSM FwdPrg.lua (#735)
Panic Text Updates - The following strings were updated:
Text[0x00D2]="Panic Channel"
Text[0x008E]="Panic Delay"
Text[0x01FC]="Panic Flight Mode"
2022-10-12 11:35:09 +02:00
Pieter du Preez
cd1c15a45a Added documentation for using dfu-util for flashing STM32 targets. (#727)
This patch adds documentation, explaining how to flash firmware to DFU
capable multimodules.

A dfu-util command was taken and adapted from:
https://github.com/benlye/flash-multi/blob/master/doc/Troubleshooting.md

Using dfu-util is straight forward, easy and very safe.
2022-10-12 11:34:32 +02:00
pascallanger
2bd50f4c8c V761/TOPRC: new sub protocol
Top RC Hobby mini planes
2022-09-26 12:02:38 +02:00
yakulis
4c2ddcbe48 Update DSM FwdPrg.lua (#733)
Reversing 'Off' and 'On' text values in lines #555 and #556.  They are used in the SAFE and AS3X menu items in the DSM Forward Programming section, and they are functioning backwards. This will correct the issue. This is the fix for Issue #728
2022-09-11 06:01:02 -04:00
Ben Lye
d7f9ef6967 Use devel boards in CI workflow (#709) 2022-07-21 10:20:16 +02:00
pascallanger
bfc8c2f9fd Kyosho2/KT-17: only 1 ID 2022-07-20 17:20:27 +02:00
pascallanger
ce6243d6e3 FX/620: IDs 2022-07-17 09:07:28 +02:00
pascallanger
80f9ff4163 Update FX_nrf24l01.ino 2022-07-15 15:44:10 +02:00
pascallanger
d9f8a3989a FX/FX620: only 1 ID 2022-07-15 15:43:04 +02:00
pascallanger
416f7d5c19 FX/FX620 another try 2022-07-12 08:05:41 +02:00
pascallanger
eb24dd5549 FX/FX620
I messed up the hopping, I must have looked at the wrong file.
2022-07-11 11:12:20 +02:00
pascallanger
ba19592973 FX/FX620 debug off 2022-07-11 09:11:11 +02:00
pascallanger
98d8d7fb5f FX/FX620 new protocol 2022-07-11 09:03:31 +02:00
pascallanger
ad0947b0b7 Updated MT99xx/PA18: need someone to test... 2022-07-09 00:43:28 +02:00
pascallanger
c093f21b31 Update README.md 2022-07-08 10:38:13 +02:00
pascallanger
c5a3e305f9 Update Protocols_Details.md 2022-07-08 09:46:58 +02:00
pascallanger
e085602a6c FX816 is not limited to the P38 2022-07-08 09:46:28 +02:00
pascallanger
dee25215cf Update Protocols_Details.md 2022-07-08 09:41:16 +02:00
Michael
ef1bb1ead7 adjusted comment according to change in commit da33df43 (#696) 2022-07-07 11:44:46 +02:00
pascallanger
90170493c0 Update doc 2022-06-30 17:40:55 +02:00
pascallanger
00a9057186 Update Protocols_Details.md 2022-06-28 14:24:19 +02:00
pascallanger
05c300e979 Update Protocols_Details.md 2022-06-28 10:23:20 +02:00
pascallanger
6730ed6246 Update Protocols_Details.md 2022-06-27 17:20:55 +02:00
pascallanger
0a0463652b E129/C186 protocol
C186/E120 models
2022-06-27 16:59:48 +02:00
pascallanger
4f580a4286 Update Hardware.md 2022-06-16 10:36:34 +02:00
Michael
0616cab386 Fixes a problem where setting failsafe values was only possible once after bind and only set values for the first 12 channels. This fix allows setting failsafe values without having to rebind and sets failsafe values correctly for all possible 16 channels. (#695)
Notes for OpenTX/EdgeTX:
This fix doesn't exhibit servo jitter if failsafe mode was left on Custom, however it is still recommended to set failsafe mode back to Receiver after setting failsafe values.
It is still necessary to wait at least 8 seconds switching back from failsafe mode Custom to failsafe mode Receiver as OpenTX/EdgeTX will trigger the data transfer in Custom mode only every 7 seconds.

Bench tested with HoTT receivers GR-16, GR-24pro, GR-32
Flight tested with HoTT receiver GR-24
2022-06-13 14:28:21 +02:00
Michael
175cfa5e93 This is the Graupner HoTT adapted version of the Model Locator script. It uses the Graupner HoTT telemetry sensor "Rssi" instead of the OpenTX sensor "RSSI". (#693)
Reasoning: The OpenTX sensor "RSSI" is populated by the individual OpenTX telemetry protocol implementations and returns a value from 0..100 (percent) originating from the early FrSky implementation. It turns out that FrSky did not really provide a genuine signal strength indicator in units of dbm but a link quality indicator in 0..100%. With Graupner HoTT the link quality indicator is not a good basis for the model locator as it is very non-linear and doesn't change much with distance. Using the Graupner HoTT telemetry sensor "Rssi" which is a true signal strength indicator serves the purpose of locating a model much better as it varies much more with distance.
2022-06-07 10:51:26 +02:00
Pascal Langer
dbfccad568 Update DSM FwdPrg.lua 2022-04-25 10:33:16 +02:00
Pascal Langer
3fe6dc64fa KF606/MIG320: Added LED control 2022-04-15 17:29:25 +02:00
Peter Feerick
49068af59f fix: MultiConfig lua set and reset subProtocol (#672) 2022-03-25 09:12:14 +01:00
pascallanger
fbd81c6e26 Update Protocols_Details.md 2022-02-07 18:49:38 +01:00
Ryan5732
9cac96d6a7 Small Readme Typos (#661) 2022-02-03 14:11:26 +01:00
Pascal Langer
5987aa40a6 Another try on PA18 2022-01-25 15:21:22 +01:00
Pascal Langer
30cb812549 Try PA18 2022-01-24 08:36:00 +01:00
Pascal Langer
0fd2e36046 test PA18 2022-01-23 19:08:46 +01:00
Pascal Langer
8b05e55ebd MT99xx2/PA18: new protocol 2022-01-23 17:56:00 +01:00
Pascal Langer
af71a208fd Ready for release 2022-01-16 11:00:50 +01:00
mheimlich
7e5cb8e884 mention XK A800 in V911S/E119 details (#654) 2022-01-16 10:54:04 +01:00
MattCarothers
8c669ea015 Updated several text fields (#651) 2022-01-09 17:25:11 +01:00
Anders Höglund
acd8379077 A few more Spektrum Fwd Programming text updates (#632)
* DSM FP, Added AR8360T

* DSM FP, Added a few unkown empty lines
2021-11-19 08:37:28 +01:00
Pascal Langer
97c6088715 fix compilation? 2021-11-13 19:08:38 +01:00
Pascal Langer
db017c73b6 HS6200 emulation using CYRF for E01X protocol 2021-11-13 19:03:01 +01:00
Anders Höglund
24aaa0dd0c Text updates in Spektrum Fwd Prog LUA script (#630)
* DSM FP, Added AR636B

* DSM FP, Added AR637TA

* DSM FP, Added On, conflict with AR636B

* DSM FP, Rx name conflict resolved.
2021-11-12 18:37:52 +01:00
Michael
da33df4346 added packet_in[14] to transfer HoTT device warnings to OpenTx (#627) 2021-11-04 14:57:25 +01:00
Pascal Langer
22590ed4f7 Update DSM FwdPrg.lua 2021-10-26 16:34:38 +02:00
Pascal Langer
c0bc64c2aa V911S: increased bind time 2021-10-24 12:03:09 +02:00
Pascal Langer
694d968e8c Update Propel_nrf24l01.ino 2021-10-24 11:04:57 +02:00
Pascal Langer
fff3b8830e MT99xx/A180: F949S flags for RATE, RXLED and 3D6G 2021-10-24 11:04:44 +02:00
Pascal Langer
b740f4cd24 V911S/E119: add 6G_3D channel for P40 plane 2021-10-24 09:57:24 +02:00
Pascal Langer
e247b8b9c1 DSM Fwd Pgm updated 2021-10-20 15:13:56 +02:00
Pascal Langer
4f7af553d1 Update doc 2021-09-17 17:07:15 +02:00
Pascal Langer
570e6f8c64 Update Protocols_Details.md 2021-09-17 09:48:35 +02:00
Pascal Langer
b6e665b567 Devo: fix typo 2021-09-16 16:13:39 +02:00
Pascal Langer
48e82304a0 Update Devo_cyrf6936.ino 2021-09-16 00:30:46 +02:00
Pascal Langer
7b58b9aca0 Devo: support for 2 GPS formats
Use the Fixed ID field, 0/1 first GPS format, +2 for the other format -> 2/3
2021-09-16 00:11:25 +02:00
Pascal Langer
dfcf3f533c Update NRF24l01_SPI.ino 2021-09-16 00:08:47 +02:00
Pascal Langer
4c14925b4f Bump version for release 2021-09-12 19:35:11 +02:00
Pascal Langer
4c74bc869d Update _Config.h 2021-09-11 00:08:09 +02:00
Pascal Langer
45edfa1ec0 AFHDS2A doc update 2021-09-10 23:58:12 +02:00
Pascal Langer
88343b7424 Proto list: fix flags 2021-09-09 08:40:09 +02:00
Pascal Langer
13197840c2 V761: code cleanup 2021-09-09 08:39:37 +02:00
Pascal Langer
ffe4ac68fd Proto list: add number of protocols in the list 2021-09-08 14:30:01 +02:00
Pascal Langer
5bab5f03db Update Multi_Protos.ino 2021-09-08 13:38:25 +02:00
Pascal Langer
ae748e25f8 Update XN297Dump_nrf24l01.ino 2021-09-07 23:17:21 +02:00
Pascal Langer
e9c7959ecb Update V761_nrf24l01.ino 2021-09-07 23:17:11 +02:00
Pascal Langer
bf09855014 Another attempt 2021-09-07 16:59:06 +02:00
Pascal Langer
32bd39f209 Save space in the 5in1 modules 2021-09-07 15:07:37 +02:00
Pascal Langer
940f241b9d Fix compilation issues 2021-09-07 14:29:35 +02:00
Pascal Langer
5c00ce6b88 New 0 protocol: enable to list all protocols and sub protocols 2021-09-07 14:08:24 +02:00
Pascal Langer
016b282246 Multi Status: send frame as soon as a new protocol is selected 2021-09-05 22:15:56 +02:00
Pascal Langer
d6ecac1302 Xerall: few improvements 2021-09-04 11:48:41 +02:00
Ben Lye
901f8ca6b0 Disable some protocols for the DIY 5-in-1 (#618) 2021-09-01 15:20:10 +02:00
Pascal Langer
9c3b6ba9f6 Update Validate.h 2021-09-01 09:45:38 +02:00
Pascal Langer
53ec484028 Update Validate.h 2021-09-01 01:39:26 +02:00
Pascal Langer
246e808cb4 Xerall protocol 2021-09-01 01:21:38 +02:00
Pascal Langer
a7b68dc2aa F949G: will it work? 2021-08-27 10:22:47 +02:00
Pascal Langer
08404f9223 F949G: another try... 2021-08-26 23:43:42 +02:00
Pascal Langer
149554e61c Update MT99xx_ccnrf.ino 2021-08-26 23:23:38 +02:00
Pascal Langer
7b71425db2 F949G test with original radio ID 2021-08-26 23:19:59 +02:00
Pascal Langer
f9cfb7f20f Update Protocols_Details.md 2021-08-26 22:51:57 +02:00
Pascal Langer
506ee43d41 Update _Config.h 2021-08-26 22:35:42 +02:00
Pascal Langer
ebde0915cd MT99xx/F949G: new sub protocol 2021-08-26 22:33:38 +02:00
Pascal Langer
2501656bf4 Update XN297Dump_nrf24l01.ino 2021-08-26 11:52:36 +02:00
Pascal Langer
9356e7654e XN297EMU: allows to send and receive 0 payload length in enhanced mode 2021-08-25 19:07:36 +02:00
Pascal Langer
4f1e5d2452 BUGSMINI: fix
No one has reported an issue but from the look of the code it was broken since some time...
2021-08-25 19:05:24 +02:00
Ben Lye
64c75414d8 Add release build for 64KB CC2500-only module (#615) 2021-08-24 20:54:46 +02:00
Pascal Langer
5147833487 DSM RX: use directly the TX type and channels 2021-08-21 10:14:05 +02:00
Ben Lye
324419241f Prefix release binaries with mm instead of multi (#596)
Better for radios with 128x64 LCDs.
2021-08-16 17:59:07 +02:00
Pascal Langer
1a921b1cdb Disable multi config if telemetry is disabled 2021-07-05 17:08:57 +02:00
Pascal Langer
25c052c0a3 KF606: new sub protocol MIG320 2021-07-04 14:05:42 +02:00
Pascal Langer
a02586cca9 RadioLink: RSSI correction 2021-07-03 14:09:28 +02:00
Pascal Langer
226e082c5a E129 and E010R5 not supported on atmega328p 2021-06-30 09:45:25 +02:00
Pascal Langer
5afdff8477 V911S: Rate channel on CH6 (default is high) 2021-06-28 18:10:44 +02:00
Pascal Langer
c52ac2cefc Fix XN297Dump enhanced payload detection 2021-06-28 18:04:17 +02:00
pascallanger
09f39ea60f Update README.md 2021-06-27 12:38:53 +02:00
Harry Phillips
41e31eae6d Set reserved field in CABELL packet to current channel (#593) 2021-06-24 11:49:47 +02:00
Pascal Langer
dcf20951ba Update Protocols_Details.md 2021-06-20 18:51:23 +02:00
Pascal Langer
6e9ebfd695 Mould King: control up to 4 bricks at the same time 2021-06-20 18:39:27 +02:00
Pascal Langer
c36b112437 Update Multi_Config.ino 2021-06-17 15:42:09 +02:00
Pascal Langer
24fbd44f5b Multi Config: eeprom format for atmega 2021-06-17 15:40:28 +02:00
Pascal Langer
d0db7829e5 Multi config: enabled by default, LUA script update 2021-06-17 15:30:46 +02:00
Pascal Langer
58ed8ca60f Mould King: Analog and digital sub protocols 2021-05-27 19:01:08 +02:00
Pascal Langer
4d2c8ef04e Fix RadioLink: request telemetry every time to time like original instead of all the time 2021-05-25 14:54:17 +02:00
Pascal Langer
438e85c551 MouldKing: match original 2021-05-09 03:36:42 +02:00
Pascal Langer
06b336ee59 Mould King: fix frequencies 2021-05-04 14:58:40 +02:00
pascallanger
a93adeb75e Update Protocols_Details.md 2021-05-04 11:29:44 +02:00
Pascal Langer
802e69563e ... 2021-05-04 10:53:38 +02:00
Pascal Langer
a8897df3f2 New protocol: Mould King 2021-05-04 10:39:13 +02:00
Pascal Langer
7157d3d906 Losi: optimization 2021-05-03 16:57:08 +02:00
Pascal Langer
96b8a500b4 New protocol: Losi 2021-05-03 15:29:24 +02:00
Pascal Langer
51a3ef8ee9 Update XN297Dump_nrf24l01.ino 2021-05-01 18:45:20 +02:00
Pascal Langer
652d6604e7 Update Multiprotocol.h 2021-05-01 18:35:47 +02:00
Pascal Langer
b9028ab4b4 XN297Dump: CC2500 dump @250K 2021-05-01 18:15:34 +02:00
Konstantin Tretyakov
62c509b03c Add the IKEA Ansluta remote-controllable lighting protocol (#566)
* Add the IKEA Ansluta remote-controllable lighting protocol

* Fixes to IKEA Ansluta implementation
2021-04-24 21:46:29 +02:00
Pascal Langer
1648a0780a XK: fix twitch on other channels than rudder 2021-04-24 12:54:17 +02:00
pascallanger
3b1af68ed6 Update FUNDING.yml 2021-04-21 13:17:46 +02:00
pascallanger
aeed7bac57 Create FUNDING.yml 2021-04-20 23:17:50 +02:00
Pascal Langer
2bb76a40f3 Pelikan/SCX24: add second hopping table 2021-04-20 22:24:01 +02:00
Pascal Langer
0c129a45aa SCX24 IDs 2021-04-18 16:41:49 +02:00
Pascal Langer
2a383c7285 Pelikan/SCX24: fix? 2021-04-17 22:55:43 +02:00
Pascal Langer
34f16b0b66 MT99XX/Dragon: batt telemetry correction & low batt flag 2021-04-17 18:31:41 +02:00
Pascal Langer
a9d9c4cdfa Update A7105_SPI.ino 2021-04-17 11:57:00 +02:00
Pascal Langer
4a1c986dd0 Kyosho/FHSS fix? 2021-04-17 11:52:21 +02:00
Pascal Langer
756e9b3213 Update Protocols_Details.md 2021-04-16 15:00:33 +02:00
Pascal Langer
61a284863e Update Protocols_Details.md 2021-04-16 14:59:10 +02:00
Pascal Langer
39410c290b Pelikan/SCX24: new sub protocol 2021-04-16 14:50:53 +02:00
Pascal Langer
9e0684b6cb CABELL: code optimization 2021-04-07 09:02:50 +02:00
Pascal Langer
13add5b9f2 Devo: fix GPS year 2021-04-06 18:15:34 +02:00
Pascal Langer
475cd1af98 Atmega CC2500 build: remove FRSKYL to fit 2021-04-06 10:36:15 +02:00
Pascal Langer
04d08c6d67 FrSkyX2: changed bind bytes 2021-04-06 10:18:48 +02:00
Pascal Langer
6295bb1bbc Packed protocols definition to save space 2021-04-05 17:43:42 +02:00
Pascal Langer
931ba2bd68 Hitec: fix freq tune 2021-04-02 17:42:44 +02:00
Pascal Langer
769fb4ff94 Update Protocols_Details.md 2021-03-30 16:41:29 +02:00
Pascal Langer
aa7c18a2bd FrSkyX: fix the need to rebind RXs 2021-03-30 15:13:00 +02:00
Pascal Langer
f95cfa1261 Update Protocols_Details.md 2021-03-30 14:13:18 +02:00
Pascal Langer
8c12aaf2c1 DSMR: new surface protocol 2021-03-30 12:10:29 +02:00
Pascal Langer
94f73bd54f MT99xx: Added voltage telemetry for the Dragon sub protocol 2021-03-27 11:51:53 +01:00
Pascal Langer
9b3549d4a9 FrSkyX: code review 2021-03-25 10:10:53 +01:00
Pascal Langer
7bc05cb63c Update Multiprotocol.h 2021-03-19 17:11:06 +01:00
Pascal Langer
84780a9d90 Multi Config 2021-03-19 17:06:58 +01:00
Pascal Langer
37e029c612 Bug fix in XN297 emu layer when address is 3 bytes and CC2500 in use 2021-03-17 19:24:42 +01:00
Pascal Langer
c47ed8aca8 E016H has its own protocol now 2021-03-17 18:46:48 +01:00
Pascal Langer
5bb0752d5e Update include to xn297... 2021-03-17 17:19:41 +01:00
Pascal Langer
4a626eaf14 Change XN297 emulation layer
Loads of protocols have been touched by this change. Some testing has been done but please test on all your models.
The XN297 emulation selects in this order:
 - the CC2500 if it is available and bitrate=250K. Configure the option field automatically for RF tune.
 - the NRF for all bitrates if it is available
 - if NRF is not available and bitrate=1M then an invalid protocol is sent automatically to the radio.
CC2500 @250K can now receive normal and enhanced payloads.
OMP protocol supports telemetry on CC2500 and is also for NRF only modules including telemetry.
Separation of E016H (new protocol) from E01X due to different structure.
MJXQ, MT99XX, Q303 and XK: some sub protocols available on CC2500 only.
2021-03-17 17:05:42 +01:00
pascallanger
47de19c8a5 DSM RX output ranges 2021-03-15 08:45:27 +01:00
Pascal Langer
3d4cfa30ac Remove spaces 2021-03-15 08:43:25 +01:00
pascallanger
d658bee05a Add files via upload 2021-03-15 08:39:06 +01:00
pascallanger
820c181394 Update CPPM_HW_Mod.md 2021-03-15 08:07:42 +01:00
pascallanger
c9774f557e Add files via upload 2021-03-15 08:06:24 +01:00
Pascal Langer
b17618a5a8 Update Protocols_Details.md 2021-03-14 19:22:49 +01:00
Pascal Langer
03d0adbd74 CCPM: added comment to disable the telemetry after setup 2021-03-14 19:00:45 +01:00
Pascal Langer
905ee4b1ed Fix module boot issue? 2021-03-14 11:15:24 +01:00
Pascal Langer
dbc33951a4 Fix for module boot issue? 2021-03-13 18:18:07 +01:00
Pascal Langer
732e66cab2 HoTT: fix Text config in Sync mode 2021-03-13 11:01:51 +01:00
pascallanger
0dab92552a Update CPPM_HW_Mod.md 2021-03-08 17:47:28 +01:00
pascallanger
047952537a Update CPPM_HW_Mod.md 2021-03-08 13:39:59 +01:00
pascallanger
d4bf1fb36e Update CPPM_HW_Mod.md 2021-03-08 13:36:43 +01:00
pascallanger
ff817cd098 Update Protocols_Details.md 2021-03-08 11:36:59 +01:00
pascallanger
04ea44ed4b Update CPPM_HW_Mod.md 2021-03-08 11:19:10 +01:00
pascallanger
e23c8e2216 Add files via upload 2021-03-08 10:15:47 +01:00
pascallanger
afb4802a2c Update CPPM_HW_Mod.md 2021-03-07 17:34:16 +01:00
pascallanger
3a5d341514 CPPM hardware mod initial page 2021-03-07 17:31:45 +01:00
pascallanger
b6bcab1604 CPPM hardware mod images 2021-03-07 17:24:15 +01:00
Pascal Langer
0a998d2dc5 Enable CPPM by default 2021-03-07 11:12:49 +01:00
Pascal Langer
7927bc601e CPPM for RX protocols 2021-03-06 18:51:53 +01:00
Pascal Langer
f8cc913898 Update Multiprotocol.ino 2021-03-06 12:00:05 +01:00
Pascal Langer
a5428bc180 Removed SBUS trainer option 2021-03-06 11:33:32 +01:00
Pascal Langer
c0285f81f0 JOYSWAY: fix? 2021-03-05 19:57:33 +01:00
Pascal Langer
600049898a SBUS/CPPM: fixed switching from CPPM to SBUS 2021-03-04 21:28:06 +01:00
Pascal Langer
0e1db8f06b SBUS/CPPM: fixed switching from SBUS to CPPM
There is still an issue from CPPM to SBUS...
2021-03-04 19:02:45 +01:00
Pascal Langer
ec83f1e5a3 Disable SBUS serial when switching to CPPM 2021-03-04 15:23:23 +01:00
Pascal Langer
f8f7769d9c Update DSM subprotocols naming 2021-03-04 10:08:52 +01:00
Pascal Langer
4dacac29c6 SBUS/CPPM: restore normal telemetry on student link lost
Once the setup is done check the "Disable telemetry" box to make sure that there is no interference between the internal module and Multi telemetry.
2021-03-04 09:52:54 +01:00
Pascal Langer
593f3b87f1 SBUS/CPPM: fixed telemetry_link 2021-03-04 09:11:20 +01:00
Pascal Langer
bb70116df0 SBUS and CPPM output 2021-03-03 10:07:19 +01:00
Pascal Langer
d7c24d62ed Update Devo_cyrf6936.ino 2021-03-02 18:32:02 +01:00
Pascal Langer
07df1a8959 DEVO telemetry: reduce the voltage and RSSI refresh frequency 2021-03-02 17:37:28 +01:00
Pascal Langer
ca9e2870ab DEVO: temp telem fix 2021-03-02 16:30:14 +01:00
Pascal Langer
99ca6fa36c DEVO: fix temp telemetry 2021-03-02 16:26:30 +01:00
Pascal Langer
3d82560f71 Update Protocols_Details.md 2021-03-02 16:20:05 +01:00
Pascal Langer
44d362aeb4 DEVO: improve telemetry 2021-03-02 16:14:14 +01:00
Pascal Langer
3d4ed5ad11 SFHSS: Timing debug 2021-03-02 12:01:23 +01:00
Pascal Langer
ca3c2bbdc8 Update Protocols_Details.md 2021-03-02 10:42:25 +01:00
Pascal Langer
90c226c748 LOLI lua script 2021-03-02 10:39:11 +01:00
Pascal Langer
b757283f41 JOYSWAY: new protocol UNTESTED 2021-03-02 10:00:33 +01:00
Pascal Langer
b3132c7bf1 Devo: added telemetry voltage 3 2021-03-02 09:32:59 +01:00
Pascal Langer
9ba56f040a Update Futaba_cc2500.ino 2021-03-01 16:31:11 +01:00
Pascal Langer
ac71b4d981 Update Devo_cyrf6936.ino 2021-03-01 14:02:39 +01:00
Pascal Langer
6bb2c06cf6 Fix compilation 2021-03-01 13:53:39 +01:00
Pascal Langer
2ad3c727fd Few changes... 2021-03-01 13:48:23 +01:00
Pascal Langer
d36af55b84 DEVO: full telemetry 2021-03-01 13:47:44 +01:00
Pascal Langer
f19bb05c7a WFLY: Failsafe values 2021-02-24 16:29:24 +01:00
Pascal Langer
08ea8818fb E010R5: 5th ID 2021-02-24 10:26:58 +01:00
Pascal Langer
59c541d013 MT99xx missing break 2021-02-23 09:52:46 +01:00
Ben Lye
37e2b5f41c Merge pull request #532 from benlye/new-builds
5-in-1 builds for DIY and T-Lite
2021-02-21 19:16:24 +00:00
Ben Lye
614a330cf2 5-in-1 builds for DIY and T-Lite 2021-02-21 18:58:02 +00:00
Pascal Langer
9106548859 T18 default build 2021-02-21 18:56:48 +01:00
Pascal Langer
2f07e79e50 T18 build by default 2021-02-21 18:35:24 +01:00
Pascal Langer
2233f6f862 SX1276: RF power adjustment for DIY & Jumper T-Lite 2021-02-21 16:05:25 +01:00
Pascal Langer
ae842f0bdc MT99XX Dragon telem prep 2021-02-17 10:26:38 +01:00
Ben Lye
4b36656246 Merge pull request #529 from benlye/build-fix
Update MT99xx_nrf24l01.ino
2021-02-16 19:39:55 +00:00
Ben Lye
ea282489f9 Update MT99xx_nrf24l01.ino 2021-02-16 19:34:01 +00:00
Ben Lye
6f2d9430d0 Merge pull request #528 from benlye/build-fix
Disable CCNRF protocols when needed
2021-02-16 18:40:58 +00:00
Pascal Langer
bccd9dc0d9 Fix XK protocol with latest change 2021-02-16 19:38:34 +01:00
Ben Lye
af919fb940 Fix CCNRF_PROTOCOLS 2021-02-16 18:31:40 +00:00
Ben Lye
7dab0de3c5 Update main.yml 2021-02-16 18:26:14 +00:00
Pascal Langer
2c0525421a Update Protocols_Details.md 2021-02-16 19:08:57 +01:00
Pascal Langer
0844ec2efd Add more protocols which can run with the CC2500
Use CC2500 only when emulating NRF250K/XN297_250K
2021-02-16 19:06:23 +01:00
Pascal Langer
49c3af12f9 AFHDS2A: fix issue with fs-x6b 2021-02-14 20:51:15 +01:00
Pascal Langer
96d335f458 Hide scanner from the available protocols 2021-02-13 20:39:00 +01:00
Pascal Langer
eae412fe41 E010r5: 1 more ID 2021-02-13 09:26:03 +01:00
Pascal Langer
0270420531 XN297dump: increase polling 2021-02-12 19:05:39 +01:00
Pascal Langer
93bb117961 RF switch fix... 2021-02-12 16:29:36 +01:00
Pascal Langer
29d1fb00b1 More code optimization 2021-02-12 11:21:42 +01:00
Pascal Langer
5a49d99c4f Update _Config.h 2021-02-11 20:09:40 +01:00
Pascal Langer
d66bf1a5b3 NRF init changed to most likely default 2021-02-11 18:40:29 +01:00
Pascal Langer
b41dccef67 HONTAI: use the global CRC calculation routine 2021-02-11 10:54:55 +01:00
Pascal Langer
addf2c5143 MT99XX/Dragon: beginner and intermediate swapped... 2021-02-11 09:50:41 +01:00
Pascal Langer
ff829f1f7b M-Link telemetry forwarded to OpenTX 2021-02-10 12:31:37 +01:00
Pascal Langer
7ee72976c4 M-Link: added vario 2021-02-10 10:13:51 +01:00
Pascal Langer
dc18e8e5b2 MT99XX: new subproto Dragon 2021-02-10 09:59:30 +01:00
Pascal Langer
97de2aaf3d One file missing in the push... 2021-02-09 18:31:13 +01:00
Pascal Langer
3b8b2ef376 Protocol init function modified 2021-02-09 18:23:33 +01:00
Pascal Langer
d496f62719 Removed depreciated MULTI_STATUS 2021-02-08 09:36:47 +01:00
Pascal Langer
fc978f95ef Disabling AFHDS2A Hub telemetry to fit in flash... 2021-02-07 19:20:12 +01:00
Pascal Langer
596e8c9b55 Update MLINK_cyrf6936.ino 2021-02-07 18:57:59 +01:00
Pascal Langer
0cf58c2990 MLink: added voltage, current, rpm, temp sensors and lqi 2021-02-07 18:51:36 +01:00
Pascal Langer
6ba1c8b118 Update Protocols_Details.md 2021-02-06 10:36:14 +01:00
Pascal Langer
b949ac0fed Update Protocols_Details.md 2021-02-06 10:35:15 +01:00
Pascal Langer
510f892d2f MLink: use only odd channels like original 2021-02-06 10:23:10 +01:00
Pascal Langer
17750e774a M-Link Failsafe 2021-02-06 09:58:36 +01:00
Pascal Langer
be1591c489 Update Protocols_Details.md 2021-02-05 18:44:48 +01:00
Pascal Langer
3b22705166 Exclude MLink from T18 build to save Flash space 2021-02-05 17:21:07 +01:00
Ben Lye
c05c0a5693 Merge pull request #518 from pascallanger/benlye-patch-1
Update main.yml
2021-02-05 16:15:36 +00:00
Ben Lye
d6fc6a3517 Update main.yml
Disable default configuration builds for T18 and 4in1.
2021-02-05 16:09:30 +00:00
Pascal Langer
7bfaee8b4f Update MLINK_cyrf6936.ino 2021-02-05 16:20:42 +01:00
Pascal Langer
89c00e8f17 Initial M-LINK release 2021-02-05 12:28:35 +01:00
pascallanger
447a58966f Update Compiling_STM32.md 2021-02-04 14:19:29 +01:00
pascallanger
74162aa972 Update Compiling_STM32.md 2021-02-04 14:15:57 +01:00
Pascal Langer
78a1e61f7a Update Telemetry.ino 2021-02-04 14:07:15 +01:00
Pascal Langer
a917227ddc Bayang: generic frsky hub function 2021-02-04 12:05:57 +01:00
Pascal Langer
c866d07743 Bayang: add PID to telemetry 2021-02-03 19:44:59 +01:00
Pascal Langer
43d969f962 FrSky RX: sub protocol to erase clone IDs 2021-02-03 16:57:14 +01:00
Pascal Langer
3973b42f81 MT99XX fix bind hopping 2021-02-02 17:55:40 +01:00
Pascal Langer
6046ad81db Update Protocols_Details.md 2021-02-02 14:42:22 +01:00
Pascal Langer
63a9874aea Futaba S-FHSS: another fs throw test 2021-02-02 12:06:54 +01:00
Pascal Langer
89420fe2d4 Futaba S-FHSS: failsafe throw test 2021-02-02 10:06:24 +01:00
Pascal Langer
9769354989 MT99XX: no autobind, 1 ID 2021-02-01 21:31:34 +01:00
Pascal Langer
580b996215 MT99XX: code optimization 2021-02-01 19:26:34 +01:00
Pascal Langer
8f5fb5083f MT99X sub A180: timing 2021-02-01 19:06:47 +01:00
Pascal Langer
821076ce95 MT99XX: code cleanup 2021-02-01 18:25:11 +01:00
Pascal Langer
0bfe1f8e63 MT99XX: new sub protocol A180 2021-02-01 15:21:39 +01:00
Pascal Langer
9c35f6f73c Futaba S-FHSS: Fist attempt to fix failsafe 2021-02-01 11:54:16 +01:00
Pascal Langer
983debe6ce WFLY2: Failsafe working for values, hold and no pulse 2021-01-29 15:41:47 +01:00
Pascal Langer
66704b5a13 AFHDS2A: common timing 2021-01-28 15:41:59 +01:00
Pascal Langer
f11da0c1de DSM: fix low power 2021-01-28 09:09:43 +01:00
Pascal Langer
7676398aab Fix OMP protocol 2021-01-25 11:33:30 +01:00
Pascal Langer
9c6c55fa00 E010r5: added 2 TX IDs 2021-01-21 15:31:37 +01:00
Pascal Langer
5b9ca3ba06 Move the CYRF emulation functions around for future 2021-01-21 12:24:46 +01:00
Pascal Langer
23141b6087 E016Hv2 and ESKY150V2 don't need the NRF code anymore 2021-01-21 11:46:54 +01:00
Pascal Langer
6d4b4bd2c0 Update MultiChannelsUpdater.lua 2021-01-21 09:32:45 +01:00
Pascal Langer
5cec22a757 AFHDS2A RX: trial to fix bind with original TX 2021-01-19 22:50:55 +01:00
pascallanger
153ba2e090 Update Transmitters.md 2021-01-19 12:26:15 +01:00
Pascal Langer
21e8bed52b E016HV2: fixed a left over from protocol reverse engineering 2021-01-19 12:15:23 +01:00
Pascal Langer
ecfc5b0313 End bind as requested by the radio on more protocols 2021-01-19 12:13:24 +01:00
Pascal Langer
2bcebbda45 LOLI: adjust timing 2021-01-18 15:51:35 +01:00
Pascal Langer
52e8d87ab1 LOLI RX configuration script 2021-01-18 11:46:19 +01:00
pascallanger
b613345da4 Update Protocols_Details.md 2021-01-17 17:16:11 +01:00
pascallanger
f2665ca786 Update Protocols_Details.md 2021-01-17 16:53:42 +01:00
Pascal Langer
e3189d3aed E010r5: add GLIDE channel 2021-01-17 15:59:05 +01:00
pascallanger
c829e1c86f Protocol E129: Add E130 model, Protocol E010r5: Add GLIDE channel 2021-01-17 15:57:52 +01:00
pascallanger
8499a508f5 Protocol E129: Add E130 model, Protocol E010r5: Add GLIDE channel 2021-01-17 15:57:42 +01:00
Pascal Langer
50dec0e55d AFHDS2A RX: fixed 2021-01-16 18:33:10 +01:00
Pascal Langer
6f419adb7f Fix CRC in various places 2021-01-16 16:50:45 +01:00
pascallanger
502e8beafb Update Protocols_Details.md 2021-01-16 15:48:40 +01:00
Pascal Langer
5aae065dc0 New protocol: E129 2021-01-16 15:45:19 +01:00
pascallanger
152dbed3fa Add Kyosho FHS details 2021-01-14 08:51:22 +01:00
Pascal Langer
b516bb8d20 Fix AFHDS2A RX 2021-01-12 14:02:13 +01:00
Pascal Langer
30e3e84066 LOLI: RX config 2021-01-11 16:27:59 +01:00
Pascal Langer
8338104266 Update XN297Dump_nrf24l01.ino 2021-01-11 12:37:58 +01:00
Pascal Langer
00c6aa52b9 Fix NCC1701... 2021-01-11 12:33:29 +01:00
Pascal Langer
e5689d2f1b Fix FQ777 2021-01-11 12:30:12 +01:00
Pascal Langer
b51dedcea1 M-Link: still work in progress 2021-01-11 12:13:03 +01:00
Pascal Langer
49f004e53f E010r5: added flip, led and calib channels 2021-01-11 12:12:26 +01:00
Pascal Langer
062fc05eac Fix FrSky RX protocol not ending bind when requested 2021-01-11 09:42:16 +01:00
Pascal Langer
6d080d5d5f New LOLI protocol 2021-01-09 18:39:31 +01:00
Pascal Langer
0955340a93 New protocol: E010r5 2021-01-08 21:16:07 +01:00
Ben Lye
9b2318cc7e Fix EEPROM address variable types (#494) 2020-12-27 09:57:41 +01:00
Pascal Langer
2098cdc5e0 Merge branch 'master' of https://github.com/pascallanger/DIY-Multiprotocol-TX-Module 2020-12-23 10:54:43 +01:00
Pascal Langer
d19b5187c5 AFHDS2A RX: stop bind when requested 2020-12-23 10:54:39 +01:00
pascallanger
2a78b1d6b7 Update README.md 2020-12-22 12:01:05 +01:00
pascallanger
84ae6366eb Update README.md 2020-12-21 16:12:04 +01:00
pascallanger
e5b235ac83 Update README.md 2020-12-21 16:08:03 +01:00
Ben Lye
0195384592 Merge pull request #486 from benlye/actions-3
Various fixes for CI workflow
2020-12-21 14:56:29 +00:00
Ben Lye
0937f832fc Rename the build artifact archive 2020-12-21 14:50:31 +00:00
Ben Lye
c77b4af2a0 Various fixes for CI workflow 2020-12-21 14:33:55 +00:00
pascallanger
b943bae8dd Update README.md 2020-12-21 11:39:35 +01:00
pascallanger
4955978eb6 Update README.md 2020-12-21 11:36:39 +01:00
Ben Lye
df409fddf5 Merge pull request #485 from benlye/store-artifacts
Upload build artifacts to workflow job
2020-12-20 20:15:21 +00:00
Ben Lye
0330c596e4 Upload build artifacts to workflow job 2020-12-20 19:56:28 +00:00
Ben Lye
8c6c58f12f Update main.yml
Only run CI workflow on push or PR if firmware source code has changed.
2020-12-20 19:08:36 +00:00
Ben Lye
4bc08d22b8 Merge pull request #484 from benlye/github-actions
Configure GitHub Actions
2020-12-20 17:44:28 +00:00
Ben Lye
96fb3b20b7 Configure GitHub Actions for testing and releases 2020-12-20 17:11:18 +00:00
Ben Lye
47f713c6c8 Disable Travis 2020-12-20 11:38:34 +00:00
Pascal Langer
443c7a6b99 WFLY2: WBUS <-> PPM 2020-12-20 12:05:43 +01:00
Pascal Langer
e79ca9b7d7 E016H: Calibration on channel 8 2020-12-19 12:16:51 +01:00
Pascal Langer
b94f774f80 WFLY2: Failsafe doc update 2020-12-18 17:34:09 +01:00
Pascal Langer
5614e8bef6 E016H: Multi IDs 2020-12-18 15:30:50 +01:00
Pascal Langer
4ce3a5d298 Renamed protocol E016H to E016HV2 2020-12-18 00:09:13 +01:00
Pascal Langer
f6de3de78c Update Protocols_Details.md 2020-12-17 21:28:42 +01:00
Pascal Langer
8099018132 RLINK: subprotocol DumboRC 2020-12-17 21:24:56 +01:00
Pascal Langer
360dde2e1b E016H: compilation fix 2020-12-17 21:09:13 +01:00
Pascal Langer
cc7b7638d3 Update Protocols_Details.md 2020-12-17 18:23:38 +01:00
Pascal Langer
321e4aee34 E016H v2: new protocol WIP only 1 ID 2020-12-17 18:05:04 +01:00
Pascal Langer
f18847df57 Update Convert.ino 2020-12-17 09:02:11 +01:00
Pascal Langer
a2559a65d3 WFLY2: add switch from PPM <-> WBUS 2020-12-16 18:40:46 +01:00
Pascal Langer
5ac41fdd15 WFLY2: add failsafe (hold/no pulse not available yet) 2020-12-16 16:14:45 +01:00
Pascal Langer
6d38dd2d7a WFLY2: auto stop bind when the RX replies 2020-12-15 23:58:56 +01:00
Ben Lye
667058269c Add latest boards 2020-12-15 09:50:28 +00:00
Ben Lye
ad6f934892 Pin arduino-cli version to 0.13.0 2020-12-15 09:32:34 +00:00
Pascal Langer
714220c349 Update Protocols_Details.md 2020-12-15 10:20:05 +01:00
Pascal Langer
4887fca873 WFLY2: fix bind after code cleanup... 2020-12-15 09:51:11 +01:00
Pascal Langer
cfe80edcb6 WFLY2: update channels throw, bind frequencies 2020-12-14 18:56:12 +01:00
Pascal Langer
484588ff6b WFLY2: documentation 2020-12-14 11:07:21 +01:00
Pascal Langer
1bb059c2a2 WFLY: renamed WFLYRF to WFLY2 2020-12-13 23:15:43 +01:00
Pascal Langer
ef5d9cb6b3 HoTT: update doc for 16 channels 2020-12-13 23:00:47 +01:00
Pascal Langer
37a06c050d HoTT: added support for 16 channels (previously 12) 2020-12-13 22:56:47 +01:00
Pascal Langer
5f0ed395ba WFLYRF: use Radio ID 2020-12-11 13:55:50 +01:00
Pascal Langer
ae27c8b671 WFLYRF: Fixed partial ID for telemetry 2020-12-11 11:23:06 +01:00
Pascal Langer
088bfb9c2f WFLYRF: added ext voltage to A2 2020-12-11 10:57:14 +01:00
Pascal Langer
b01462e36b WFLYRF: fixed normal mode, added telemetry, bind is not working yet 2020-12-11 10:40:00 +01:00
Pascal Langer
abd36dc6a4 WFLY: Track changes in A7105 config (radio has A7106) 2020-12-10 18:57:06 +01:00
Pascal Langer
ebb8a33c1a Fix potential bug with wait loops 2020-12-10 16:52:34 +01:00
Pascal Langer
2b0f663482 WFLY RF: WIP protocol 2020-12-10 16:51:55 +01:00
pascallanger
956e632392 Update Protocols_Details.md 2020-12-10 13:48:04 +01:00
pascallanger
90b6bb8f7d Update Protocols_Details.md 2020-12-08 18:52:13 +01:00
pascallanger
6153e84abf Update README.md 2020-12-08 16:51:52 +01:00
pascallanger
16357f29e9 Add files via upload 2020-12-08 16:48:04 +01:00
Pascal Langer
0b8a5a7539 MLINK protocol: WIP, works only for a few sec... 2020-12-05 19:13:11 +01:00
Pascal Langer
6874e3a6a7 Template for WFLY RF 2020-12-05 19:12:11 +01:00
Pascal Langer
96263ed8a6 Prep for M-LINK 2020-12-04 09:00:17 +01:00
Ben Lye
7bb1cb9ae3 Add STM32 EEPROM initialization at startup (#475) 2020-11-30 18:11:35 +01:00
Pascal Langer
20e32c4cb0 Fix XK450 twitching? 2020-11-30 13:36:29 +01:00
Ben Lye
b4421306c0 Fix compiler errors when telemetry is disabled (#474) 2020-11-30 08:38:21 +01:00
Pascal Langer
e53f723fdb Update DSM FwdPrg.lua 2020-11-25 10:37:47 +01:00
Ben Lye
832a331437 Update Frequency_Tuning.md 2020-11-22 10:09:07 +00:00
Ben Lye
12e66bd84f Add tests for STM32F103C8 board 2020-11-09 11:09:12 +00:00
Pascal Langer
d290cc519f Bayang telemetry OpenTX Ratio and Offset 2020-11-06 10:04:01 +01:00
Ben Lye
f4b19fe33e Add module sub-type to signature
Differentiates between the STM32F1 boards.
2020-11-03 08:08:10 +00:00
pascallanger
767d2c079a Update Protocols_Details.md 2020-10-31 16:24:02 +01:00
pascallanger
7750310be5 Update Protocols_Details.md 2020-10-31 16:06:18 +01:00
Pascal Langer
6de4e1e1dd Protocols order 2020-10-31 15:59:04 +01:00
Ben Lye
627d47f139 C8 MCU flash size check (#461) 2020-10-30 12:21:39 +01:00
pascallanger
36675cf729 Change Travis links 2020-10-30 12:18:15 +01:00
Pascal Langer
33d8234eb3 Update JJRC345_nrf24l01.ino 2020-10-30 12:01:40 +01:00
Pascal Langer
347eb11328 SFHSS name change to Futaba 2020-10-30 12:01:29 +01:00
Ben Lye
5ed61f30e1 STM32 release file name standardization (#451)
Tweak the names of the STM32 serial and CC2500-only release files.
2020-10-11 14:09:42 +01:00
Ben Lye
a633f46f4f Travis release build changes (#450)
* Move the release build steps into separate shell scripts
* Remove builds that we don't need any more
  * Latest builds of er9x and erSkyTx both support MULTI_TELEMETRY so separate OpenTX / erSkyTx builds are no longer needed
  * Radio can switch telemetry inversion on or off automatically so STM32 inv / noinv builds are no longer needed
2020-10-11 12:52:05 +01:00
Pascal Langer
baf9a0f978 Update DSM FwdPrg.lua 2020-10-03 11:06:22 +02:00
Pascal Langer
c98b8fc8bf Flysky: Fix AFHDS and AFHDS2A 2020-10-03 10:52:11 +02:00
Pascal Langer
2fae0a35b8 Merge branch 'master' of https://github.com/pascallanger/DIY-Multiprotocol-TX-Module 2020-10-01 00:18:28 +02:00
Pascal Langer
b04f38ed3d Indicate ratio values to be used for A1 and A2 voltage sensors
OMP, RadioLink, Hubsan, Bayang, ...
2020-10-01 00:18:13 +02:00
pascallanger
60d5dd4101 Update Protocols_Details.md 2020-10-01 00:06:40 +02:00
Pascal Langer
75b7dd1dd7 Kyosho/Hype: channel order & doc 2020-10-01 00:05:20 +02:00
Pascal Langer
aa2717d6ab Kyosho/Hype: bind fix 2020-09-30 20:30:07 +02:00
Pascal Langer
4058f04b39 Kyosho/Hype: another attempt to fix bind... 2020-09-30 11:06:30 +02:00
Pascal Langer
25ebd55c85 Update Protocols_Details.md 2020-09-29 19:14:41 +02:00
Pascal Langer
d00b58c8ed Kyosho/Hype: fix bind 2020-09-29 17:06:01 +02:00
Pascal Langer
e7eb07a5a4 Kyosho: new sub_protocol Hype
Initial release
2020-09-29 11:24:55 +02:00
Ben Lye
a4cac50261 Add builds for modules with only CC2500 2020-09-24 14:09:08 +01:00
Pascal Langer
4f8da64822 OMP: doc update 2020-09-23 23:52:22 +02:00
Pascal Langer
4f89721cd0 RadioLink: any id
Need to rebind RXs...
2020-09-23 23:42:03 +02:00
Pascal Langer
43c2843490 Update AFHDS2A_a7105.ino 2020-09-23 23:08:26 +02:00
Pascal Langer
c152265284 OMP: doc 2020-09-23 23:05:05 +02:00
Pascal Langer
b591b92b4e Update OMP documentation 2020-09-23 09:41:26 +02:00
Pascal Langer
090388aa1b OMP: improve telemetry 2020-09-22 15:15:14 +02:00
Pascal Langer
c6ab696949 AFHDS2A: fix X6B telemetry issue? 2020-09-21 10:57:19 +02:00
Pascal Langer
df45a3ff83 OMP: prevent telemetry voltage from rolling over 2020-09-21 10:50:01 +02:00
pascallanger
fedd04b724 Update Troubleshooting.md 2020-09-19 21:23:51 +02:00
pascallanger
d8630da09d Update Troubleshooting.md 2020-09-19 20:35:44 +02:00
pascallanger
6192f7287e Update README.md 2020-09-18 17:15:18 +02:00
Pascal Langer
5b8a08ab22 OMP: added telemetry 2020-09-18 16:13:45 +02:00
Ben Lye
313b03fb84 Disable PPM/serial in builds as needed 2020-09-17 10:13:00 +01:00
Pascal Langer
5639def6fb Update DSM FwdPrg.lua 2020-09-15 12:05:26 +02:00
Pascal Langer
15a254879c DSM_RX: bind with other radio modules off 2020-09-15 12:03:16 +02:00
pascallanger
5baa9bd256 Update README.md 2020-09-13 11:34:23 +02:00
Pascal Langer
d5346c0eaf Add DISABLE_FLASH_SIZE_CHECK 2020-09-09 16:47:32 +02:00
Pascal Langer
a2213fd6dc DSM Forward Programming: work in progress 2020-09-09 10:45:14 +02:00
Pascal Langer
9b07f12f90 AFHDS2A: add sub proto 2020-09-08 08:49:38 +02:00
Pascal Langer
c9b49483e0 NanoRF 2020-09-07 22:58:37 +02:00
Pascal Langer
e2972a5823 AFHDS2A: enable 16 channels on SBUS 2020-09-07 20:31:47 +02:00
Pascal Langer
d5b3ed832d Update Multiprotocol.ino 2020-09-04 10:59:31 +02:00
Pascal Langer
9fcc030c15 STM32: test flash size 2020-09-04 10:39:30 +02:00
pascallanger
fc81b7ee5a Update Protocols_Details.md 2020-09-03 17:28:54 +02:00
Pascal Langer
f168abc2bb Fixed frame size 2020-08-31 22:21:21 +02:00
pascallanger
fe6778635e Add Realacc R11 protocol 2020-08-30 14:57:56 +02:00
Pascal Langer
65a6c19d02 OMP doc 2020-08-30 14:35:44 +02:00
pascallanger
a32b5561a1 Update Protocols_Details.md 2020-08-30 14:30:28 +02:00
pascallanger
4b4393952e Update README.md 2020-08-24 14:41:10 +02:00
Pascal Langer
ea205b1e69 Bayanf: fix telemetry batt 2020-08-20 19:00:06 +02:00
pascallanger
748140cdee Update Protocols_Details.md 2020-08-18 12:02:08 +02:00
Pascal Langer
e8037c857f OMP fixes 2020-08-17 08:26:42 +02:00
Pascal Langer
15e37cefee OMP: fix? 2020-08-16 18:48:40 +02:00
Pascal Langer
b1e4daf1c2 OMP: new protocol intial release
Untested!!!
2020-08-15 16:17:18 +02:00
Pascal Langer
4e0fccfc63 Update Protocols_Details.md 2020-08-14 19:40:25 +02:00
Pascal Langer
48b90029c4 V761: Work with any ID. Tested on Eachine RX. 2020-08-14 19:39:24 +02:00
Pascal Langer
8b189af2f9 R9: small change 2020-08-13 21:21:34 +02:00
Pascal Langer
030cdd35a2 Update REALACC_nrf24l01.ino 2020-08-11 00:02:19 +02:00
Pascal Langer
3789998ba9 Update ZSX_nrf24l01.ino 2020-08-10 23:54:51 +02:00
Pascal Langer
ea24ab6032 New protocol Realacc 2020-08-10 23:54:33 +02:00
Pascal Langer
1408431649 XN297Dump: increase the number of RF channels to look for 2020-08-10 22:52:50 +02:00
Pascal Langer
6810372064 RadioLink: enable Range test mode 2020-08-10 20:30:19 +02:00
Pascal Langer
708e2ac5f6 V761 bug fix: the model was not reconnecting unless you did a bind first 2020-08-07 15:18:15 +02:00
Pascal Langer
2178f6761d RadioLink: update A2=Batt telemetry value 2020-08-07 15:11:59 +02:00
Pascal Langer
aa5fd82004 Update FrSky_Rx_cc2500.ino 2020-08-05 09:50:40 +02:00
Pascal Langer
660282db2e RX protocols: abort RX bind as requested 2020-08-04 10:42:35 +02:00
Ben Lye
fdd357619b Fix folder structure inside LUA script zip file 2020-08-03 22:39:10 +01:00
Pascal Langer
5f12f99761 Update Validate.h 2020-08-01 19:35:39 +02:00
Pascal Langer
3d98abb6d4 Rename the Flyzone protocol by Height which is the original manufacturer 2020-08-01 19:19:11 +02:00
Pascal Langer
e35879a5d0 RadioLink: fix 2020-08-01 10:19:30 +02:00
Pascal Langer
37138f03ae Few fixes 2020-07-31 15:58:07 +02:00
Pascal Langer
51d39bbd8c RadioLink: add RXs to the supported list 2020-07-31 10:56:34 +02:00
Pascal Langer
0932a1c93f Update Protocols_Details.md 2020-07-31 10:52:37 +02:00
Pascal Langer
19164521e4 Flyzone protocol: 8 channels support 2020-07-31 10:42:10 +02:00
Pascal Langer
df28cfe3cc Radiolink: final version with 64 IDs 2020-07-31 10:41:07 +02:00
Pascal Langer
354878d542 RadioLink: preparation for final 2020-07-28 15:53:58 +02:00
Pascal Langer
695264d59a RadioLink: update 2020-07-28 00:55:47 +02:00
pascallanger
de190f3349 Update Protocols_Details.md 2020-07-25 14:43:52 +02:00
Pascal Langer
b049385094 Update Protocols_Details.md 2020-07-23 21:40:26 +02:00
Pascal Langer
75dc616130 Update RadioLink_cc2500.ino 2020-07-23 15:08:23 +02:00
Pascal Langer
b542f5e7cd RLINK: remove fixed ID 2020-07-23 10:10:08 +02:00
Pascal Langer
f3bee3cded RLINK: Fix voltage values 2020-07-23 10:03:04 +02:00
Pascal Langer
a9b7ab9a06 Update Protocols_Details.md 2020-07-22 20:13:54 +02:00
Pascal Langer
ed019e954e RadioLink: few fixes 2020-07-22 20:05:56 +02:00
Pascal Langer
65186b4356 Add Kyosho to the Lua channel namer exception list 2020-07-22 18:18:35 +02:00
Pascal Langer
e1d4f9a270 RadioLink Surface protocol: initial commit 2020-07-22 15:37:47 +02:00
Pascal Langer
69c95ca153 Fix compilation issues when Telem is disabled 2020-07-22 15:27:06 +02:00
Pascal Langer
e6976fb08d Merge branch 'master' of https://github.com/pascallanger/DIY-Multiprotocol-TX-Module 2020-07-21 01:40:19 +02:00
Pascal Langer
f502ba3659 FrSkyX Cloned: 8 channels option 2020-07-21 01:40:14 +02:00
pascallanger
e6ccc7e7cc Update Protocols_Details.md 2020-07-17 14:21:57 +02:00
Pascal Langer
da9d8851c2 Fix FrSkyX and FrSkyR9 bind options 2020-07-16 10:28:07 +02:00
pascallanger
ad48291d2a Update Protocols_Details.md 2020-07-16 00:02:29 +02:00
Pascal Langer
d6da230369 Flysky AFHDS2A: 16 channels + LQI
Use the 2 new sub protocols to extend the protocol to 16 channels on IBUS
2020-07-15 23:58:41 +02:00
pascallanger
f8ac406a94 Update Frequency_Tuning.md 2020-07-15 20:31:55 +02:00
Pascal Langer
e691ecd167 Update doc 2020-07-15 19:09:56 +02:00
Pascal Langer
930c26a111 Kyosho: new protocol 2020-07-10 15:25:32 +02:00
Pascal Langer
64419a6cf4 V2x2: fix? 2020-07-09 22:49:48 +02:00
Pascal Langer
5c59cddc7a FrSkyR9: FCC initial support 2020-07-06 09:52:43 +02:00
Ben Lye
4c7a51be46 Create folders in LUA script zip file 2020-07-05 16:54:55 +01:00
Ben Lye
7dad0fb89f Update install_drivers.bat
Change to libusbk driver for DFU device
2020-07-05 16:32:56 +01:00
Pascal Langer
adebb3fc5c FrSkyX: clean up 2020-07-05 17:19:29 +02:00
Pascal Langer
5ab00b9d18 FrSkyX: TXQly is the percentage of telemetry received packets (100...0%) 2020-07-05 00:28:43 +02:00
Pascal Langer
fbd5d7cf48 FrSky R9: telemetry TX to RX attempt 2020-07-04 22:43:19 +02:00
Pascal Langer
84132678cc FrSkyR9: TQLY = percentage of telemetry frames per second 2020-07-04 18:40:29 +02:00
Pascal Langer
78421748ba FrSky R9: fix sensors telem? 2020-07-04 17:50:05 +02:00
Pascal Langer
7112f58dae FrSkyX: fix telem 2020-07-04 15:15:55 +02:00
Pascal Langer
e56f737b34 FrSkyX: fix telemetry not stopping when RX is off 2020-07-04 13:33:56 +02:00
Pascal Langer
49d993f613 FrSkyR9: fix independant compilation issue 2020-07-04 11:48:26 +02:00
Pascal Langer
63dd8a9215 Update iface_sx1276.h 2020-07-03 19:51:22 +02:00
Pascal Langer
d5f819dd59 FrSkyR9: initial telemetry support 2020-07-03 19:51:11 +02:00
pascallanger
a68787f16e Update Protocols_Details.md 2020-07-03 18:03:36 +02:00
Pascal Langer
858ef5801c FrSkyX: fix AVR telemetry and may be improve telemetry overall 2020-07-03 17:42:12 +02:00
Pascal Langer
9e0bd29cee FrSkyD: clone mode - additional ID byte 2020-07-03 16:15:47 +02:00
Pascal Langer
15395de579 FrSky R9: adding CH1-8/CH9-16 and Telem ON/OFF (not that telem is supported yet) 2020-07-01 15:39:40 +02:00
Pascal Langer
db4aad04a7 FrSkyR9: fix 868 2020-07-01 14:39:11 +02:00
Pascal Langer
466e4cf227 Update DSM protocol details 2020-06-29 23:31:17 +02:00
Ben Lye
05a3780c38 Add latest STM32 board 2020-06-29 19:55:29 +01:00
pascallanger
85ea91cdbb Update README.md 2020-06-28 19:54:14 +02:00
pascallanger
985d7a6fd9 Update README.md 2020-06-28 19:37:58 +02:00
pascallanger
2a19b8dd45 Update README.md 2020-06-28 19:35:12 +02:00
Pascal Langer
b2b3078861 Update README.md 2020-06-28 19:17:02 +02:00
Pascal Langer
2ac92f5725 Create README.md 2020-06-28 19:15:39 +02:00
Pascal Langer
e2f5afd71e V761 doc updates 2020-06-28 19:07:34 +02:00
Ben Lye
e094ee036d Zip the LUA scripts for release 2020-06-28 16:06:06 +01:00
Ben Lye
2ad7f3e9f2 Fix LUA script copy 2020-06-28 15:13:33 +01:00
Pascal Langer
8e1f2258f8 OpenTX Lua scripts related to Multi 2020-06-27 17:59:06 +02:00
Pascal Langer
5c01bbf284 V761: additional channles 2020-06-27 17:58:29 +02:00
Pascal Langer
647425fc1a Revert "V761 additonal channels"
This reverts commit 7286049d07.
2020-06-27 17:56:19 +02:00
Pascal Langer
7286049d07 V761 additonal channels 2020-06-27 17:55:36 +02:00
Pascal Langer
ce67a065cd V761 - Eachine sub protocol 2020-06-26 17:54:56 +02:00
Ben Lye
8948cb6287 Switch to Arduino CLI instead of IDE for Travis CI builds 2020-06-26 09:56:07 +01:00
pascallanger
4daa5fa2bb Update Advanced_XN297Ldump.md 2020-06-22 10:10:57 +02:00
Pascal Langer
c49a7dae0a Few changes 2020-06-20 22:04:26 +02:00
Pascal Langer
890a042a43 V2X2 new sub proto MR101 and protocol rewrite
MR101 sub proto for Dromida XL
2020-06-20 21:40:03 +02:00
Pascal Langer
c95e576ef3 DSM RX: end bind and increased retry 2020-06-18 10:53:03 +02:00
Pascal Langer
2aa96dd129 SX1276: indent with tabs 2020-06-15 23:34:56 +02:00
AlessandroAU
908634474b Adds SX1276_DetectChip() function (#373)
* Adds SX1276_DetectChip() function

works by testing for 0x12 match in version reg 0x42

* fix build err
2020-06-15 23:03:03 +02:00
AlessandroAU
79b525ee71 Implement datasheet errata recommendation (#372) 2020-06-15 23:02:30 +02:00
Pascal Langer
872b8259ab Q90C VTX channel 2020-06-15 19:39:43 +02:00
Pascal Langer
a14c82708f Update Q90C_nrf24l01.ino 2020-06-15 15:30:31 +02:00
Pascal Langer
7e53778680 Update Q90C_nrf24l01.ino 2020-06-15 15:23:02 +02:00
Pascal Langer
210fbe3b9e Update Q90C_nrf24l01.ino 2020-06-15 14:45:49 +02:00
Pascal Langer
0a5fd72bdc DSM: 3 ch timing on CH13 2020-06-15 14:45:42 +02:00
Pascal Langer
6e1701ecc5 Q90C: Flight Modes 2020-06-14 23:22:27 +02:00
Pascal Langer
a5f627a2d6 Q90C test 2020-06-14 22:28:36 +02:00
Pascal Langer
b4a1f175c6 Update Q90C_nrf24l01.ino 2020-06-14 22:22:13 +02:00
Pascal Langer
e0690fa661 Update Q90C_nrf24l01.ino 2020-06-14 19:10:59 +02:00
Pascal Langer
bd962eff35 DSM: SAFE setting how to 2020-06-14 18:34:38 +02:00
Pascal Langer
b515355249 DSM RX: remove reverse on aileron and rudder 2020-06-13 21:54:18 +02:00
Pascal Langer
d1feef97be DSM: adjust end points, solve SAFE? 2020-06-13 16:20:51 +02:00
Pascal Langer
f52f96d44e DSM: selectable refresh rate 22/11ms when supported 2020-06-12 00:25:09 +02:00
Pascal Langer
944ec62f49 Update DSM_cyrf6936.ino 2020-06-10 09:03:41 +02:00
Pascal Langer
30905014d2 DSM: fix 11ms issue on some RXs? 2020-06-09 23:49:51 +02:00
Pascal Langer
32dbdfc6e3 Fix compilation when telemetry is disabled 2020-06-09 20:08:00 +02:00
Pascal Langer
b2e312b41e FrSkyX: force tuning fix for FrSkyX2 2020-06-07 18:06:19 +02:00
Ben Lye
52f4096197 Force 'noinv' for the T18 5in1 release files
And put it in the file name, just for consistency
2020-06-06 19:16:19 +01:00
Ben Lye
c547ea0c0f Disable some protocols for Atmega CC2500 builds
Trying to get the build to fit again.
2020-06-06 18:47:32 +01:00
Ben Lye
c73ee61128 Add T18 5in1 tests and release builds 2020-06-06 18:47:32 +01:00
Pascal Langer
90b287f1f4 Multi 5-in-1 initial support 2020-06-06 01:57:52 +02:00
Pascal Langer
0316c9eea9 HoTT: telem code cleanup 2020-06-05 22:44:32 +02:00
Pascal Langer
374b46966c FrSkyX: small change 2020-06-05 22:22:13 +02:00
Pascal Langer
3705415927 HoTT: fix telemetry 2020-06-05 22:20:19 +02:00
Pascal Langer
bff68f482e Update Protocols_Details.md 2020-06-03 14:08:09 +02:00
Pascal Langer
32ed758072 Update DSM_Rx_cyrf6936.ino 2020-06-03 12:55:45 +02:00
Pascal Langer
5ce99ee419 Test protocol 2020-06-03 11:43:27 +02:00
Pascal Langer
ceea384a36 Pelikan Lite: force_id update 2020-06-03 10:29:34 +02:00
Pascal Langer
fd3b026e12 Update Pelikan_a7105.ino 2020-06-02 19:10:11 +02:00
Pascal Langer
7e451c13a8 Pelikan: add sub protocol for Lite version 2020-06-02 19:04:05 +02:00
Pascal Langer
3dcf74c2e4 Bayang: renamed CX100 to QX100 2020-06-02 17:17:49 +02:00
Pascal Langer
50f1eca4be Bayang: new subprotocol CX100 2020-06-02 14:59:32 +02:00
Pascal Langer
0d97af5ae2 XN297dump: Auto mode small fix 2020-06-02 14:34:50 +02:00
Pascal Langer
aeb8d67219 HoTT: add subprotocols 2020-06-01 22:55:32 +02:00
Pascal Langer
1f65025036 HoTT: add LBT and telemetry improvment 2020-05-31 23:54:13 +02:00
Pascal Langer
8df3687684 Q90C: channels reverse 2020-05-26 22:26:30 +02:00
MRC3742
adf59a9d0d Misc updates for errors, omissions amd corrections (#359) 2020-05-26 19:52:09 +02:00
Pascal Langer
b9f00bdbc5 Q90C: checksum fix 2020-05-26 12:41:33 +02:00
Pascal Langer
a10e169573 New protocol Q90C 2020-05-24 17:39:14 +02:00
Pascal Langer
317b9a8156 Fix compilation when ESKY150V2 was built without HoTT 2020-05-23 23:34:05 +02:00
Pascal Langer
1c632d462f Update Protocols_Details.md 2020-05-23 22:53:53 +02:00
Pascal Langer
c46b49ccf1 HoTT: cleanup 2020-05-23 22:41:07 +02:00
Pascal Langer
e70708b133 FrSkyX: push more parts to common 2020-05-23 22:39:26 +02:00
Konstantin Tretyakov
62486c2220 JJRC345: Reduce stick sensitivity (#355)
A largely symbolic contribution to record participation in protocol development.
See: https://github.com/DeviationTX/deviation/pull/853
2020-05-23 00:09:46 +02:00
Pascal Langer
cffe66747a JJRC345: last commit 2020-05-22 21:03:01 +02:00
Pascal Langer
b31bbfa04f JJRC345: Change checksum calculation 2020-05-21 23:40:23 +02:00
Pascal Langer
48e4cad3ad JJRC345: add RTH on CH7 2020-05-21 17:49:04 +02:00
Pascal Langer
53f58ce2e1 JJRC345: update 2020-05-21 17:24:11 +02:00
Pascal Langer
eb8b5eac01 JJRC345: update channels range 2020-05-21 11:56:08 +02:00
Pascal Langer
02008a8b2e New protocol JJRC345: WIP
Work in progress
2020-05-21 11:47:51 +02:00
Pascal Langer
5b82599eb9 Update Protocols_Details.md 2020-05-20 12:23:37 +02:00
Pascal Langer
a5e4b2c6fa DSM RX: Fix compilation 2020-05-18 01:30:52 +02:00
Pascal Langer
987753ff73 DSM and DSM RX: fix bind 2020-05-18 01:13:08 +02:00
Pascal Langer
ee080839b1 Update DSM_Rx_cyrf6936.ino 2020-05-17 17:26:43 +02:00
Pascal Langer
4290c75478 HoTT: support for auto sensors discovery and sensors text config 2020-05-17 15:47:56 +02:00
Pascal Langer
cc6be6027d New DSM RX protocol 2020-05-17 15:45:23 +02:00
Pascal Langer
4cfde0a80a Update Protocols_Details.md 2020-05-10 13:41:14 +02:00
Pascal Langer
a77aee0e1a Update Protocols_Details.md 2020-05-09 16:11:36 +02:00
Pascal Langer
6f36473975 Devo basic telemetry 2020-05-09 16:11:10 +02:00
pascallanger
f5720d38bb Update Flash_from_Tx.md 2020-05-09 09:10:09 +02:00
pascallanger
23478d3d21 Update Protocols_Details.md 2020-05-08 22:50:52 +02:00
Pascal Langer
ba72b6dedd eSky150v2 last minute typo... 2020-05-08 20:01:33 +02:00
Pascal Langer
103f595891 New protocol eSky 150 v2
Protocol: 69
No sub protocol
No extended limit
RX outputs is be set automatically to the eSky default TAER
16 channels
2020-05-08 19:55:16 +02:00
Pascal Langer
957d623b4b FrSky D16 LBT v1.x & 2.1: adjust thresholds to match ETSI requirements 2020-05-02 18:20:47 +02:00
Pascal Langer
2be757e609 Skyartec: small changes 2020-04-22 15:02:06 +02:00
Pascal Langer
c4be660a05 Skyartec: activate cc2500 rf tune 2020-04-21 18:27:15 +02:00
Pascal Langer
c1c5f9fe3a Hide Proto Scanner 2020-04-21 12:15:53 +02:00
Pascal Langer
53c0637a85 Fix a bug introduced with Alpha protocols ordering 2020-04-21 11:43:48 +02:00
Pascal Langer
4ae30dc3b0 New protocol: Skyartec 2020-04-18 19:04:38 +02:00
Pascal Langer
fc5fbc9899 Multi_Names update for OpenTX 2020-04-16 17:03:17 +02:00
Pascal Langer
2397bf365b Update Multi_Names.ino 2020-04-16 13:52:10 +02:00
Pascal Langer
42cd17d5f2 Multi Names: if proto invalid give first available proto 2020-04-16 12:07:19 +02:00
Pascal Langer
a35e01bbeb Update Protocols_Details.md 2020-04-15 11:23:40 +02:00
Pascal Langer
b21e8030b3 Fix independant protocols build 2020-04-15 01:30:06 +02:00
Pascal Langer
0984a42fe5 Update Protocols_Details.md 2020-04-13 22:42:41 +02:00
Pascal Langer
ed50d60108 Update Protocols_Details.md 2020-04-13 22:41:37 +02:00
Pascal Langer
a7f72a73e5 Update Protocols_Details.md 2020-04-13 22:31:26 +02:00
Pascal Langer
1c02cb46f5 FrSky Clone mode
Check documentation for full details: https://github.com/pascallanger/DIY-Multiprotocol-TX-Module/blob/master/Protocols_Details.md#FRSKY_RX---55
2020-04-13 22:10:58 +02:00
Pascal Langer
da8fd21177 Update FrSkyL_cc2500.ino 2020-04-11 20:17:02 +02:00
Pascal Langer
7e5cd9819a New protocol FrSkyL: LR12
Model: L9R RX
2 sub protocols: LR12 and LR12_6CH
2020-04-11 20:09:32 +02:00
Pascal Langer
00aecb3ab1 Update Protocols_Details.md 2020-04-10 19:38:49 +02:00
Pascal Langer
cde77a88fd FrSkyRX: added sub_protocol, documentation and more 2020-04-10 19:32:50 +02:00
E1yot
08a555f187 Initial Version of CloneMode (#342)
* Initial Version

* Bugfix and change of the handling of the RX Num.

If RX Num is 63, write a finetune value of 127 to the EEPROM.
A real finetune value of 127 means, the frequency of module is out of range and
the module should be replaced. This way the clone mode should not get unwanted
active by a module with a frequency drift arround 63.
2020-04-10 19:01:01 +02:00
Pascal Langer
4039cbf8af Small corrections 2020-04-07 10:55:54 +02:00
Pascal Langer
3f652fa06c FrSkyX: improve SPort to RX code 2020-04-07 01:43:05 +02:00
Pascal Langer
272d2be3ae Update FrSky_Rx_cc2500.ino 2020-04-05 16:05:51 +02:00
Pascal Langer
7e461344a8 Update Protocols_Details.md 2020-04-05 10:46:26 +02:00
Pascal Langer
8af985a2cb FrSkyRX: check additional ID and use RX num 2020-04-05 10:44:09 +02:00
Pascal Langer
08eee34446 Protocol PROPEL: enhanced telemetry 2020-04-05 09:39:33 +02:00
Pascal Langer
0a5b97a177 New Protocol: PROPEL
Compatible model: PROPEL 74-Z Speeder Bike
Protcol: PROPEL (66)
Sub protocol: none
Autobind protocol
Extended limits not supported
Telemetry supported
14 channels in use due to many features
2020-04-03 19:36:05 +02:00
Bryce Johnson
cab782b38e redpine updates to make released betaflight and deviation builds (#341)
Co-authored-by: Bryce Johnson <bryce@redpinelabs.com>
2020-04-02 12:39:26 +02:00
pascallanger
d1518d763b Add files via upload 2020-03-30 21:22:12 +02:00
Pascal Langer
44a676b809 Update Multiprotocol.h 2020-03-30 18:22:13 +02:00
Pascal Langer
d66709ea87 Update Protocols_Details.md 2020-03-29 19:23:28 +02:00
Pascal Langer
358a77cf7c Update Protocols_Details.md 2020-03-29 19:15:32 +02:00
Pascal Langer
1a631908f4 Update FrSky_Rx_cc2500.ino 2020-03-29 19:09:56 +02:00
Pascal Langer
9f32a1f22b FrSkyRX protocol: chanskip test 2020-03-29 18:49:37 +02:00
Pascal Langer
dfd3386319 FrSkyX v2.1: initial support
Rewrite of the FrSkyX code to support both v1 and v2.1.0 with FCC and LBT.
FrSky v1 accessible as usual
FrSky v2.1.0 accessible through the protocol 64=FrSkyX2 with the same subprotocols as v1
The LBT feature is now fully implemented on the TX and turned on for both v1 LBT and v2.1.0 LBT.
For v2.1.0, to access the bind functions Telem=on/off, CH1-8/9-16 and bidirectional SPort (SxR setup for example), you need to update OpenTX to the latest 2.3.8 nightly (not available yet).
2020-03-29 18:44:03 +02:00
Pascal Langer
3df836e6b8 Hitec: fix a bind issue 2020-03-21 19:00:40 +01:00
Pascal Langer
2b8ed25843 FrSkyD: Change hopping frequencies
WARNING: all receivers must be rebound !!!
2020-03-21 15:17:46 +01:00
Pascal Langer
62250d2f25 ESky: addition of sub-protocol ET4 2020-03-21 15:16:01 +01:00
Pascal Langer
a4e9082f53 SLT CC2500 fix 2020-02-20 17:37:58 +01:00
Pascal Langer
7217e8c41d SLT: fix? 2020-02-18 15:50:54 +01:00
Pascal Langer
a7ac093753 SLT: CC2500 fix 2020-02-17 16:44:02 +01:00
Pascal Langer
5503502bad SLT: fix going from NRF to CC2500 2020-02-17 13:10:57 +01:00
Pascal Langer
5124c2a96d SLT: use the CC2500 emulation layer if requested/available 2020-02-17 11:45:28 +01:00
Pascal Langer
73d7728e08 Change CC2500 emulation layer to support NRF24L01 @250K 2020-02-17 11:44:53 +01:00
Pascal Langer
8b7bd00a48 Update Multi.txt 2020-02-16 20:48:49 +01:00
Pascal Langer
68a6af0eb5 Update E119 channels and flags
Default is high rate
CH5 is calib
2020-02-16 20:18:02 +01:00
Pascal Langer
693f9f58eb V911S: new sub protocol E119
Model: Eachine E119
Protocol: V911S -> 46
Sub protocol: E119 -> 1
CH5: left button ???
CH6: right button ???
2020-02-16 20:05:29 +01:00
Tomer Abramovich
4a01e2d472 missed the last 3 bytes here, loop should continue one more time (#322) 2020-01-24 21:09:37 +01:00
pascallanger
e4fd1f4399 FrSkyR9: 16 channels 2020-01-24 14:59:26 +01:00
pascallanger
0d5fcb0849 FrskyR9 protocol 2020-01-24 12:12:07 +01:00
pascallanger
2236c256ba Merge pull request #320 from UnTraDe/master
initial working version of R9M, 8 CH and BINDING support only
2020-01-24 10:12:19 +01:00
Tomer Abramovich
945ad2e7bd now using FrSkyX_scaleForPXX to scale channel values for FrSky R9 instead of using floating point math 2020-01-23 22:29:57 +02:00
Tomer Abramovich
6f9740f03f moved register definitions to a different file and created higher level functions for using them; added preliminary support for 868 MHz mode, not fully working yet 2020-01-23 22:25:00 +02:00
pascallanger
f9fa4dff73 Update _Config.h 2020-01-22 16:11:42 +01:00
Tomer Abramovich
77bf17967d initial working version of R9M, 8 CH and BINDING support only 2020-01-21 17:42:33 +02:00
pascallanger
7281c0b5bf Comment FRSKYX2 protocol for now 2020-01-21 10:51:07 +01:00
pascallanger
e6cab65560 Fix paranthesis... 2020-01-21 10:29:11 +01:00
pascallanger
cc115323e1 Prep for FrSky X v2 2020-01-20 23:52:17 +01:00
Ben Lye
58665ea7a7 Bubble up errors in release builds 2020-01-17 21:37:16 +00:00
Ben Lye
3920644caf Reduce protocols for debug test builds.
Make the debug builds small enough to pass the buildDefault test.
2020-01-17 21:37:16 +00:00
pascallanger
25aecbf15e XK full ID to address and hop freqs generation 2020-01-16 23:43:29 +01:00
pascallanger
e18d8868d2 Protocol Pelikan: hop freq change with RX_num 2020-01-15 16:28:03 +01:00
pascallanger
c6e5d00a2b Protocol Pelikan: fix rx_tx_addr[1]... 2020-01-14 23:00:50 +01:00
pascallanger
7a5b4dea1a XK X420/X520: 2 valid IDs
IDs are selected using RX num.
2020-01-14 22:51:47 +01:00
pascallanger
5df877f32c Protocol XK X420: Changed bitrate to 1Mbps 2020-01-14 22:05:30 +01:00
pascallanger
c5c7dda2e0 Update XK X420 channel order
Change channel order
Add CH140 for video
2020-01-14 21:25:43 +01:00
pascallanger
492b9e5ed4 New protocol XK
Still work in progress
Subprotocols: X450 and X420 -> not sure if they are subprotocols or just different IDs...
CH5: M-Mode=-100%, 6G-Mode=0%, V-Mode=+100%
CH6: Take off momentary switch
CH7: Emergency stop momentary switch
CH8: 3D/6G momentary switch
CH9: Photo momentary switch
2020-01-14 12:19:12 +01:00
pascallanger
9f721c528d Bayang: rewritten the protocol to be more friendly with main scheduler 2020-01-12 19:42:51 +01:00
pascallanger
7f3c80c2a9 Fix DSM invalid protocol when binding 2020-01-12 18:18:47 +01:00
pascallanger
8f789607e4 Pelikan: add some hopping frequencies 2020-01-12 17:38:30 +01:00
pascallanger
6a9b6ed4be XN297EMU: option=0->nrf24L01, option!=0 -> CC2500
XN297L@250kbps is emulated by default with the NRF24L01. If option (freq tune) is diffrent from 0, the CC2500 module (if installed) will be used instead with option being the freq usual tuning.
2020-01-12 14:06:27 +01:00
pascallanger
953a97dae4 Flyzone: add channel 5 2020-01-12 13:17:17 +01:00
pascallanger
86778c5997 XN297Dump: new auto mode
Automatically:
 - find XN297L packet -> bitrate, scrambling, enhanced...
 - use address to filter incoming packets
 - find all frequencies
 - determine channel order (basic)
 - help to find out the changes by only displaying packets when there is a change in the packet
2020-01-12 13:16:30 +01:00
pascallanger
8c32cdf5fd Pelikan: fix TX and multi ID
Still 1 hopping freq table
2020-01-12 13:00:30 +01:00
pascallanger
d092593e5c Fix FrSky RX bind which could fail if another TX was around 2020-01-12 12:57:16 +01:00
pascallanger
edbf4b6908 Merge pull request #311 from benlye/multi-status-fix
Fix module status on erSkyTX
2020-01-11 10:20:03 +01:00
Ben Lye
43f688d011 Fix module status on erSkyTX 2020-01-10 18:25:56 +00:00
pascallanger
054c3088c3 Merge pull request #305 from Shkolik/Direct_inputs
Direct inputs
2020-01-02 17:29:45 +01:00
Andrew Shkolik
0cedd5bb66 disable myConfig 2019-12-30 16:53:12 -06:00
Andrew Shkolik
1961579fe4 code cleanup 2019-12-30 15:44:16 -06:00
Andrew Shkolik
6906f1652e Inputs logic added 2019-12-24 23:41:04 -06:00
Andrew Shkolik
e2bbe8a422 definitions for direct inputs 2019-12-24 15:03:35 -06:00
pascallanger
8ea4e00d31 Pelikan protocol fix ? 2019-12-20 15:43:44 +01:00
pascallanger
917e27280f Pelikan and Tiger protocol fixes 2019-12-20 09:29:37 +01:00
pascallanger
ec92edfc85 New protocol Tiger
Model: Tiger drone 1400782
Protocol number: 61
No sub_protocol
CH5: Flip
CH6: Light
2019-12-19 23:40:33 +01:00
pascallanger
afd2be6c59 New Pelikan protocol
Protocol number: 60
No sub proto
8 channels AETR...
Extended limit supported
!!Only 1 ID for now!!
2019-12-19 22:39:01 +01:00
pascallanger
a23d50bf0d FrSkyX add bind options CH1-8/CH9-16 & Telem ON/OFF 2019-12-19 17:26:47 +01:00
pascallanger
cace1144db Add TX_LQI (TLQY) comment 2019-12-09 10:47:17 +01:00
pascallanger
0d646ed1a6 Update Protocols_Details.md 2019-12-05 17:14:26 +01:00
pascallanger
e9b09ffecd Update Protocols_Details.md 2019-12-04 10:58:40 +01:00
pascallanger
0008633d6e Bayang RX: Sync 2019-11-30 12:11:08 +01:00
pascallanger
396c005b0a BAYANG RX: enables 6 analog channels
Fix channels range -100%..+100%
2019-11-29 20:26:10 +01:00
pascallanger
d3c3fac4f7 Multi_names mandatory when using multi_telemetry
Validate that sub_proto is valid for the current protocol
Validate that disable channel mapping is valid for the current protocol
2019-11-29 18:50:57 +01:00
pascallanger
cf4acc1d4c Bayang RX: fix warnings 2019-11-29 18:46:24 +01:00
pascallanger
5bd95f8414 Merge pull request #300 from goebish/protocol_bayang_rx
Protocol Bayang rx
2019-11-29 16:37:13 +01:00
Goebish
a31d9a83a3 Use table for channel mapping 2019-11-29 14:26:59 +01:00
Goebish
9b24589897 Fix linefeeds 2019-11-29 14:24:23 +01:00
Goebish
8f3d634132 Fix documentation tag 2019-11-29 14:21:58 +01:00
Goebish
5ef1ccb99b Update protocol details 2019-11-29 13:36:36 +01:00
Goebish
e7d91bc76a Update protocol details 2019-11-29 12:10:56 +01:00
Goebish
e4309824c2 Add missing stuffs 2019-11-29 11:57:06 +01:00
Goebish
cc6a35ac8a Fix channel count 2019-11-29 02:53:19 +01:00
Goebish
1f13a6c281 Add Bayang RX protocol 2019-11-29 02:06:58 +01:00
Goebish
69519bdf14 Add skeleton for Bayang RX protocol 2019-11-28 20:02:59 +01:00
Ben Lye
2e5a8f384a Add '-inv-' to file names for the xn297dump builds 2019-11-28 18:59:40 +00:00
pascallanger
c803eeb26a Esky150: add sub protocols 4CH and 7CH 2019-11-28 17:01:33 +01:00
pascallanger
6a7497cdf8 Update FX816_nrf24l01.ino 2019-11-27 12:24:49 +01:00
pascallanger
3067ea3a5c New protocol: FX816
Model P38
Protocol number: 58
Sub protocol: None
Channels: A & T
2019-11-27 12:12:13 +01:00
pascallanger
9a5309d84b V911S: revert to nrf24l01 2019-11-27 12:10:49 +01:00
pascallanger
fff18f825a DSM: change timing to see if it improves long range telemetry RX range 2019-11-27 12:08:17 +01:00
Ben Lye
e70bdd4152 Update .travis.yml
Put the 'v' back in the version number in the file names
2019-11-26 09:28:45 +00:00
Ben Lye
cf77a1981f Travis CI test changes (#297) 2019-11-26 07:51:00 +00:00
pascallanger
10e33f5d5c Update _Config.h 2019-11-21 08:49:39 +01:00
pascallanger
db442d81dd Fix all compilation issues (?) 2019-11-11 19:15:39 +01:00
pascallanger
f800b4f90b Merge pull request #291 from pascallanger/SPort_Send
New features
2019-11-11 17:30:26 +01:00
pascallanger
712f297d86 Update _Config.h 2019-11-11 17:19:27 +01:00
pascallanger
0afed7d3a4 Fix HoTT menu for internal module 2019-11-11 15:36:39 +01:00
pascallanger
6a03972ff3 Update Protocols_Details.md 2019-11-10 19:34:31 +01:00
pascallanger
0e40f64c6b Enable HoTT RX config menu
Use OpenTX lua script
2019-11-10 18:55:03 +01:00
pascallanger
c83b769f28 Update Multiprotocol.ino 2019-11-10 09:25:42 +01:00
pascallanger
dad3282bbb XN297Dump RF channel display 2019-11-09 19:26:31 +01:00
pascallanger
1621263fb0 HoTT telem doc update 2019-11-09 12:10:56 +01:00
pascallanger
2686cd0c48 Scanner in blocking mode for best perf 2019-11-09 12:10:34 +01:00
pascallanger
b07b081a15 HoTT telemetry size change 2019-11-07 11:13:48 +01:00
pascallanger
c5d4e8c191 Failsafe improvement 2019-11-07 02:30:03 +01:00
pascallanger
928641f535 HoTT: add progmem to tables 2019-11-07 01:56:13 +01:00
pascallanger
c4c5ffec4f HoTT: Failsafe
Failsafe MUST be configured once with the desired channel values (hold or position) while the RX is up (wait 10+sec for the RX to learn the config) and then failsafe MUST be set to RX/Receiver otherwise the servos will jitter!!!
2019-11-07 01:03:57 +01:00
pascallanger
c048e97d3a DSM configurable max throw parameter through option 2019-11-05 19:12:06 +01:00
pascallanger
00f0719659 HoTT: more hop tables 2019-11-05 19:11:28 +01:00
pascallanger
0482627512 HoTT telem 2019-11-05 00:31:20 +01:00
pascallanger
5856442e0f First HoTT version 2019-11-04 19:16:19 +01:00
pascallanger
7b281e47d6 HoTT work in progress 2019-11-04 09:26:12 +01:00
pascallanger
6ef2934c18 Update Telemetry.ino 2019-11-03 15:48:14 +01:00
pascallanger
19b931223b Changed serial timer source 2019-11-03 15:46:05 +01:00
pascallanger
ca15d7108f Prep for HoTT protocol and fix STM32 seed 2019-11-02 20:51:41 +01:00
pascallanger
e6e4d33847 Few changes... 2019-11-02 18:13:47 +01:00
pascallanger
815cf4fd99 FrSky X telemetry quick fix 2019-11-01 18:42:45 +01:00
pascallanger
5cf2bf2cf5 Small tweaks 2019-11-01 15:11:31 +01:00
pascallanger
6632da0276 Fix link 2019-11-01 14:52:50 +01:00
pascallanger
9b499ab7d1 Fix (?) protocol issues 2019-10-31 23:33:10 +01:00
pascallanger
d29461607b Tweakes 2019-10-29 00:36:57 +01:00
pascallanger
243bdf2240 Merge branch 'master' into SPort_Send 2019-10-29 00:02:59 +01:00
pascallanger
cde185901a PPM protcols: remove warning when setting negative option values 2019-10-28 23:29:34 +01:00
pascallanger
a9f35f8095 Update _Config.h 2019-10-27 17:05:02 +01:00
pascallanger
63d7e32e06 INVERT_TELEMETRY_TX flag 2019-10-27 17:02:38 +01:00
pascallanger
400fdb3cc6 FrSkyX LBT RSSI timing improvement 2019-10-27 16:44:36 +01:00
pascallanger
9f1bdc901c FrSkyX LBT: implement LBT instead of transmitting all the time
Needs to be activated using FRSKYX_LBT for now.
2019-10-27 13:20:53 +01:00
pascallanger
61970b028e AFHDS2A: Fix LQI to channel 2019-10-26 15:40:46 +02:00
pascallanger
aee92737ca Fix Failsafe compilation 2019-10-25 22:27:46 +02:00
pascallanger
0fddd9c119 Fix AFHDS2A RX_LQI forward on CH
Hopefully...
2019-10-25 22:03:39 +02:00
pascallanger
b156f66146 Fix Failsafe compilation 2019-10-25 21:35:25 +02:00
pascallanger
63e6590b65 Merge branch 'master' into SPort_Send 2019-10-20 15:48:18 +02:00
pascallanger
103be7f6e0 Update Protocols_Details.md 2019-10-18 18:08:42 +02:00
pascallanger
2154b75499 Fix MULTI_NAMES len... 2019-10-17 22:35:43 +02:00
goebish
6a83cb5577 Frsky rx fixes (#289)
* Restore previous cc2500 register init

* Fix failsafe packets locks

* Fix D8 checksum check
2019-10-17 16:59:08 +02:00
pascallanger
70ce8e9a1f Fix SLT inversion 2019-10-17 16:56:15 +02:00
pascallanger
fdd0a00d5a Correct option value for FrSky protocols 2019-10-17 11:38:23 +02:00
pascallanger
a8cad1e70a Move optionDisp to Data[19] 2019-10-17 09:41:20 +02:00
pascallanger
40afd67fc6 Disable MULTI_SYNC when using RX or Scanner protocols 2019-10-16 20:18:24 +02:00
pascallanger
f3b9206d67 Merge branch 'master' into SPort_Send 2019-10-16 18:54:43 +02:00
pascallanger
b76dd4c8ac Update Compiling_STM32.md 2019-10-16 12:18:15 +02:00
pascallanger
3eb507ebe6 Update Compiling_STM32.md 2019-10-16 12:17:40 +02:00
pascallanger
fe0a1f0f94 Create T16-internal-connection.png 2019-10-16 11:30:45 +02:00
pascallanger
fab3339b8d Update Compiling_STM32.md 2019-10-16 10:49:42 +02:00
pascallanger
10604cf820 Create T16-internal-connector.png 2019-10-16 10:45:16 +02:00
pascallanger
e297310a25 Update Scanner_cc2500.ino 2019-10-15 20:00:45 +02:00
pascallanger
d71006f2ae Update Multi_Names.ino 2019-10-15 20:00:41 +02:00
pascallanger
7a8e099a79 Send MULTI NAMES all the time 2019-10-15 11:19:42 +02:00
pascallanger
822aa84fa2 Update Multi_Names.ino 2019-10-15 08:54:02 +02:00
pascallanger
948ce9e8b8 Send current protocol and sub protocol name 2019-10-15 02:04:19 +02:00
goebish
caf145c38a Auto-detect FrSky RX format (#286)
* Calibrate rf channels for D8 too

* Auto-detect D16FCC, D16LBT or D8 format during bind
2019-10-14 00:28:39 +02:00
pascallanger
f964cdec98 Update Multiprotocol.h 2019-10-13 22:23:32 +02:00
pascallanger
6848fab873 FiX AFHDS2A RX LNA switch 2019-10-13 16:46:24 +02:00
pascallanger
72d57cae71 Merge branch 'master' into SPort_Send 2019-10-13 16:37:18 +02:00
pascallanger
a23178e20e Fix ADHDS2A RX LNA switch 2019-10-13 16:35:09 +02:00
pascallanger
5ae4f0288b Global def for the common RX variables 2019-10-13 11:08:20 +02:00
goebish
e0e51eb187 Fix rc channels init (#284) 2019-10-12 20:31:09 +02:00
pascallanger
840944ea94 Merge branch 'SPort_Send' of https://github.com/pascallanger/DIY-Multiprotocol-TX-Module into SPort_Send 2019-10-12 19:50:46 +02:00
pascallanger
31ff27b1d3 PPM mode FrSkyX to FrSkyD
If TELEMETRY_FRSKYX_TO_FRSKYD is defined in PPM mode FrSkyX simple telemetry will be sent using FrSkyD format:
RX_RSSI, RX_Batt, TX_RSSI, TX_LQI
2019-10-12 19:50:41 +02:00
goebish
a234ccbd05 Protocol FrSkyD (D8) receiver (#283)
* Rename FrSkyX Rx to FrSky Rx

* Rename protocol

* Add D8 receiver sub protocol
2019-10-12 19:50:11 +02:00
pascallanger
6dfd54b8be Remove travis test for debug 2019-10-11 10:08:25 +02:00
Ben Lye
edb7729b35 Update README.md 2019-10-11 08:46:19 +01:00
pascallanger
d434e63c22 Multi_sync updates
Only for STM32
Enable bidirectionnal serial
2019-10-11 01:14:04 +02:00
pascallanger
cd7ede006c Sync radio -> module 2019-10-10 23:12:09 +02:00
pascallanger
d4d0dc3dbc Update Compiling_STM32.md 2019-10-10 16:18:15 +02:00
pascallanger
5c7f997e7a Send channel order in MULTI_TELEMETRY 2019-10-09 11:58:50 +02:00
Ben Lye
1623a007a4 Add Channel Order doc page (#281)
* Create Channel_Order.md

* Update Channel_Order.md

* Update README.md
2019-10-08 21:42:48 +02:00
pascallanger
0b19fa0bdf Disable channel mapping + telemetry inversion 2019-10-08 18:52:47 +02:00
pascallanger
897c8b6ec5 Remove "Disable channel mapping" 2019-10-08 00:07:23 +02:00
pascallanger
d427a7fec1 DSM TH_KILL channel 14 2019-10-07 23:31:03 +02:00
pascallanger
b0749a1bee DSM TH_KILL channel 14 2019-10-07 23:30:17 +02:00
pascallanger
2406080515 Update Protocols_Details.md 2019-10-07 23:27:04 +02:00
pascallanger
ff96146b04 Enhanced serial protocol
Protocol 0..255
RX_Num 0..63
Disable channel mapping -> not implemented yet
Disable telemetry
Data 0-9 bytes
2019-10-07 19:06:00 +02:00
pascallanger
e3a5b2825d Merge branch 'master' into SPort_Send 2019-10-07 08:44:51 +02:00
goebish
9fd72b5ad5 Fix scaling for +125% (#280) 2019-10-05 19:02:59 +02:00
goebish
c2bf63991f Fix channel and rssi scaling (#279) 2019-10-05 13:30:50 +02:00
pascallanger
a75ae7b65a Create irx4-lite-cabling.jpg 2019-10-04 19:46:13 +02:00
pascallanger
507e4cb07b Create irx4-lite-boot0.jpg 2019-10-04 19:40:56 +02:00
pascallanger
0f250bb04b Merge branch 'master' into SPort_Send 2019-10-04 19:04:24 +02:00
pascallanger
4a315057a2 Merge branch 'master' of https://github.com/pascallanger/DIY-Multiprotocol-TX-Module 2019-10-04 19:03:37 +02:00
pascallanger
c8f44a0c4b Fix Multi receiver channels 2019-10-04 19:03:19 +02:00
pascallanger
382d853fe2 Update Compiling_STM32.md 2019-10-04 18:52:48 +02:00
pascallanger
a5996c488e Pictures 2019-10-04 18:48:46 +02:00
pascallanger
760642ecb3 Create irx4-lite.jpg 2019-10-04 18:00:41 +02:00
pascallanger
c7a3548df0 Merge branch 'master' into SPort_Send 2019-10-04 10:32:37 +02:00
pascallanger
d8acc6a5e8 New boards with bin signatures 2019-10-04 10:14:52 +02:00
pascallanger
431808286b Data Buffer signaling 2019-10-03 16:38:50 +02:00
Ben Lye
747fa19259 Update package_multi_4in1_board_index.json 2019-10-02 22:11:18 +01:00
pascallanger
bf61295b76 Fix AFHDS2A_RX 2019-10-02 21:24:50 +02:00
pascallanger
49a1ecea00 Merge branch 'master' into SPort_Send 2019-10-02 21:07:08 +02:00
pascallanger
11f0e55bb1 SPort_Send sequencer 2019-10-02 20:09:18 +02:00
Ben Lye
331da37840 Update Binary_Signature.ino (#278)
Clean up the comments, add bitmasks.
2019-10-02 10:15:13 +02:00
goebish
032e0641a5 Fix AFHDS2A receiver packet filter (#276)
* Add skeleton for AFHDS2A receiver protocol

* Bind & data Ok

* Send channels to TX via telemetry

* Add RSSI

* Fix AVR compilation

* Fix channel number

* Fix packet type check
2019-10-02 09:04:13 +02:00
goebish
f3d2ab61e4 Protocol Flysky AFHDS2A receiver (#275)
* Add skeleton for AFHDS2A receiver protocol

* Bind & data Ok

* Send channels to TX via telemetry

* Add RSSI

* Fix AVR compilation

* Fix channel number
2019-10-01 20:44:26 +02:00
Ben Lye
e8b5f071fe Move signature conditionals to separate file, add channel order (#274) 2019-10-01 11:05:37 +02:00
Ben Lye
ada72d6113 Update Travis Configuration (#273)
Various improvements to the Travis CI script:
* Add channel order builds to releases - now building AETR, TAER, and RETA
* Add PPM builds for each channel order with no inversion and PPM banks set to 5
* Log config diff for each build (diff output folded to keep the log readable)
* Colorify the "Building" lines to make parsing the log easier
* Export .bin files instead of .hex files for the AVR modules
* Add Multi.txt to the release files
2019-10-01 07:43:08 +01:00
pascallanger
c2404d4f0d Code cleanup 2019-09-30 20:53:10 +02:00
pascallanger
821732bba9 Initial S.Port send
!!! No retransmit for now !!!
2019-09-30 17:35:12 +02:00
pascallanger
b6df650f50 Update BOM_DIY_ATmega.md 2019-09-29 15:13:47 +02:00
pascallanger
e783ce5788 Failsafe modification
The following protocols are supporting failsafe: FrSkyX, Devo, WK2x01, SFHSS, HISKY/HK310 and AFHDS2A
In Serial mode failsafe is configured on the radio itself.
In PPM mode and only after the module is up and fully operational, press the bind button for at least 5sec to send the current stick positions as failsafe to the RX.
2019-09-27 16:20:43 +02:00
pascallanger
18af4a0724 AVR modules: Fix KF606, GD00X and Potensic 2019-09-26 15:51:28 +02:00
pascallanger
7e6ec1dc8d Update FrSkyX_Rx_cc2500.ino
Remove compilation warnings for AVR
2019-09-26 15:50:38 +02:00
pascallanger
4fbe0859e0 Update comments 2019-09-25 19:10:55 +02:00
pascallanger
b89c23fe7c PPM channel remapping 2019-09-23 18:13:25 +02:00
goebish
e038c49ae9 Protocol FrskyX D16 RX frequency auto-tune (#270)
* Add autotune during bind

* Fix data phase
2019-09-23 08:11:06 +02:00
Ben Lye
bed02c9384 Update .travis.yml (#269) 2019-09-22 14:17:23 -04:00
pascallanger
96bc4f7cdf Revert Fix FrskyX failsafe hold/no pulse inversion 2019-09-22 20:00:04 +02:00
pascallanger
6503469ddd Bump multi board version to the latest 2019-09-22 17:29:43 +02:00
pascallanger
61a1c3742c Fix FrskyX failsafe hold/no pulse inversion 2019-09-22 17:12:00 +02:00
pascallanger
1fb2a38bc1 Hitec additional telemetry 2019-09-22 17:11:23 +02:00
pascallanger
22a0d79315 FrskyX_RX documentation 2019-09-22 17:05:46 +02:00
MRC3742
0cc72772a3 Repair sub protocol column listing errors for two Protocol (#268) 2019-09-19 20:13:13 +02:00
Pascal Langer
11f4e636e3 AFHDS2A telemetry fix
Discard RX config packets
2019-09-19 10:51:24 +02:00
pascallanger
fef1a2e041 Update Advanced_Debug.md 2019-09-19 09:07:14 +02:00
pascallanger
41a9c8e013 Update Advanced_Debug.md 2019-09-19 08:59:40 +02:00
Pascal Langer
c1ad02b792 Create Debug1.png 2019-09-19 08:55:20 +02:00
Pascal Langer
ab2315c951 FrSkyX: few cosmetic and optimization changes 2019-09-18 11:05:46 +02:00
goebish
7948e33cbc Fix start channel (#267) 2019-09-18 08:48:04 +02:00
goebish
2be2dce584 Protocol FrSky D16 receiver (#266)
* Add skeleton for FrSkyX receiver protocol

* Binds & receives data packets

* Store bind information

* Fix compilation

* Bypass LNA since intended usage implies tx & rx are close together

* Bind channel has FS_AUTOCAL

* Add freq fine tune & low power mode (disable lna)

* Add TX ID check

* Retry longer until first packet is catched

* Fix chanskip for first packet

* Fix defines

* Fix bind

* Send channels to TX

* Fix RSSI reading

* Add missing static keyword

* Fix Validate.h

* Fix compilation
2019-09-17 23:35:19 +02:00
Ben Lye
69bdfe3dba Update package_multi_4in1_board_index.json 2019-09-17 20:36:24 +01:00
Pascal Langer
d73d163a58 Update Validate.h 2019-09-17 09:53:18 +02:00
Ben Lye
48a52ae5b2 Update Multiprotocol.ino (#265) 2019-09-17 09:37:18 +02:00
Pascal Langer
078dc2ab17 AFHDS2A telemetry AA and AC 2019-09-14 16:34:19 +02:00
Pascal Langer
6f4522caa6 Revert "AFHDS2A telemetry AA and AC"
This reverts commit 3c76ce9f39.
2019-09-14 16:31:27 +02:00
Pascal Langer
3c76ce9f39 AFHDS2A telemetry AA and AC 2019-09-14 16:27:07 +02:00
goebish
8601149051 Fix scanner telemetry (#262)
* Fix scanner telemetry

* Take several samples per channel, keep maximum value
2019-09-14 16:07:49 +02:00
pascallanger
d7ef15d435 Update Compiling_STM32.md 2019-09-12 16:08:20 +02:00
pascallanger
27e3645b56 Update Compiling_STM32.md 2019-09-12 15:55:08 +02:00
pascallanger
95eb4e1a22 Update Compiling_STM32.md 2019-09-12 15:54:18 +02:00
pascallanger
32ea07bf5a Update Compiling_STM32.md 2019-09-12 15:51:58 +02:00
pascallanger
06272575c5 Flash from TX 2019-09-12 15:50:12 +02:00
Pascal Langer
edd6432d4c Update Validate.h 2019-09-11 15:26:35 +02:00
Pascal Langer
303c4615e9 Fix scanner compilation issue 2019-09-11 12:23:36 +02:00
Pascal Langer
7d327c1622 Scanner 2.4GHz
Thanks to Goebish for this spectrum analyzer.
It will work soon with the OpenTX 2.3 Spectrum Analyser tool.
2019-09-10 23:37:54 +02:00
Ben Lye
6a74b83f98 Update .travis.yml 2019-09-08 14:40:59 +01:00
Ben Lye
c601c2dd98 Update .travis.yml 2019-09-08 14:25:52 +01:00
Ben Lye
c27b60749f Update Travis CI script (#257)
* Use latest STM32 board options
* Use latest Arduino IDE
* Fix build functions to return an error if the build fails
* Modify the files that get exported to releases
2019-09-08 13:33:26 +01:00
Ben Lye
b3cb286088 Update package_multi_4in1_board_index.json 2019-09-07 18:54:27 +01:00
Ben Lye
361903e8ec Doc updates for new board package (#256) 2019-09-07 18:23:08 +01:00
Ben Lye
d72c69242d Update package_multi_4in1_board_index.json
Add AVR board v1.0.8 and STM32 board v1.1.5.
2019-09-06 19:43:10 +01:00
Ben Lye
539819fa0c Accomodate new Debug Option setting in Arduino IDE (#255)
Thanks, that's perfect!
2019-09-06 14:05:57 +02:00
Ben Lye
d80c218744 Add timeout to serial debug (#253)
* Wait 30s for serial debug instead of waiting forever
* Delay of 50ms to allow FTDI debugger to connect at startup
2019-09-05 08:33:01 +02:00
pascallanger
0603d220a9 T16 Flash from TX 2019-09-04 17:39:47 +02:00
pascallanger
e13fe56f47 Include the Jumper T16 2019-09-04 17:38:00 +02:00
pascallanger
acd7694485 Update Protocols_Details.md 2019-09-02 19:23:15 +02:00
pascallanger
7f50edacc8 Update Protocols_Details.md 2019-09-02 19:07:48 +02:00
pascallanger
5a4906c5b5 Update Protocols_Details.md 2019-09-02 19:06:34 +02:00
Pascal Langer
4e906757b9 XN297Dump fix enhanced unscramble mode 2019-08-24 22:39:27 +02:00
Pascal Langer
1f0b21e351 Fix GW008 protocol 2019-08-24 22:14:18 +02:00
Pascal Langer
2f3ea323c7 CHECK_FOR_BOOTLOADER now enabled by default in _config.h 2019-08-24 21:50:36 +02:00
Pascal Langer
d4e77c6499 XN297Dump: added enhanced packet mode 2019-08-24 21:37:26 +02:00
pascallanger
ffc56b049d Update Advanced_Debug.md 2019-08-20 14:07:38 +02:00
pascallanger
ddac89d732 Update Advanced_Debug.md 2019-08-20 14:06:01 +02:00
Pascal Langer
fecf2805c7 WIP: Advanced topics 2019-08-20 14:01:56 +02:00
Pascal Langer
4dcc88ba32 Serial debug documentation 2019-08-18 18:44:36 +02:00
Pascal Langer
084308d8a4 Update Multi.txt 2019-08-18 17:08:27 +02:00
Pascal Langer
1ffb5c405b New protocol: Flyzone
Models compatible with TX FZ-410
Protocol 53
No sub protocol
2019-08-17 22:37:00 +02:00
Pascal Langer
ad29409407 New protocol ZSX
Model JJRC ZSX-280
Protocol number 52 ,no sub protocol
CH3: Throttle
CH4: Rudder
CH5: Light
2019-08-10 21:43:14 +02:00
Pascal Langer
6f33abb25e New protocol Traxxas
Protocol number: 43
Compatible with receivers 6519
Extended limits supported
CH1=AUX3
CH2=AUX4
CH3=THROTTLE
CH4=STEERING
2019-08-06 17:27:42 +02:00
Pascal Langer
2c9693389e Fix DSM telemetry and global cyrf6936 freq tunning
- Fixed DSM telemetry with some RXs (R720X)
 - Global frequency tunning for all protocols using the CYRF6936 by adjusting channel 15 when enabled
 - Changed default DSM_THROTTLE_KILL_CH to use channel 14
2019-08-01 14:23:08 +02:00
MRC3742
d3c82c4da4 Add option instructions to update STM module (#243) 2019-07-18 10:34:46 +02:00
Pascal Langer
541a96e7b4 Merge branch 'master' of https://github.com/pascallanger/DIY-Multiprotocol-TX-Module 2019-07-04 10:37:42 +02:00
Pascal Langer
5b234a9cbc Mandatory use of boards AVR 1.0.7 and STM32 1.1.4 solving path space issues 2019-07-04 10:37:25 +02:00
Ben Lye
24c3a62f3a Update package_multi_4in1_board_index.json 2019-07-04 09:31:51 +01:00
Pascal Langer
23756a387a XN297Dump: fix packet timer 2019-07-03 20:51:13 +02:00
Pascal Langer
efbd350dfd GD00X: fix typo... 2019-07-03 18:27:39 +02:00
Pascal Langer
072e95c84e Merge branch 'master' of https://github.com/pascallanger/DIY-Multiprotocol-TX-Module 2019-07-03 18:13:08 +02:00
Pascal Langer
4be26e7202 GD00X: add high/low rates 2019-07-03 18:07:18 +02:00
pascallanger
a616cbb95c Update Protocols_Details.md 2019-07-03 18:05:54 +02:00
Pascal Langer
8aea9aa3dd Added a common deadband conversion code
Modified protocols:
 - GD00X applied on aileron
 - KF606 applied on aileron
 - POTENSIC applied on throttle
2019-07-03 17:39:05 +02:00
pascallanger
e4992bc917 Update Protocols_Details.md 2019-07-03 16:48:06 +02:00
pascallanger
000b3e97c7 Update Protocols_Details.md 2019-07-03 09:55:16 +02:00
pascallanger
cb91e19413 Update Compiling_STM32.md 2019-07-03 00:18:45 +02:00
pascallanger
c72e690085 Update Compiling_STM32.md 2019-07-02 23:32:27 +02:00
pascallanger
f1a4e659e7 Update Compiling_STM32.md 2019-07-02 23:28:02 +02:00
pascallanger
0d56d17d52 Update Compiling_STM32.md 2019-07-02 23:25:37 +02:00
pascallanger
96c89c8c97 Update Compiling_STM32.md 2019-07-02 23:12:26 +02:00
pascallanger
7df5a1f211 Update Compiling_STM32.md 2019-07-02 23:11:03 +02:00
pascallanger
8ae8e028c7 Update Compiling_STM32.md 2019-07-02 22:34:23 +02:00
pascallanger
581ad5f8f4 Update Compiling_STM32.md 2019-07-02 22:33:05 +02:00
pascallanger
977bae3750 Add files via upload 2019-07-02 22:28:43 +02:00
pascallanger
8a0161607e Update Protocols_Details.md 2019-07-02 21:51:31 +02:00
Ben Lye
cd6a7bfc3a Update package_multi_4in1_board_index.json
Add new boards which resolves issue with spaces in the sketch path on Windows.
2019-06-27 15:50:44 +01:00
Pascal Langer
4671700b7d Devo protocol: number of channels 2019-06-23 17:13:30 +02:00
pascallanger
840ca74407 Redpine changes (#240)
* Change Looptimes
state => bind_counter

* minimize whitespace changes
2019-06-20 10:53:31 +02:00
Bryce Johnson
0d8a7e46de Redpine changes (#240)
* Change Looptimes
state => bind_counter
2019-06-20 10:53:17 +02:00
pascallanger
8b9940b0f0 Redpine typo 2019-06-19 16:07:08 +02:00
Pascal Langer
521b819b8a New protocol POTENSIC
Model: A20
Protocol number: 51
Sub protocol: none
Channels:
- CH5 TAKE_OFF/LANDING: momentary switch -100% -> +100%
- CH6 EMERGENCY: Stop +100%
- CH7 MODE: MODE: Beginner -100%, Medium 0%, Advanced +100%
- CH8 HEADLESS: Off -100%, On +100%
2019-06-19 11:25:21 +02:00
Bryce Johnson
208e9ef64b minimize whitespace changes 2019-06-17 19:08:07 -06:00
Bryce Johnson
a7ea8e012e Change Looptimes
state => bind_counter
2019-06-17 19:01:27 -06:00
Pascal Langer
d940a7e49a New Redpine protocol
Protocol Redpine: 50
Sub protocol: Fast=0, Slow=1
Option=freq tunning
2019-06-17 17:16:39 +02:00
Pascal Langer
9d50171034 BUGS fix a bug... 2019-06-10 09:19:56 +02:00
Pascal Langer
701a5b9e28 Merge branch 'master' of https://github.com/pascallanger/DIY-Multiprotocol-TX-Module 2019-06-09 19:00:27 +02:00
Pascal Langer
d11785ef2d V761... forgot to save the change before pushing... 2019-06-09 19:00:21 +02:00
pascallanger
f4a4d91ef8 V761 additional IDs 2019-06-09 15:06:29 +02:00
Pascal Langer
9514e47ed3 BUGS EEPROM clean: need to rebind BUGS and BUGSMINI 2019-06-09 14:51:21 +02:00
Pascal Langer
9461f2d632 V761 3rd ID 2019-06-09 14:50:17 +02:00
Pascal Langer
f6064d03e1 V761 aileron channel 2019-06-08 21:57:02 +02:00
MRC3742
0d917e0dc5 Update TOC for sub protocols using CC2500 to emulate XN297L @250kbps (#234) 2019-06-08 21:26:25 +02:00
pascallanger
9408af8d08 Update Protocols_Details.md 2019-06-08 21:25:02 +02:00
Pascal Langer
862ab48bbc Update V761_nrf24l01.ino 2019-06-06 10:26:54 +02:00
Pascal Langer
f498347c53 V761 second TX ID/freqs 2019-06-06 10:07:57 +02:00
Pascal Langer
3f77f59c8a XN297L emu scramble option 2019-06-06 01:15:28 +02:00
pascallanger
e96186015d XN297L CC2500 emulation 2019-06-05 23:31:17 +02:00
Pascal Langer
1fa6e4526b Include full xn297(L) xor tables 2019-06-05 23:23:27 +02:00
Pascal Langer
3853d585a0 XN297L/CC2500 emulation on V911s 2019-06-05 22:53:24 +02:00
Pascal Langer
e8c6225ef0 New XN297L 250Kbps emu layer based on CC2500
This layer can be enabled/disabled with the option XN297L_CC2500_EMU in _config.h
Protocols which are using it so far:
GD00X, KF606 and MJXQ/E010&PHOENIX
2019-06-05 21:54:47 +02:00
Pascal Langer
17c67cc780 Update V761_nrf24l01.ino 2019-06-04 22:42:37 +02:00
Pascal Langer
dcc4236833 Merge branch 'master' of https://github.com/pascallanger/DIY-Multiprotocol-TX-Module 2019-06-04 22:02:43 +02:00
Pascal Langer
6a7c735924 Fix V761 input 2019-06-04 22:02:20 +02:00
pascallanger
3c40cd853e Update Protocols_Details.md 2019-06-04 21:59:12 +02:00
pascallanger
5357660b68 KF606 and V761 protocols 2019-06-04 21:56:39 +02:00
Pascal Langer
a15a911f8e New protocol KF606
Model: KF606
Protocol: 49
No sub protocol
Channels: throttle, aileron and trim on ch5
2019-06-04 21:44:40 +02:00
Pascal Langer
ded0487ce6 XN297Dump improvements
Selection of address length
Timing accuracy
2019-06-04 21:41:50 +02:00
pascallanger
e7b079ece7 Update Protocols_Details.md 2019-06-01 16:05:23 +02:00
goebish
0cbe4de920 Fix E010/CC2500 Protocol on AVR (#229)
* Use cc2500 fast frequency hopping

* Calibrate cc2500 PLL if sub-protocol is E010/Phoenix only

* Fix e010 crc for AVR
2019-05-31 09:17:27 +02:00
Ben Lye
5c3bf30fe7 Fix CX20 image 2019-05-29 08:48:21 +01:00
Ben Lye
56b8694fd5 Add CX20 Image 2019-05-29 08:47:25 +01:00
Pascal Langer
c9fecafada WFly frequency tunning 2019-05-18 20:33:32 +02:00
Pascal Langer
f3ca7ad644 WFly freq tuning on channel 15
You need to enable the tuning in _config.h: #define USE_CYRF6936_CH15_TUNING
2019-05-18 17:36:39 +02:00
pascallanger
c3b48c78af Update Protocols_Details.md 2019-05-18 13:48:02 +02:00
Pascal Langer
18dcc29a0d XN297Dump: auto scramble detection 2019-05-17 20:34:02 +02:00
Pascal Langer
c3a5c263d3 XN297Dump fix CRC... 2019-05-17 19:56:52 +02:00
Pascal Langer
ccdf60d525 XN297DUMP: dynamic address search
The dump process is now looking for addresses with different length (3..5) additonnaly to the packet length.
Untested...
2019-05-17 17:00:08 +02:00
Pascal Langer
443e1cec75 New protocol V761
Protocol number: 48
Sub_protocol: none
Channel 5: +100% expert, 0% mid=gyro on no rate limits, -100% beginer=gyro on and axis rate limited.
ONLY 1 ID IS AVAILABLE SO BE CAREFUL WHILE FLYING.
2019-05-17 16:25:39 +02:00
goebish
aa540514b8 Use CC2500 if available instead of NRF24L01 for E010 and PHOENIX (#225)
* Use CC2500 if available instead of NRF24L01 for E010 and PHOENIX sub protocols

* Update documentation

* Why do I always swap below & above ?
2019-05-16 13:17:39 +02:00
pascallanger
fda7e2e5b6 Update Protocols_Details.md 2019-05-14 18:23:24 +02:00
pascallanger
fb4d5cf437 Update Protocols_Details.md 2019-05-14 18:22:07 +02:00
pascallanger
9fc2898a56 Bayang protocol DHD D4 sub_protocol 2019-05-10 21:52:54 +02:00
Pascal Langer
2e24323adf DHD D4 set to high rates 2019-05-10 21:39:15 +02:00
pascallanger
77abc1ed7c BUGS3H Altitude Hold 2019-05-10 21:09:31 +02:00
Pascal Langer
259d550d04 AFHDS2A: stop bind process as requested 2019-05-10 19:39:14 +02:00
Pascal Langer
1a8f9c5a12 AFHDS2A extended telemetry forward 2019-05-10 18:17:09 +02:00
Pascal Langer
1916eb3095 AFHDS2A: add debug on full telemetry frames 2019-05-10 11:04:21 +02:00
Pascal Langer
fc3eec7ae1 BUSMINI: 3H altitude hold mode on CH11 2019-05-09 23:56:06 +02:00
Ben Lye
8d10c9b004 Update .travis.yml
Fix file extension for compiled STM32 files
2019-05-09 21:36:49 +01:00
Pascal Langer
511f77f5e7 Bayang DHD D4 sub protocol 2019-05-09 18:23:19 +02:00
pascallanger
a58d7a4d79 Update Protocols_Details.md 2019-05-09 13:33:08 +02:00
Pascal Langer
6748f6ce78 Add XN297 Dump protocol
Protocol number: 63
Sub protocols: 0=250Kb, 1=1Mb, 2=2Mb
Option: -1=scan RF channels, 0-84=RF channel
DEBUG_SERIAL must be enabled
If a valid frame is received the frame will be sent on the serial port.
2019-05-08 22:01:24 +02:00
ben@lye.co.nz
2dcb6b1987 Update the Travis deploy API key 2019-05-08 15:50:43 +01:00
Ben Lye
2b4ac41142 Update .travis.yml
* Change build commands to make log a little easier to read
* Create a backup of the _config.h file before starting
* Add `before_deploy` and `deploy` sections to deploy compiled binaries when a release is tagged
2019-05-08 15:10:37 +01:00
Pascal Langer
2b47958207 Debug on AFHDS2A telemetry 2019-05-06 22:39:18 +02:00
Pascal Langer
5538d4d1c4 AFHDS2A update RF channels and Failsafe
You need to bind all the RXs again...
2019-04-26 17:51:14 +02:00
pascallanger
467756df48 BUGS3MINI 2019-04-18 10:48:38 +02:00
pascallanger
534ebb26c0 Update Protocols_Details.md 2019-04-18 10:45:48 +02:00
Pascal Langer
21790a9725 BUGSMINI sub protocol BUGS3H 2019-04-18 10:44:42 +02:00
Pascal Langer
6bc22c8ac4 BUGSMINI telemetry fix 2019-04-15 23:28:24 +02:00
Pascal Langer
ac1c422f14 Update Multi.txt 2019-04-15 10:51:28 +02:00
pascallanger
efa1860104 MJXQ sub protocol PHOENIX 2019-04-15 10:50:16 +02:00
Pascal Langer
c673b4254f MJXQ (18) new sub protocol PHOENIX (6) 2019-04-15 10:48:20 +02:00
Pascal Langer
96db173694 BUS Mini: Dynamic trims 2019-04-15 10:31:18 +02:00
pascallanger
1d5be624fe GD00X V2 2019-04-11 23:25:01 +02:00
Pascal Langer
56f9672896 Update GD00X_nrf24l01.ino 2019-04-11 22:47:01 +02:00
Pascal Langer
303b3f08b8 GD00X V2: 64 IDs 2019-04-11 22:42:00 +02:00
Pascal Langer
150e3fd92e GD00x V2 support
Only 1 ID available for now.
Protocol: 47
Sub-protocol: 1
Channels: same as V1
2019-04-09 22:39:03 +02:00
Pascal Langer
840b01273c Update GD00X_nrf24l01.ino 2019-04-03 09:25:48 +02:00
Pascal Langer
8a7beda339 E016H calibration 2019-04-03 09:06:15 +02:00
Pascal Langer
65606f7083 Merge branch 'master' of https://github.com/pascallanger/DIY-Multiprotocol-TX-Module 2019-04-02 09:16:18 +02:00
Pascal Langer
0095071ebf E016 fix 2019-04-02 09:16:13 +02:00
Ben Lye
ae4ee9061d Update package_multi_4in1_board_index.json
STM32 board v1.1.1
2019-03-21 17:35:42 +00:00
Ben Lye
6ba06bc006 Update Compiling.md
Added a warning about spaces in the path for Windows users.
2019-03-21 17:32:20 +00:00
Ben Lye
00f247eae1 Update Compiling_STM32.md
Added a warning about spaces in the path for Windows users.
2019-03-21 17:31:07 +00:00
Pascal Langer
c250c91ab4 BUGSMINI flip issue fix 2019-03-11 10:03:16 +01:00
Brian
b1ac10a4c4 Add Silverware's analog aux channel feature to Bayang protocol (#215)
* Expanded Bayang protocol to have Option 2, which adds two analog auxiliary channels driven by channels 14 and 15. The expert byte is taken over, as is the extra txid byte, which is not used by Silverware.

* Change Bayang options - Bit 0 (LSB) enables telemetry and Bit 1 selects analog aux channels

* Changed Bayang protocol bind to ensure binding only when telemetry and analog aux option selections match on RX and TX

* Add details for Bayang protocol update
2019-03-03 20:47:58 +01:00
Pascal Langer
af4185fbea Fix E01X BV statements 2019-03-03 20:42:26 +01:00
Pascal Langer
aa85d4d797 Merge branch 'master' of https://github.com/pascallanger/DIY-Multiprotocol-TX-Module 2019-02-28 21:45:23 +01:00
Pascal Langer
74cc63e6dd E016H typo fix 2019-02-28 21:45:16 +01:00
pascallanger
04ed613ca3 E016H addition 2019-02-28 21:15:38 +01:00
pascallanger
9ea157b9b6 E016H addition 2019-02-28 21:13:49 +01:00
Pascal Langer
536d7f6124 E016H subprotocol addition to E01X
Protocol E01X (45)
Subprotocol E016H (2)
Channels:
CH5=STOP
CH6=FLIP
CH8=HEADLESS
CH9=RTH
2019-02-28 21:11:05 +01:00
pascallanger
869a01b57f Update Compiling_STM32.md 2019-02-18 09:44:57 +01:00
Pascal Langer
ea982b23c2 Merge branch 'master' of https://github.com/pascallanger/DIY-Multiprotocol-TX-Module 2019-01-09 16:56:57 +01:00
Pascal Langer
15dfe8cead Fix E01X hang up when option=0 2019-01-09 16:56:53 +01:00
pascallanger
b50027150e xn297L @250kbps issues 2019-01-09 13:49:45 +01:00
Pascal Langer
103acb8294 Add PPM protocol list definition in _MyConfig.h 2018-12-10 11:34:11 +01:00
pascallanger
aca23b8bca Update Protocols_Details.md 2018-12-06 16:49:02 +01:00
Ben Lye
aaffbbc5be Add AVR v1.0.4 and STM32 v1.1.0 boards 2018-12-01 19:32:20 +00:00
MRC3742
e0002c9488 Add Table of Contents (#206)
Adds a chart for quick reference of all available protocols with quick links to each protocols description. Also makes navigating this lengthy file much easier.
2018-11-30 10:35:30 +01:00
pascallanger
687d6d914c GD00X full id support 2018-11-25 21:41:46 +01:00
Pascal Langer
9a61b2701e GD00X: Implement general ID/Freq 2018-11-25 20:52:44 +01:00
MRC3742
d8224ebefe Correction in example file of #define Module_3 (#205) 2018-11-25 19:13:44 +01:00
Pascal Langer
cc2af73a05 Bayang Visuo support, DSM TH_KILL improvement 2018-11-23 10:03:55 +01:00
Pascal Langer
aecd44ada6 Merge branch 'master' of https://github.com/pascallanger/DIY-Multiprotocol-TX-Module 2018-11-22 23:29:20 +01:00
Pascal Langer
72593c4d99 _Config.h DSM_THROTTLE_KILL description 2018-11-22 23:29:15 +01:00
pascallanger
52ca258616 Update Protocols_Details.md 2018-11-22 23:24:38 +01:00
pascallanger
04412667ff Update Protocols_Details.md 2018-11-22 23:08:20 +01:00
pascallanger
4124ec80ec Update Protocols_Details.md 2018-11-22 23:07:01 +01:00
pascallanger
693ea75e95 Update Protocols_Details.md 2018-11-22 23:01:26 +01:00
pascallanger
9e3c1ab059 Update Compiling.md 2018-11-22 11:42:47 +01:00
pascallanger
5fc860702f Update Compiling.md 2018-11-22 10:35:30 +01:00
pascallanger
6ad2ee5a47 Update Compiling.md 2018-11-22 10:32:13 +01:00
pascallanger
b0f64297cb Update Compiling_STM32.md 2018-11-22 10:21:18 +01:00
Pascal Langer
f99a63dbc0 Merge branch 'master' of https://github.com/pascallanger/DIY-Multiprotocol-TX-Module 2018-11-22 08:34:01 +01:00
Pascal Langer
9261e8fe94 DSM throttle kill: correct channel number 2018-11-22 08:33:57 +01:00
pascallanger
52bb116e24 Update Flash_from_Tx.md 2018-11-21 20:29:52 +01:00
pascallanger
7006c36101 Update Flash_from_Tx.md 2018-11-21 20:27:50 +01:00
pascallanger
f7d452e3f1 Update Flash_from_Tx.md 2018-11-21 20:24:09 +01:00
pascallanger
598e50a40f Update Flash_from_Tx.md 2018-11-21 20:10:24 +01:00
pascallanger
eadfa26c3b Add files via upload 2018-11-21 20:03:13 +01:00
pascallanger
b03491fdf7 Update Flash_from_Tx.md 2018-11-21 19:20:51 +01:00
pascallanger
42911c63b3 Update Flash_from_Tx.md 2018-11-21 16:59:33 +01:00
pascallanger
43462757ed Update Flash_from_Tx.md 2018-11-21 16:58:44 +01:00
pascallanger
0eee1c5d15 Update Flash_from_Tx.md 2018-11-21 16:57:17 +01:00
pascallanger
3a21bf69f1 Update Flash_from_Tx.md 2018-11-21 16:47:26 +01:00
pascallanger
7d4c8f7f07 Update Compiling_STM32.md 2018-11-21 14:26:05 +01:00
pascallanger
866d19d649 Update Compiling_STM32.md 2018-11-21 14:23:55 +01:00
pascallanger
c27ec2475c Update Compiling_STM32.md 2018-11-21 14:17:44 +01:00
pascallanger
1d64cbfaa0 Update Compiling_STM32.md 2018-11-21 14:15:26 +01:00
pascallanger
5d1baa89e4 Update Compiling_STM32.md 2018-11-21 14:11:24 +01:00
pascallanger
e846ce7e98 Update Compiling_STM32.md 2018-11-21 13:08:27 +01:00
pascallanger
300b3582a6 Update Compiling.md 2018-11-21 12:03:20 +01:00
pascallanger
3a7ffe62b0 Update Compiling.md 2018-11-21 12:02:49 +01:00
Pascal Langer
d990ebe49e _Config.h file update 2018-11-20 21:15:31 +01:00
Pascal Langer
bd78739217 AFHDS2A: LQI to RX channel 2018-11-20 21:04:29 +01:00
Pascal Langer
6c7312a09c DSM: Throttle Kill option 2018-11-20 16:54:55 +01:00
pascallanger
1525e564cb Update Protocols_Details.md 2018-11-20 13:17:09 +01:00
Pascal Langer
7fb4bbbf3c GD00X fix 2018-11-17 09:08:23 +01:00
Pascal Langer
2553d44d32 Merge branch 'master' of https://github.com/pascallanger/DIY-Multiprotocol-TX-Module 2018-11-16 09:13:47 +01:00
Pascal Langer
dc902b7a61 E01X test 2018-11-16 09:13:45 +01:00
pascallanger
b992cbd92e New GD00X protocol 2018-11-16 00:36:52 +01:00
Pascal Langer
22711fad28 Update GD00X 2018-11-15 23:49:26 +01:00
Pascal Langer
a9df0abed3 Update Multiprotocol/GD00X_nrf24l01.ino 2018-11-15 23:16:15 +01:00
Pascal Langer
fd65550f8d Fix typos... 2018-11-15 22:32:50 +01:00
Pascal Langer
b910ad3386 New protocol GD00X
Protocol number: 47
No sub protocol
!!!! ONLY 1 ID AT THIS TIME !!!!
CH1 AILERON
CH3 THROTTLE
CH5 TRIM
CH6 LIGHT
2018-11-15 11:08:07 +01:00
pascallanger
fb9f094365 Update Protocols_Details.md 2018-11-11 17:10:06 +01:00
Pascal Langer
05470446a0 V911S mod
Change AIL and RUD directions.
2018-11-09 10:19:36 +01:00
Pascal Langer
903982afb7 V911S protocol
Protocol number 46
No sub protocol
CH5: yaw calib
2018-11-09 00:31:26 +01:00
Ben Lye
8bea5b125b Tweak protocol builds (#199) 2018-11-07 15:54:17 +01:00
Pascal Langer
c658a892f2 Fix some compilation issues 2018-11-07 15:52:39 +01:00
Pascal Langer
3f0d6cfcf1 Typo fix 2018-11-07 10:48:11 +01:00
Pascal Langer
c6657c199c Merge branch 'master' of https://github.com/pascallanger/DIY-Multiprotocol-TX-Module 2018-11-07 09:35:38 +01:00
pascallanger
cf6d980b8b Update Protocols_Details.md 2018-11-06 22:16:34 +01:00
Pascal Langer
c3ff49e86e E01X new protocol
New protocol E01X number 45
Sub protocol E012 number 0
Sub protocol E015 number 1
Channels:
ARM_SW      CH5
FLIP_SW     CH6
LED_SW      CH7
HEADLESS_SW CH8
RTH_SW      CH9
2018-11-06 22:06:19 +01:00
Pascal Langer
e51f91f041 Bugs protocol fix? 2018-11-06 21:43:55 +01:00
Pascal Langer
2589c67f6c NCC1701 fix 2018-11-05 20:03:39 +01:00
pascallanger
2f4f19b52b Update Protocols_Details.md 2018-11-05 20:02:48 +01:00
pascallanger
b3ed7563dc NCC1701 2018-11-03 17:28:40 +01:00
Pascal Langer
ea96c328fc Protocol NCC1701
CH5: Warp
Telemetry:
A1 voltage is used for crash detection. In case of a crash A1=0V. You can be assign a sound to the crash.
2018-11-03 17:24:47 +01:00
Pascal Langer
f42da14413 New NCC1701 protocol
NCC1701 - 44
Model: Air Hogs Star Trek USS Enterprise NCC-1701-A
Autobind protocol
Only 9 IDs available, cycle through them using RX_Num.
2018-11-02 21:20:57 +01:00
pascallanger
2149149723 New Protocol NCC1701 2018-11-02 21:17:51 +01:00
Pascal Langer
f1916b3d0b Merge branch 'master' of https://github.com/pascallanger/DIY-Multiprotocol-TX-Module 2018-10-17 13:24:08 +02:00
Pascal Langer
10788976b6 New protocol BUGSMINI
Models: MJX Bugs 3 Mini and 3H
Protocol BUGSMINI = 42
No sub_protocol
Telemetry = RX RSSI and battery voltage  good/warning/bad
RX_Num is used to give a number to a given model. You must use a different RX_Num per MJX Bugs Mini. A maximum of 16 Bugs Mini are supported.
Channels:
ARM	CH5
ANGLE	CH6
FLIP		CH7
PICTURE	CH8
VIDEO	CH9
LED		CH10
2018-10-17 13:23:27 +02:00
pascallanger
567d26a385 New protocol BUGSMINI 2018-10-17 13:21:22 +02:00
Pascal Langer
220eb8f6f4 Merge branch 'master' of https://github.com/pascallanger/DIY-Multiprotocol-TX-Module 2018-10-11 17:58:11 +02:00
Pascal Langer
b40e7d6e97 Bugs: fixed telemetry disable compilation error 2018-10-11 17:58:07 +02:00
pascallanger
97dd90a718 OpenLRSng 2018-09-24 10:30:26 +02:00
pascallanger
75ba6401a4 Hubsan typo 2018-09-19 17:19:58 -04:00
Pascal Langer
5cf8d8d263 ESKY protocol code review 2018-09-15 08:02:05 -04:00
Pascal Langer
058e09c413 _config.h descriptions update 2018-09-13 17:25:49 -04:00
Pascal Langer
63fb1b1f36 Removed old SLT sub protocols 2018-09-12 14:24:30 -04:00
Pascal Langer
7c0b9ce3c6 Merge branch 'master' of https://github.com/pascallanger/DIY-Multiprotocol-TX-Module 2018-09-12 09:51:59 -04:00
Pascal Langer
c153d236f2 SLT Q100/Q200/MR100: reverse elevator 2018-09-12 06:49:40 -04:00
pascallanger
3b3a3c275c Update Protocols_Details.md 2018-09-12 06:45:09 -04:00
Pascal Langer
f4691d08cc SLT Q100/Q200/MRT100: reverse throttle 2018-09-11 15:51:28 -04:00
pascallanger
e5d9471b33 Update Protocols_Details.md 2018-09-11 09:33:54 -04:00
pascallanger
ab9525c507 Update Compiling_STM32.md 2018-09-11 06:06:34 -04:00
pascallanger
b1fb3a5470 Update Protocols_Details.md 2018-09-11 05:24:21 -04:00
pascallanger
b2194790eb SLT changes 2018-09-11 05:20:45 -04:00
Pascal Langer
8901310ed4 BUGS: fix? 2018-09-11 04:59:07 -04:00
Pascal Langer
09c6adaa95 BUGS: fix 2018-09-10 21:28:37 -04:00
Pascal Langer
5fe1e9674e DSM functions and variables renamed 2018-09-10 09:58:31 +02:00
pascallanger
601116bd59 SLT sub protocols Q100/Q200/MR100 2018-09-10 08:34:30 +02:00
Pascal Langer
27dc02fdec SLT sub protocol Q100
CH9 FMODE
CH10 FLIP
CH13 Gyro calib
2018-09-10 08:11:56 +02:00
Pascal Langer
03f417546e Multi.txt update 2018-09-09 11:29:25 +02:00
Pascal Langer
3b9aa79201 SLT sub protocol MR100 for Vista
CH9: MODE
CH10: FLIP
CH11: VIDEO
CH12:PICTURE
2018-09-09 11:26:01 +02:00
Ben Lye
5aa4936c0e Add stm32 board v1.0.9 (#192) 2018-09-07 10:27:43 +01:00
pascallanger
1e65d58113 SLT Q200 channels 2018-09-07 10:52:07 +02:00
Pascal Langer
e2a66bdd1f SLT/Q200: gyro calibration on CH13 2018-09-07 10:38:22 +02:00
pascallanger
4f9c30505a Update README.md 2018-09-06 20:49:28 +02:00
pascallanger
1ec817c96c SLT sub protocols V1, V2, Q200 2018-09-06 19:09:10 +02:00
pascallanger
41528ae7b6 Update README.md 2018-09-06 18:56:14 +02:00
pascallanger
77d248df0b Add Travis status 2018-09-06 17:24:56 +02:00
Ben Lye
c6cb13b332 Initial go at Travis CI (#191) 2018-09-06 10:44:16 +01:00
Pascal Langer
d67108fa8b SLT/Q200: Fix frequencies calculation 2018-09-06 10:57:36 +02:00
Pascal Langer
b7447f055a SLT/Q200 subprotocol changes 2018-09-05 15:38:36 +02:00
pascallanger
3902ed19b7 Update Compiling_STM32.md 2018-09-03 19:11:33 +02:00
Pascal Langer
51ba7cf75c Update SLT/Q200 hopping freq 2018-09-03 17:30:53 +02:00
Pascal Langer
82fb5dd0da SLT: added sub_protocols
SLT (11) sub_protocols are now
 - V1 (0): original 6 channels
 - V2 (1): 6 channels, might be able to add channel 7 and 8 but need testing
 - Q200 (2): 5 channels + switches: CH9=FMODE, CH10=FLIP, CH11=VIDON, CH12=VIDOFF
2018-09-03 16:02:43 +02:00
Ben Lye
2ac20cb575 Update Advanced_Topics.md 2018-08-31 19:39:53 +01:00
Ben Lye
3f33e5b2a8 Created EEPROM doc (#189) 2018-08-31 19:36:46 +01:00
Pascal Langer
655ea98bf1 Hubsan/H501: removed useless channels headless2 and osd 2018-08-31 00:01:05 +02:00
pascallanger
238260612c Update Protocols_Details.md 2018-08-30 23:58:21 +02:00
pascallanger
cd26c2d8e6 Update Protocols_Details.md 2018-08-29 18:16:23 +02:00
pascallanger
814e28b86a Update Protocols_Details.md 2018-08-29 17:36:18 +02:00
Pascal Langer
f515ba79af Hubsan sub_protocol 501 features
sub_protocol H501
Model H122D: add flip on ch13 and OSD on ch14
Model H123D: add flight modes on ch16 -> -100% Sport mode 1,0% Sport mode 2, +100% Acro
2018-08-29 17:29:50 +02:00
pascallanger
e6f16700e4 Update Protocols_Details.md 2018-08-29 14:56:24 +02:00
pascallanger
f38e7c35da Bugs angle/acro mode 2018-08-29 14:54:24 +02:00
Pascal Langer
b3576b7162 BUGS protocol
Add channel for ANGLE/ACRO mode. Angle is +100%, acro is -100%.
Channels mapping:
ARM	CH5
ANGLE	CH6
FLIP		CH7
PICTURE	CH8
VIDEO	CH9
LED		CH10
2018-08-29 14:44:10 +02:00
pascallanger
d9914e95d9 Update Protocols_Details.md 2018-08-29 12:58:54 +02:00
pascallanger
64c79626b4 Update Protocols_Details.md 2018-08-28 16:41:04 +02:00
pascallanger
e047a76855 Update Protocols_Details.md 2018-08-28 16:40:10 +02:00
Pascal Langer
e7449897f9 BUGS new protocol
BUGS new protocol (number 41)
Models: Bugs 3, 6 and 8
Autobind protocol
Telemetry: TX & RX RSSI, Battery voltage good/bad
ARM	CH5
LED		CH6
FLIP		CH7
PICTURE	CH8
VIDEO	CH9
2018-08-28 16:13:28 +02:00
Pascal Langer
db093cf25b Merge branches 'master' and 'master' of https://github.com/pascallanger/DIY-Multiprotocol-TX-Module 2018-08-21 14:58:48 +02:00
Pascal Langer
4bb4bd9792 New protocol WFLY (40)
Use the CYRF6936 RF component
Extended limit supported
No sub protocol
option=number of channels between 4 and 9. If outside of the range default=9.
2018-08-21 14:58:44 +02:00
pascallanger
c16654c8cf WFLY protocol 2018-08-21 14:50:17 +02:00
Ben Lye
817ff7e239 Remove boards files and re-org (#185) 2018-08-17 18:53:31 +01:00
Ben Lye
685de52538 Adding stm32 auto-upload scripts for Windows, Mac, and Linux (#184) 2018-08-16 09:29:47 +01:00
Ben Lye
1dc52773f4 Added step for installing libusb on MacOS 2018-08-14 20:04:34 +01:00
pascallanger
fbb04ea88a Update Compiling_STM32.md 2018-08-12 17:55:57 +02:00
pascallanger
23da318645 Update Compiling_STM32.md 2018-08-12 17:54:40 +02:00
pascallanger
30b77931d7 Jumper serial 2018-08-12 17:50:54 +02:00
pascallanger
39327b2b27 Update Compiling_STM32.md 2018-08-12 17:44:58 +02:00
pascallanger
13c3af96a6 Update Compiling_STM32.md 2018-08-12 17:43:36 +02:00
pascallanger
4411732022 Jumper module serial connection 2018-08-12 17:42:09 +02:00
pascallanger
0c08b8b93b Update Compiling_STM32.md 2018-08-12 17:23:46 +02:00
pascallanger
838755aabf Update Compiling_STM32.md 2018-08-12 17:14:03 +02:00
pascallanger
2bca104e33 Update Compiling_STM32.md 2018-08-12 17:10:13 +02:00
pascallanger
cf857f3256 Simplify Upload 2018-08-12 16:58:55 +02:00
Ben Lye
1647d3d841 Add stm32 serial upload method which includes bootloader (#180) 2018-08-10 20:11:32 +01:00
Pascal Langer
2f5252ab88 Hitec: new sub_protocol to support forward telemetry
OPT_FW (0) : OPTIMA + forward telemetry packets to TX to be decoded
OPT_HUB (1) : OPTIMA + basic telemetry using FrSky Hub format
MINIMA (2) : Minima/Micro/RED
2018-08-09 19:51:07 +02:00
pascallanger
eb89b5be1b Hitec sub_protocols 2018-08-09 19:39:09 +02:00
Ben Lye
e80fe29dba Recreated STM32 board package v1.0.6 to fix Linux executable files. (#179) 2018-08-09 10:07:07 +01:00
Pascal Langer
74ab2a4bd7 _Config.h tweaks 2018-08-09 09:59:30 +02:00
Pascal Langer
edd4f740e0 Hitec correction 2018-08-08 14:54:37 +02:00
Pascal Langer
d0c9bc801b Hitec: typo in telemetry 2018-08-08 12:44:56 +02:00
Pascal Langer
73dd63caa1 Hitec telemetry comments 2018-08-08 00:37:59 +02:00
Pascal Langer
cc4703ea40 Merge branch 'master' of https://github.com/pascallanger/DIY-Multiprotocol-TX-Module 2018-08-08 00:30:25 +02:00
Pascal Langer
f105d7c7eb Hitec full telemetry 2018-08-08 00:30:19 +02:00
pascallanger
e85ad00a46 Update Protocols_Details.md 2018-08-08 00:28:35 +02:00
pascallanger
658dfa4290 Update Protocols_Details.md 2018-08-08 00:25:52 +02:00
pascallanger
df75036501 Update Protocols_Details.md 2018-08-08 00:24:57 +02:00
Pascal Langer
9ab5353122 Hitec full telemetry description 2018-08-07 19:35:31 +02:00
Pascal Langer
5345ece322 Merge branch 'master' of https://github.com/pascallanger/DIY-Multiprotocol-TX-Module 2018-08-07 13:24:52 +02:00
Pascal Langer
9f09c81ef4 Hitec: Minima fix 2018-08-07 13:24:45 +02:00
pascallanger
c8dea20865 Update Troubleshooting.md 2018-08-07 11:16:15 +02:00
Pascal Langer
bf09177916 Hitec improvement
Added 3rd byte of TX ID
Reproduce the F5 frames from original TX
2018-08-06 18:32:39 +02:00
Pascal Langer
d71640ad7e Hitec comments 2018-08-06 01:42:12 +02:00
Pascal Langer
68afcc0c44 Hitec try for Minima
Add F5 packets
2018-08-05 15:46:24 +02:00
Pascal Langer
9b30a3d72a FrSky X: SPORT polling
Mike's corrections to make SPORT working on Taranis.
2018-08-04 23:47:15 +02:00
pascallanger
789cd21618 Add reference to Hitec 2018-08-04 22:27:15 +02:00
Pascal Langer
d9f343e20b Hitec: new protocol
Hitec protocol using the CC2500 RF component
Protocol number: 39
Sub protocols:
 - Optima (0): the TX must be really close to the RX for the bind negociation to complete.
- Minima (1): untested
Optima supports basic telemetry using the FrSky Hub format: RX volt, TX RSSI,&LQI
2018-08-03 18:29:24 +02:00
pascallanger
0b8ff15133 Update Protocols_Details.md 2018-08-03 18:28:48 +02:00
pascallanger
27a4748111 Update Protocols_Details.md 2018-07-23 22:41:28 +02:00
Pascal Langer
18efaef38c Multi 4-in-1 STM32 v1.0.6
Bootloader: Toggle TX invert
2018-07-21 21:53:32 +02:00
Pascal Langer
35137b87ed ... 2018-07-21 10:06:54 +02:00
Pascal Langer
9019c46102 STM32 dual bootloader update
New version of the STM32 dual bootloader:
 - Fix startup issues with OpenTX
 - Auto invert TX if needed
2018-07-21 09:50:29 +02:00
Pascal Langer
52d0869c50 Merge branch 'master' of https://github.com/pascallanger/DIY-Multiprotocol-TX-Module 2018-07-20 19:14:09 +02:00
Pascal Langer
236b375669 Corona: FD_V3 sub protocol
New subprotocol for FlyDream V3 number 2.
2018-07-20 19:13:56 +02:00
pascallanger
9502b5a12a Update Protocols_Details.md 2018-07-20 19:12:59 +02:00
Pascal Langer
ad18856f7a AFHDS2A limit to 12 channels 2018-07-20 19:11:03 +02:00
Pascal Langer
9015b78aaf 1.2.0.21 2018-07-20 15:54:01 +02:00
pascallanger
8cc7a4f693 Update Compiling_STM32.md 2018-07-20 15:50:45 +02:00
pascallanger
ac298fee61 Update Compiling_STM32.md 2018-07-20 15:41:17 +02:00
pascallanger
457fc5296e Update Compiling_STM32.md 2018-07-20 15:39:44 +02:00
pascallanger
b8f3cd1ad8 Update Protocols_Details.md 2018-07-20 15:30:24 +02:00
Pascal Langer
f9f265271a Fix AFHDS2A
Fix bind issue with AFHDS2A
Add frskyd hub telemetry voltage 2 from external battery
Removed cflie warnings...
2018-07-20 15:24:33 +02:00
Arne Schwabe
dde5f6e119 Add the Vantac MPM Lite Board (#173) 2018-06-25 10:28:37 +02:00
Arne Schwabe
add3fb13ef Fix module id returned to be 0 when saved to eeprom (#170)
Also fix that stm32 id is always either 0 or stm32 id
2018-06-12 12:41:38 +02:00
Peter
51c1936c24 Added hardware Jumper 4IN1 and documentation tweak (#163)
* Numbered list since instructions are sequential

* Added 'Jumper JP4IN1' module from Hobbyking.

* Fix table formatting
2018-06-01 13:58:14 +02:00
James Hagerman
07adeaf60d Adding CFlie protocol (#159) 2018-05-04 16:12:04 +02:00
Pascal Langer
811913bf89 Merge branch 'master' of https://github.com/pascallanger/DIY-Multiprotocol-TX-Module 2018-05-04 16:08:34 +02:00
Pascal Langer
8906c85d06 Few modifications 2018-05-04 16:08:29 +02:00
pascallanger
7df5894ca4 Update Protocols_Details.md 2018-03-12 19:09:12 +01:00
slagdang
fa9e559195 Simplify STM32 Linux compilation steps. (#151)
* Update Linux rules to use Maple rules file already available in this project.

* Additional clarification.

* Correct typo.
2018-02-25 09:09:13 +01:00
slagdang
81f408ee77 Added instructions for Ubuntu linux. Added jumper image for IRX4Plus. (#149) 2018-02-19 10:16:04 +01:00
Pascal Langer
aa8a059553 Documenattion: PPM protocol selection 2018-02-11 14:58:30 +01:00
pascallanger
8c7918577d Update Transmitters.md 2018-02-11 14:50:26 +01:00
pascallanger
7219885196 Update Protocols_Details.md 2018-02-11 14:48:49 +01:00
pascallanger
9f8915239f Update Transmitters.md 2018-02-11 14:45:17 +01:00
pascallanger
83401f6e1a Update Transmitters.md 2018-02-11 14:43:32 +01:00
pascallanger
dd686ad9d1 Update Protocols_Details.md 2018-02-11 14:41:00 +01:00
pascallanger
7d04005c72 Update PPM_Setup.md 2018-02-11 14:40:07 +01:00
pascallanger
cdbaeb1c6c Update PPM_Setup.md 2018-02-11 14:38:40 +01:00
pascallanger
6bf432a112 Update PPM_Setup.md 2018-02-11 14:37:59 +01:00
pascallanger
f6ef136502 Update Protocols_Details.md 2018-02-11 14:35:04 +01:00
Pascal Langer
4a9d295f1a More examples in _MyConfig.h.example 2018-01-30 12:53:00 +01:00
pascallanger
105e0bb7a4 Update Protocols_Details.md 2018-01-30 12:04:47 +01:00
Pascal Langer
ab27ee50b0 Introduction of Banks for the switch protocol selection 2018-01-30 12:02:45 +01:00
Pascal Langer
f4a4f67453 Addition of LED2 for iRangeX modules 2018-01-25 11:07:54 +01:00
Pascal Langer
fb88eebc2f Merge branch 'master' of https://github.com/pascallanger/DIY-Multiprotocol-TX-Module 2018-01-24 10:17:27 +01:00
Pascal Langer
6fea0c2a93 Force latest board versions 2018-01-24 10:17:23 +01:00
Ben Lye
301c8da9eb Arduino IDE Board Updates (#142)
* Fix macOS serial upload

* Add verification switch to serial upload scripts

* Fix do_version.bat

Allow parentheses and other special characters in the sketch path

* Fix AVR board linker flags

* Switch to new STM32 dual bootloader

Single bootloader for flash via USB and from TX

* Increment board versions

* Add new board archive files and add new versions to JSON file
2018-01-24 09:07:22 +01:00
Pascal Langer
4facdf0932 FIX OpenTX DSM autodetect 2018-01-22 13:23:11 +01:00
pascallanger
ce489887db Update Protocols_Details.md 2018-01-20 11:12:11 +01:00
pascallanger
55e30bd4aa Update Protocols_Details.md 2018-01-20 10:59:17 +01:00
pascallanger
eb0d03d420 Update Protocols_Details.md 2018-01-19 11:36:40 +01:00
Pascal Langer
db1da2d9cf Corona V1 tweaking 2018-01-10 11:25:07 +01:00
Pascal Langer
6fa3b8597f DSM full throw details 2018-01-09 16:17:17 +01:00
pascallanger
c8da89f0d3 Update Protocols_Details.md 2018-01-09 16:06:56 +01:00
pascallanger
c3c89801e9 Update Protocols_Details.md 2018-01-09 16:06:04 +01:00
Pascal Langer
eb3f8b0d91 DSM max throw config 2018-01-09 16:04:04 +01:00
Pascal Langer
d3285f002e Fix Flysky bug.... 2018-01-09 14:31:58 +01:00
Pascal Langer
e81ee38fa5 DSM: match Spektrum standard for servo throw 2018-01-09 11:56:42 +01:00
Ben Lye
499e854275 Move Arduino IDE boards doc to /doc (#139)
* Create Arduino_IDE_Boards.md
* Update README.md
* Update links to Arduino IDE board instructions (#138)
2018-01-09 08:06:17 +00:00
Pascal Langer
cd235bbcde Removed PPM 125% statements 2018-01-09 09:04:55 +01:00
Pascal Langer
984aa3f413 Switch all protocols to use a resolution of 2048
- Change how PPM is handled with a resolution of 2048 and scaled to match serial input range. PPM is now fully scaled for all protocols which was not the case before. If you are using PPM, you might have to adjust the end points depending on the protocols.
 - Change all range conversions to use 2048 where possible
 - Updated all protocols with new range functions
 - Protocols which are taking advantage of 2048 are Assan, FrSky V/D/X, DSM, Devo, WK2x01
 - Renamed AUX xto CHx for code readbility
2018-01-08 19:37:14 +01:00
Pascal Langer
11287cb9c0 Corona bind timing 2018-01-08 10:21:13 +01:00
Pascal Langer
5cc49a8862 A7105 dynamic tuning on channel 15 2018-01-04 14:37:05 +01:00
Pascal Langer
fabda76e98 Merge branch 'master' of https://github.com/pascallanger/DIY-Multiprotocol-TX-Module 2018-01-03 13:05:04 +01:00
Pascal Langer
70db505dd9 New Corona protocol and autobind bug fix 2018-01-03 13:04:58 +01:00
pascallanger
29fd1c800b Update Compiling.md 2018-01-03 10:19:05 +01:00
Pascal Langer
d70d8f62a4 Frequency tuning page 2018-01-02 22:08:22 +01:00
Pascal Langer
bef562964d Revert "Merge branch 'Pascal' into master"
This reverts commit fc5495b6d1, reversing
changes made to f3838ae4b0.
2017-12-30 05:32:43 +01:00
midelic
fc5495b6d1 Merge branch 'Pascal' into master 2017-12-24 20:24:59 +01:00
midelic
3e004d01ec add files 2017-12-01 05:02:48 +02:00
midelic
21266d0a17 Delete StmMultiUSB.bin 2017-12-01 04:37:46 +02:00
midelic
2b62b8dab3 Delete StmMultiBoot.bin 2017-12-01 04:37:39 +02:00
midelic
b24564ffe9 Add files via upload 2017-12-01 04:35:35 +02:00
midelic
f57d436640 Add files via upload 2017-12-01 04:32:16 +02:00
midelic
762613bd7f Add files via upload 2017-12-01 04:29:00 +02:00
midelic
e2ed752b51 add BootLoader folder 2017-12-01 04:27:49 +02:00
midelic
2610926f47 Delete StmBoot.ino.generic_stm32f103c.bin 2017-12-01 02:49:11 +02:00
midelic
cf1a74e532 Delete system_stm32f10x.h 2017-12-01 02:48:59 +02:00
midelic
f55b451d9b Delete stm32f10x_flash.h 2017-12-01 02:48:52 +02:00
midelic
ae51e389ca Delete stm32f10x_flash.cpp 2017-12-01 02:48:41 +02:00
midelic
6f71ef1d03 Delete stm32f10x.h 2017-12-01 02:48:30 +02:00
midelic
94a9e4db05 Delete stk500.h 2017-12-01 02:48:16 +02:00
midelic
82dc0c4f32 Delete how to use.txt 2017-12-01 02:48:07 +02:00
midelic
bb5827629e Delete core_cm3.h 2017-12-01 02:47:58 +02:00
midelic
76f7cb7126 Delete StmBoot.ino 2017-12-01 02:47:47 +02:00
midelic
d5005323d4 Delete README.md 2017-12-01 02:47:31 +02:00
midelic
9bc1a9963f Delete package_MULTI_index.json 2017-12-01 02:47:06 +02:00
midelic
cefbf2ee70 Delete package_MULTI2_index.json 2017-12-01 02:46:19 +02:00
midelic
f13701b120 SymaX impove rates in headless mode. 2017-11-14 12:15:08 +02:00
midelic
5f7c598a34 fix compile error for avr module when commented FrSkyX protocol 2017-11-06 17:45:14 +01:00
midelic
defd354286 Fix AFHDS2A failsafe problem 2017-11-04 20:43:56 +01:00
midelic
f9e6b30550 Fix AFHDS2A failsafe problem 2017-11-04 20:40:20 +01:00
midelic
d451af365a Fix telemetry FrSkyX protocol 2017-11-04 17:14:29 +01:00
midelic
57a78535f2 updated version number 2017-10-20 17:06:45 +01:00
midelic
f824ecb7f9 update Compiling_STM32 doc_3 2017-08-04 17:50:04 +03:00
midelic
98f848138d Updated Compiling_STM32 doc_2 2017-08-03 22:45:15 +03:00
midelic
200a1dc3da updated Compiling_STM32 doc 2017-08-03 22:04:29 +03:00
midelic
507e1d2b50 Updated Compiling_STM32 with flashing with TX method 2017-08-03 21:58:56 +03:00
midelic
0f752e2571 Add STM32 bootloader files_2 2017-08-03 18:55:04 +03:00
midelic
ca6cd65d46 Revert "Revert "Add STM32 bootloader files""
This reverts commit ddc287a84e.
2017-08-03 18:41:06 +03:00
midelic
ddc287a84e Revert "Add STM32 bootloader files"
This reverts commit c92ec031ae.
2017-08-03 18:40:03 +03:00
midelic
c92ec031ae Add STM32 bootloader files 2017-08-03 18:39:21 +03:00
midelic
ef2d4d6b12 Add flashing with TX for STM32_board 2017-07-31 22:21:41 +03:00
midelic
2753f6c4e5 added Mike Blandord modifications
- used bootloader to flash multi-module with TX
-updated  FrslyX protocol telemetry sequence
2017-07-28 23:39:51 +03:00
midelic
021577d638 Merge pull request #6 from pascallanger/master
sync main branch
2017-07-26 13:57:09 +03:00
midelic
040354501c Merge pull request #5 from pascallanger/master
sync with base
2017-04-24 20:23:02 +01:00
1239 changed files with 146829 additions and 141939 deletions

12
.github/FUNDING.yml vendored Normal file
View File

@@ -0,0 +1,12 @@
# These are supported funding model platforms
github: [pascallanger]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=VF2K9T23DRY56&lc=US&item_name=DIY%20Multiprotocol&currency_code=EUR&bn=PP%2dDonationsBF%3abtn_donate_SM%2egif%3aNonHosted

378
.github/workflows/main.yml vendored Normal file
View File

@@ -0,0 +1,378 @@
# Workflow for testing MULTI-Module firmware builds
name: MULTI Test, Build, Deploy, Release
on:
# Trigger the workflow on pushes, except those that are tagged (avoids double-testing releases)
push:
branches:
- '**'
tags-ignore:
- '**'
paths:
- '.github/workflows/**'
- 'buildroot/bin/**'
- 'Multiprotocol/**'
# Trigger the workflow on pull requests to the master branch
pull_request:
branches:
- master
paths:
- '.github/workflows/**'
- 'buildroot/bin/**'
- 'Multiprotocol/**'
# Triggers the workflow on release creation
release:
types:
- created
# Allows the workflow to be triggered manually from the Actions tab
workflow_dispatch:
jobs:
test:
runs-on: ubuntu-latest
# Configure the board matrix
strategy:
fail-fast: false
matrix:
include:
- board: "multi4in1:avr:multiatmega328p:bootloader=none"
name: "ATmega328p"
- board: "multi4in1:avr:multiatmega328p:bootloader=optiboot"
name: "ATmega328p (Optiboot)"
- board: "multi4in1:avr:multixmega32d4"
name: "OrangeRX"
- board: "multi4in1:STM32F1:multistm32f103c8:debug_option=none"
name: "STM32F103 (64KB)"
- board: "multi4in1:STM32F1:multistm32f103cb:debug_option=none"
name: "STM32F103 (128KB)"
- board: "multi4in1:STM32F1:multistm32f103cb:debug_option=native"
name: "STM32F103 (128KB, USB Debug)"
- board: "multi4in1:STM32F1:multistm32f103cb:debug_option=ftdi"
name: "STM32F103 (128KB, Serial Debug)"
- board: "multi4in1:STM32F1:multi5in1t18int"
name: "T18 5-in-1 (128KB)"
# Set the build name using the friendly board name
name: "[Test] ${{ matrix.name }}"
# Set the environment variables
env:
BOARD: ${{ matrix.board }}
steps:
- uses: actions/checkout@v4
- name: Install Arduino CLI
uses: arduino/setup-arduino-cli@v1.1.2
with:
version: "0.32.2"
- name: Prepare build environment
run: |
echo "Github Ref: $GITHUB_REF"
echo "Event name: ${{ github.event_name }}"
echo "Event action: ${{ github.event.action }}"
echo "Tag name: ${{ github.event.release.tag_name }}"
arduino-cli config init --additional-urls https://raw.githubusercontent.com/pascallanger/DIY-Multiprotocol-TX-Module-Boards/master/package_multi_4in1_board_index.json,https://raw.githubusercontent.com/pascallanger/DIY-Multiprotocol-TX-Module-Boards/devel/source/package_multi_4in1_board_devel_index.json
arduino-cli core update-index
if [[ "$BOARD" =~ ":avr:" ]]; then
arduino-cli core install arduino:avr;
fi
if [[ "$BOARD" =~ "multi4in1-devel:avr" ]]; then
arduino-cli core install multi4in1-devel:avr
elif [[ "$BOARD" =~ "multi4in1:avr" ]]; then
arduino-cli core install multi4in1:avr
fi
if [[ "$BOARD" =~ "multi4in1-devel:STM32F1:" ]]; then
arduino-cli core install multi4in1-devel:STM32F1
elif [[ "$BOARD" =~ "multi4in1:STM32F1:" ]]; then
arduino-cli core install multi4in1:STM32F1
fi
chmod +x ${GITHUB_WORKSPACE}/buildroot/bin/*
echo "${GITHUB_WORKSPACE}/buildroot/bin" >> $GITHUB_PATH
mkdir ./build
mkdir ./binaries
- name: Configure MULTI-Module firmware options
run: |
# Load the build functions
source ./buildroot/bin/buildFunctions;
# Get the version
getMultiVersion
echo "MULTI_VERSION=$(echo $MULTI_VERSION)" >> $GITHUB_ENV
# Get all the protocols for this board
getAllProtocols
echo "A7105_PROTOCOLS=$(echo $A7105_PROTOCOLS)" >> $GITHUB_ENV
echo "CC2500_PROTOCOLS=$(echo $CC2500_PROTOCOLS)" >> $GITHUB_ENV
echo "CYRF6936_PROTOCOLS=$(echo $CYRF6936_PROTOCOLS)" >> $GITHUB_ENV
echo "NRF24L01_PROTOCOLS=$(echo $NRF24L01_PROTOCOLS)" >> $GITHUB_ENV
echo "SX1276_PROTOCOLS=$(echo $SX1276_PROTOCOLS)" >> $GITHUB_ENV
echo "CCNRF_INO_PROTOCOLS=$(echo $CCNRF_INO_PROTOCOLS)" >> $GITHUB_ENV
echo "ALL_PROTOCOLS=$(echo $ALL_PROTOCOLS)" >> $GITHUB_ENV
# Get all the RF modules for this board
getAllRFModules
echo "ALL_RFMODULES=$(echo $ALL_RFMODULES)" >> $GITHUB_ENV
# Disable CHECK_FOR_BOOTLOADER when not needed
if [[ "$BOARD" =~ ":avr:multiatmega328p:bootloader=none" ]]; then
opt_disable CHECK_FOR_BOOTLOADER;
fi
# Trim the build down for the Atmega328p board
if [[ "$BOARD" =~ ":avr:multiatmega328p:" ]]; then
opt_disable $ALL_PROTOCOLS
opt_enable FRSKYX_CC2500_INO AFHDS2A_A7105_INO MJXQ_NRF24L01_INO DSM_CYRF6936_INO;
fi
# Trim the enabled protocols down for the STM32F103CB board with debugging or the STM32F103C8 board in general
if [[ "$BOARD" =~ ":STM32F1:multistm32f103cb:debug_option=ftdi" ]] || [[ "$BOARD" =~ ":STM32F1:multistm32f103cb:debug_option=native" ]] || [[ "$BOARD" =~ ":STM32F1:multistm32f103c8" ]]; then
opt_disable $ALL_PROTOCOLS;
opt_enable FRSKYX_CC2500_INO AFHDS2A_A7105_INO MJXQ_NRF24L01_INO DSM_CYRF6936_INO;
fi
- name: Save default firmware configuration
run: |
cat Multiprotocol/_Config.h
cp Multiprotocol/_Config.h ./_Config.h.bak
- name: Build default configuration
run: |
# Skip the default build for boards where it's too large now
if [[ "$BOARD" =~ ":STM32F1:multistm32f103cb:debug_option=none" ]] || [[ "$BOARD" =~ ":STM32F1:multi5in1t18int" ]]; then
printf "Not testing default build for $BOARD.";
else
source ./buildroot/bin/buildFunctions;
buildMulti
fi
- name: Build serial only
run: |
# Skip the serial-only build for boards where it's too large now
if [[ "$BOARD" =~ ":STM32F1:multistm32f103cb:debug_option=none" ]] || [[ "$BOARD" =~ ":STM32F1:multi5in1t18int" ]]; then
printf "Not testing serial-only build for $BOARD.";
else
source ./buildroot/bin/buildFunctions;
cp ./_Config.h.bak Multiprotocol/_Config.h
opt_disable ENABLE_PPM;
buildMulti;
fi
- name: Build PPM only
run: |
# Skip the PPM-only build for boards where it's too large now
if [[ "$BOARD" =~ ":STM32F1:multistm32f103cb:debug_option=none" ]] || [[ "$BOARD" =~ ":STM32F1:multi5in1t18int" ]]; then
printf "Not testing PPM-only build for $BOARD.";
else
source ./buildroot/bin/buildFunctions;
cp ./_Config.h.bak Multiprotocol/_Config.h
opt_disable ENABLE_SERIAL;
buildMulti;
fi
- name: Build each RF module individually
run: |
# Skip the per-RF module builds for boards which have fixed modules
if [[ "$BOARD" =~ ":STM32F1:multi5in1t18int" ]]; then
printf "Not testing individual RF module builds for $BOARD.";
else
source ./buildroot/bin/buildFunctions;
cp ./_Config.h.bak Multiprotocol/_Config.h;
buildEachRFModule;
fi
- name: Build each protocol individually
run: |
source ./buildroot/bin/buildFunctions;
cp ./_Config.h.bak Multiprotocol/_Config.h;
buildEachProtocol;
build:
runs-on: ubuntu-latest
# Configure the board matrix
strategy:
fail-fast: false
matrix:
include:
- board: "multi4in1:avr:multiatmega328p:bootloader=none"
name: "ATmega328p"
release: "atmega328p"
- board: "multi4in1:avr:multiatmega328p:bootloader=optiboot"
name: "ATmega328p (Optiboot)"
release: "atmega328p-optiboot"
- board: "multi4in1:avr:multixmega32d4"
name: "OrangeRX"
release: "orangerx"
- board: "multi4in1:STM32F1:multistm32f103c8:debug_option=none"
name: "STM32F103 CC2500 (64KB)"
release: "stm32f103-cc2500-64k"
- board: "multi4in1:STM32F1:multistm32f103cb:debug_option=none"
name: "STM32F103 CC2500 (128KB)"
release: "stm32f103-cc2500-128k"
- board: "multi4in1:STM32F1:multistm32f103cb:debug_option=none"
name: "STM32F103 (128KB)"
release: "stm32f103-128k-4in1"
- board: "multi4in1:STM32F1:multistm32f103cb:debug_option=native"
name: "STM32F103 (128KB, USB Debug)"
release: "stm32f103-128k-usb-debug"
- board: "multi4in1:STM32F1:multistm32f103cb:debug_option=ftdi"
name: "STM32F103 (128KB, Serial Debug)"
release: "stm32f103-128k-serial-debug"
- board: "multi4in1:STM32F1:multistm32f103cb:debug_option=none"
name: "STM32F103 5-in-1 (128KB)"
release: "stm32f103-128k-5in1"
- board: "multi4in1:STM32F1:multistm32f103cb:debug_option=none"
name: "T-Lite 5-in-1 (128KB)"
release: "tlite-5in1"
- board: "multi4in1:STM32F1:multi5in1t18int"
name: "T18 5-in-1 (128KB)"
release: "t18-5in1"
- board: "none"
name: "Scripts"
release: "scripts"
# Set the build name using the friendly board name
name: "[Build] ${{ matrix.name }}"
# Set the environment variables
env:
BOARD: ${{ matrix.board }}
RELEASE: ${{ matrix.release }}
steps:
- uses: actions/checkout@v4
- name: Install Arduino CLI
uses: arduino/setup-arduino-cli@v1.1.2
with:
version: "0.32.2"
- name: Prepare build environment
run: |
echo "Github Ref: $GITHUB_REF"
echo "Event name: ${{ github.event_name }}"
echo "Event action: ${{ github.event.action }}"
echo "Tag name: ${{ github.event.release.tag_name }}"
arduino-cli config init --additional-urls https://raw.githubusercontent.com/pascallanger/DIY-Multiprotocol-TX-Module-Boards/master/package_multi_4in1_board_index.json,https://raw.githubusercontent.com/pascallanger/DIY-Multiprotocol-TX-Module-Boards/devel/source/package_multi_4in1_board_devel_index.json
arduino-cli core update-index
if [[ "$BOARD" =~ ":avr:" ]]; then
arduino-cli core install arduino:avr;
fi
if [[ "$BOARD" =~ "multi4in1-devel:avr" ]]; then
arduino-cli core install multi4in1-devel:avr
elif [[ "$BOARD" =~ "multi4in1:avr" ]]; then
arduino-cli core install multi4in1:avr
fi
if [[ "$BOARD" =~ "multi4in1-devel:STM32F1:" ]]; then
arduino-cli core install multi4in1-devel:STM32F1
elif [[ "$BOARD" =~ "multi4in1:STM32F1:" ]]; then
arduino-cli core install multi4in1:STM32F1
fi
chmod +x ${GITHUB_WORKSPACE}/buildroot/bin/*
echo "${GITHUB_WORKSPACE}/buildroot/bin" >> $GITHUB_PATH
mkdir ./build
mkdir ./binaries
- name: Configure MULTI-Module firmware options
run: |
# Load the build functions
source ./buildroot/bin/buildFunctions;
# Get the version
getMultiVersion
echo "MULTI_VERSION=$(echo $MULTI_VERSION)" >> $GITHUB_ENV
# Get all the protocols for this board
getAllProtocols
echo "A7105_PROTOCOLS=$(echo $A7105_PROTOCOLS)" >> $GITHUB_ENV
echo "CC2500_PROTOCOLS=$(echo $CC2500_PROTOCOLS)" >> $GITHUB_ENV
echo "CYRF6936_PROTOCOLS=$(echo $CYRF6936_PROTOCOLS)" >> $GITHUB_ENV
echo "NRF24L01_PROTOCOLS=$(echo $NRF24L01_PROTOCOLS)" >> $GITHUB_ENV
echo "SX1276_PROTOCOLS=$(echo $SX1276_PROTOCOLS)" >> $GITHUB_ENV
echo "CCNRF_INO_PROTOCOLS=$(echo $CCNRF_INO_PROTOCOLS)" >> $GITHUB_ENV
echo "ALL_PROTOCOLS=$(echo $ALL_PROTOCOLS)" >> $GITHUB_ENV
# Disable CHECK_FOR_BOOTLOADER when not needed
if [[ "$BOARD" =~ ":avr:multiatmega328p:bootloader=none" ]]; then
opt_disable CHECK_FOR_BOOTLOADER;
fi
- name: Save default firmware configuration
run: |
cat Multiprotocol/_Config.h
cp Multiprotocol/_Config.h ./_Config.h.bak
- name: Build release files
run: |
source ./buildroot/bin/buildFunctions;
cp ./_Config.h.bak Multiprotocol/_Config.h;
buildReleaseFiles;
ls -al ./binaries;
NUM_FILES=$(ls -l ./binaries | grep ^- | wc -l);
if [ $NUM_FILES -gt 0 ]; then
echo "HAVE_FILES=true" >> $GITHUB_ENV
else
echo "HAVE_FILES=false" >> $GITHUB_ENV
fi
- name: 'Upload Artifacts'
if: env.HAVE_FILES == 'true'
uses: actions/upload-artifact/@v4
with:
name: multi-${{ matrix.release }}
path: ./binaries/
deploy:
name: "[Deploy] Attach Build Artifacts"
runs-on: ubuntu-latest
needs: [test, build]
steps:
- name: Combine and upload build artifacts
uses: actions/upload-artifact/merge@v4
with:
name: multi-test-build
pattern: multi-*
delete-merged: true
retention-days: 90
release:
name: "[Release] Publish Files to Release"
if: github.event_name == 'release' && github.event.action == 'created'
runs-on: ubuntu-latest
needs: deploy
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: multi-test-build
path: ./artifacts/
- name: Display downloaded artifacts
run: ls -R ./artifacts/
- name: Deploy artifacts to release
uses: AButler/upload-release-assets@v3.0
with:
files: './artifacts/*'
repo-token: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -0,0 +1,11 @@
@echo off
echo Installing MULTI-Module DFU Bootloader Driver...
"%~dp0wdi-simple" --vid 0x1EAF --pid 0x0003 --type 2 --name "MULTI-Module DFU Bootloader" --dest "%~dp0MULTI-DFU-Bootloader" -b
echo.
echo Installing MULTI-Module USB Serial Driver...
"%~dp0wdi-simple" --vid 0x1EAF --pid 0x0004 --type 3 --name "MULTI-Module USB Serial" --dest "%~dp0MULTI-USB-Serial" -b
echo.
pause

File diff suppressed because it is too large Load Diff

View File

@@ -1,84 +0,0 @@
# See: https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification
# See: http://code.google.com/p/arduino/wiki/Platforms
##############################################################
menu.bootloader=Bootloader
##############################################################
## Multi 4-in-1 (3.3V, 16 MHz) w/ ATmega328p
## --------------------------------------------------
multiatmega328p.name=Multi 4-in-1 (Atmega328p, 3.3V, 16MHz)
multiatmega328p.upload.tool=arduino:avrdude
multiatmega328p.upload.protocol=arduino
multiatmega328p.upload.speed=57600
multiatmega328p.upload.maximum_data_size=2048
multiatmega328p.build.mcu=atmega328p
multiatmega328p.build.f_cpu=16000000L
multiatmega328p.build.core=arduino:arduino
multiatmega328p.build.variant=arduino:eightanaloginputs
multiatmega328p.build.extra_flags=-Wl,--relax
multiatmega328p.build.board=MULTI_AVR=102
multiatmega328p.board.compiler.c.flags=-c -g -Os {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -MMD -flto -fno-fat-lto-objects
multiatmega328p.board.compiler.c.elf.flags=-Os -g -flto -fuse-linker-plugin -Wl,--gc-sections
multiatmega328p.board.compiler.S.flags=-c -g -x assembler-with-cpp -flto -MMD
multiatmega328p.board.recipe.output.save_file=multi-avr.hex
multiatmega328p.board.tools.avrdude.config.path={path}/etc/avrdude.conf
multiatmega328p.board.tools.avrdude.erase.pattern="{cmd.path}" "-C{config.path}" {erase.verbose} -p{build.mcu} -c{protocol} {program.extra_params} -e -Ulock:w:{bootloader.unlock_bits}:m -Uefuse:w:{bootloader.extended_fuses}:m -Uhfuse:w:{bootloader.high_fuses}:m -Ulfuse:w:{bootloader.low_fuses}:m
multiatmega328p.board.tools.avrdude.bootloader.pattern="{cmd.path}" "-C{config.path}" {bootloader.verbose} -p{build.mcu} -c{protocol} {program.extra_params} "-Uflash:w:{runtime.platform.path}/bootloaders/{bootloader.file}:i" -Ulock:w:{bootloader.lock_bits}:m
multiatmega328p.bootloader.tool=arduino:avrdude
multiatmega328p.bootloader.low_fuses=0xFF
multiatmega328p.bootloader.extended_fuses=0xFD
multiatmega328p.bootloader.unlock_bits=0x3F
multiatmega328p.bootloader.lock_bits=0x0F
multiatmega328p.menu.bootloader.none=No bootloader
multiatmega328p.menu.bootloader.none.build.board=MULTI_NO_BOOT=102
multiatmega328p.menu.bootloader.none.upload.maximum_size=32768
multiatmega328p.menu.bootloader.none.bootloader.file=Multi4in1/AtmegaMultiEmpty.hex
multiatmega328p.menu.bootloader.none.bootloader.high_fuses=0xD7
multiatmega328p.menu.bootloader.optiboot=Flash from TX
multiatmega328p.menu.bootloader.optiboot.build.board=MULTI_FLASH_FROM_TX=102
multiatmega328p.menu.bootloader.optiboot.upload.maximum_size=32256
multiatmega328p.menu.bootloader.optiboot.bootloader.file=Multi4in1/AtmegaMultiBoot.hex
multiatmega328p.menu.bootloader.optiboot.bootloader.high_fuses=0xD6
##############################################################
##############################################################
## Multi 4-in-1 (OrangeRX)
## --------------------------------------------------
multixmega32d4.name=Multi 4-in-1 (OrangeRX)
multixmega32d4.build.board=MULTI_ORANGERX=102
multixmega32d4.build.mcu=atxmega32d4
multixmega32d4.build.f_cpu=32000000L
multixmega32d4.build.core=xmega
multixmega32d4.build.variant=xmega32d4
multixmega32d4.upload.tool=arduino:avrdude
multixmega32d4.upload.protocol=avrispmkii
multixmega32d4.upload.maximum_size=32768
multixmega32d4.upload.speed=57600
multixmega32d4.bootloader.tool=arduino:avrdude
multixmega32d4.bootloader.file=Multi4in1/OrangeMultiBoot.hex
multixmega32d4.bootloader.lock_bits=0xFF
multixmega32d4.board.compiler.c.flags=-c -g -Os {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -MMD -flto
multixmega32d4.board.compiler.c.elf.flags=-Os -flto -Wl,--gc-sections
multixmega32d4.board.compiler.S.flags=-c -g -x assembler-with-cpp -flto
multixmega32d4.board.recipe.output.save_file=multi-orx.hex
multixmega32d4.board.tools.avrdude.config.path={runtime.platform.path}/avrdude_xmega.conf
multixmega32d4.board.tools.avrdude.erase.pattern="{cmd.path}" "-C{config.path}" {erase.verbose} -p{build.mcu} -c{protocol} {program.extra_params} -e -Ulock:w:{bootloader.unlock_bits}:m -Ufuse1:w:{bootloader.fuse1}:m -Ufuse2:w:{bootloader.fuse2}:m -Ufuse4:w:{bootloader.fuse4}:m -Ufuse5:w:{bootloader.fuse5}:m
multixmega32d4.board.tools.avrdude.bootloader.pattern="{cmd.path}" "-C{config.path}" {bootloader.verbose} -p{build.mcu} -c{protocol} {program.extra_params} "-Uboot:w:{runtime.platform.path}/bootloaders/{bootloader.file}:i" -Ulock:w:{bootloader.lock_bits}:m
##############################################################

View File

@@ -1,34 +0,0 @@
:107E0000112484B714BE9FEF9BB99CE395B991E010
:107E100098B98370A9F08AEF80938500109284004E
:107E200085E08093810096BBB09BFECF10928100CD
:107E300093B186B181709C73892B8D3109F0B3D0D9
:107E400082E08093C00088E18093C10086E0809347
:107E5000C20081E28093C400259AC0E0D0E093E0A4
:107E6000F92EEE24E39425E0D22E31E1C32EA9D0E1
:107E7000813481F4A6D08EBBABD08EB3823811F49E
:107E800085E006C08EB3813811F484E001C083E040
:107E900091D086C0823411F484E103C0853419F492
:107EA00085E09DD07DC0853541F48BD0C82F89D029
:107EB000D0E0D82BCC0FDD1F72C0863521F484E0D2
:107EC0008ED080E0E5CF843609F03DC07AD079D0FD
:107ED000B82E77D0C11520E7D20718F000E011E0E6
:107EE00004C0FE01F7BEE895F9CF6BD0F80181938D
:107EF0008F01BE12FACFCE01905781159E4018F423
:107F0000FE01F7BEE89564D0C115FEE7DF0708F073
:107F100047C007B600FCFDCFFE01A0E0B1E08D91A7
:107F20009D910C01E7BEE89511243296A03821E01E
:107F3000B207A9F7FE01D7BEE89507B600FCFDCF52
:107F4000C7BEE8952DC08437B1F43BD03AD0B82EE7
:107F500038D03ED0FE01AC2EAB0C8F010F5F1F4F0F
:107F6000849128D0A01205C02196BA94CB0DD11DC2
:107F700017C0F801F2CF853739F42AD08EE11AD034
:107F800085E918D08FE084CF813549F421D080E194
:107F900011D08091C00086FFFCCF05D001C018D061
:107FA00080E108D064CFE0E0F0E084918F3F09F0F9
:107FB000099408959091C00095FFFCCF8093C6006E
:107FC00008958091C00087FFFCCF8091C60008957E
:107FD000F8DF803211F085E1EDDF84E1EBCFCF9364
:107FE000C82FEFDFC150E9F7CF91F2CFA8950895E0
:0C7FF000E0E6F0E098E1908380830895C3
:0400000300007E007B
:00000001FF

View File

@@ -1,2 +0,0 @@
:02000000FFFF00
:00000001FF

View File

@@ -1,47 +0,0 @@
:108000001F92CDB7DEB7CFD01124809178009FEFBB
:1080100090937800837099F088EA91E680936808DD
:108020009093690880E180934C0880914C0884FF0C
:10803000FCCF109240088091680682FD8FD082E0CC
:1080400080936106C12CD12C97D0813479F494D0DF
:10805000898399D08981823811F485E005C08138FF
:1080600011F484E001C083E080D075C0823411F443
:1080700084E103C0853419F485E08CD06CC085356B
:1080800059F47AD0C82E78D0D12CD82A8D2D881FBB
:108090008827881F8BBF5EC0863521F484E07AD0A4
:1080A00080E0E2CF843641F567D066D0F82E64D008
:1080B000C601DCD000E010E25FD0F80181938F01AF
:1080C000FE12FACF60D0D7FC46C0CBD0C601DAD0C2
:1080D000760100E010E2F801619171918F01C70112
:1080E000DBD0F2E0EF0EF11C011581E2180799F7E1
:1080F000C601E0D0B6D02FC08437C1F43DD03CD00B
:10810000F82E3AD040D0F601EC2CEF0C8F010F5F27
:108110001F4F84912AD0E01207C0EFEFCE1ADE0A7B
:10812000FA94CF0CD11C17C0F801F0CF853739F481
:108130002AD08EE11AD085E918D082E495CF813516
:1081400049F421D080E111D08091A10886FFFCCFB5
:1081500005D001C018D080E108D076CFE0E0F0E093
:1081600084918F3F09F0099408959091A10895FF9B
:10817000FCCF8093A00808958091A10887FFFCCFD1
:108180008091A0080895F8DF803211F085E1EDDFDD
:1081900084E1EBCFCF93C82FEFDFC150E9F7CF9148
:1081A000F2CFA895089583EC8093520080915000FF
:1081B0008860809350008091510083FFFCCF82EC57
:1081C0008093550080915000806180935000809191
:1081D000510084FFFCCF88ED84BF1092400084BF23
:1081E00024E02093400087E08093A20087E88093FA
:1081F0008301109241081092420810924308109295
:10820000440810924608109247088FEF9FEF809322
:1082100066089093670810926008109261088BE0DE
:1082200080934008209365062093620688E180933E
:10823000720698E0909345069093410692E29093DF
:10824000A6081092A7088093A4088091A3088F7CA9
:1082500080618093A30883E08093A5088091A008A3
:1082600008958091CF0187FDFCCF08958F939F9350
:1082700082E2E0ECF1E08287FF91EF918DE984BF2B
:10828000E8950895FC0186E28093CA0188ED84BFD9
:1082900081E08093CB0108950F921F92FC01062E7E
:1082A000172E83E28093CA018DE984BFE8951F9061
:1082B0000F900895FC018EE28093CA018DE984BF7E
:0482C000E8950895A0
:040000030000800079
:00000001FF

View File

@@ -1,450 +0,0 @@
/*
Arduino.h - standard definitions for Arduino build environment
Part of Arduino - http://www.arduino.cc/
Copyright (c) 2007 David A. Mellis [duplicated from pins_arduino.h, not present in original]
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
Boston, MA 02111-1307 USA
Updated for 'xmega' core by bob frazier, S.F.T. Inc. - http://mrp3.com/
for the XMegaForArduino project - http://github.com/XMegaForArduino
In some cases, the xmega updates make assumptions about the pin assignments.
See 'pins_arduino.h' for more detail.
*/
#ifndef Arduino_h
#define Arduino_h
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <avr/pgmspace.h>
#include <avr/io.h>
#include <avr/interrupt.h>
#include "binary.h"
#ifdef __cplusplus
extern "C"{
#endif // __cplusplus
#define HIGH 0x1
#define LOW 0x0
#define INPUT 0x0 /* totem poll, input */
#define OUTPUT 0x1 /* totem poll, output */
#define INPUT_BUS_KEEPER 0x2 /* weak pull up/down to maintain state when switched to or in input mode */
#define INPUT_PULLUP 0x3 /* pullup resistor on input */
#define INPUT_PULLDOWN 0x4 /* pulldown resistor on input */
#define OUTPUT_OR 0x5 /* output open drain 'or', no pulldown */
#define OUTPUT_AND 0x6 /* output open drain 'and', no pullup */
#define INPUT_OR_PULLDOWN 0x7 /* output open drain 'or' with pulldown */
#define INPUT_AND_PULLUP 0x8 /* output open drain 'and' with pullup */
#define OUTPUT_OR_PULLDOWN 0x9 /* output open drain 'or' with pulldown */
#define OUTPUT_AND_PULLUP 0xa /* output open drain 'and' with pullup */
#define INPUT_OUTPUT_MASK 0xf /* mask for INPUT/OUTPUT flags */
#define INPUT_SENSE_DEFAULT 0 /* input sense default - currently 'BOTH' */
#define INPUT_SENSE_RISING 0x10 /* just rising */
#define INPUT_SENSE_FALLING 0x20 /* just falling */
#define INPUT_SENSE_BOTH 0x30 /* rising AND falling */
#define INPUT_SENSE_LEVEL 0x40 /* high level (or low if I invert it) */
#define INPUT_SENSE_DISABLED 0x50 /* buffered input disabled (most pins won't be able to use 'IN' if you do this) */
#define INPUT_SENSE_MASK 0x70 /* mask for 'input sense' bits */
#define INPUT_OUTPUT_INVERT 0x80 /* bit for 'inverted' I/O - note that digitalRead and digitalWrite will re-invert to maintain consistency */
// NOTE: 'INPUT_OUTPUT_INVER' is primarily there to support LOW LEVEL interrupts. if you specify this flag for normal
// digital I/O, there will be no 'visible effect' since digitalRead and digitalWrite will "re-invert" the bit value
// and act as if the invert flag weren't set. That way, if you select 'LOW LEVEL' interrupt, you will read the
// low level as a '0' (as it should be) via digitalRead, even though the value MUST be inverted for this to work.
// NOTE: the values of 'true' and 'false' should be defined by C++ already
#define true /*0x1*/(!0) /* rather than '1' true is defined as '!0' - it's logically accurate */
#define false 0x0
#define PI 3.1415926535897932384626433832795
#define HALF_PI 1.5707963267948966192313216916398
#define TWO_PI 6.283185307179586476925286766559
#define DEG_TO_RAD 0.017453292519943295769236907684886
#define RAD_TO_DEG 57.295779513082320876798154814105
/* I do not know what these next 4 #defines do, but all 4 seem to be WRONG - bf */
#define SERIAL 0x0
#define DISPLAY 0x1
#define LSBFIRST 0
#define MSBFIRST 1
// INTERRUPT TYPE - LOW, HIGH, CHANGE, FALLING, RISING (compatibility with DUE etc.)
// 'LOW' is defined as '0' already
// 'HIGH' is defined as '1' already
#define CHANGE 2
#define FALLING 3
#define RISING 4
// definitions for atmega328 etc. carried forward - not sure what this is for
#define INTERNAL 3
#define DEFAULT 1
#define EXTERNAL 0
// undefine stdlib's abs if encountered (from 'arduino' version)
#ifdef abs
#undef abs
#endif
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define abs(x) ((x)>0?(x):-(x))
#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))
#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))
#define radians(deg) ((deg)*DEG_TO_RAD)
#define degrees(rad) ((rad)*RAD_TO_DEG)
#define sq(x) ((x)*(x))
#define interrupts() sei()
#define noInterrupts() cli()
#define clockCyclesPerMicrosecond() ( F_CPU / 1000000L )
#define clockCyclesToMicroseconds(a) ( (a) / clockCyclesPerMicrosecond() )
#define microsecondsToClockCycles(a) ( (a) * clockCyclesPerMicrosecond() )
#define lowByte(w) ((uint8_t) ((w) & 0xff))
#define highByte(w) ((uint8_t) ((w) >> 8))
#define bitRead(value, bit) (((value) >> (bit)) & 0x01)
#define bitSet(value, bit) ((value) |= (1UL << (bit)))
#define bitClear(value, bit) ((value) &= ~(1UL << (bit)))
#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit))
typedef unsigned int word;
#define bit(b) (1UL << (b))
typedef uint8_t boolean;
typedef uint8_t byte;
void init(void);
void initVariant(void);
int atexit(void (*func)()) __attribute__((weak));
void adc_setup(void); // implemented in wiring_analog.c - configures ADC for analogRead()
// adc_setup must be called whenever exiting SLEEP MODE or ADC will malfunction
// It is automatically called from 'init()' but sleep mode typically resets the controller
void pinMode(uint8_t, uint8_t);
void digitalWrite(uint8_t, uint8_t);
int digitalRead(uint8_t);
int analogRead(uint8_t);
void analogReference(uint8_t mode); // somewhat different for xmega (default is Vcc/2) - see 'enum _analogReference_', below
// pass only one of THOSE values as 'mode'
void analogWrite(uint8_t, int);
// special XMEGA-specific functions for the analog inputs
int analogReadDeltaWithGain(uint8_t pin, uint8_t negpin, uint8_t gain);
// typically 'pin' can be A0 through An, 'negpin' may be restricted but typically A4-A7 or 'ANALOG_READ_DELTA_USE_GND' to use GND
// NOTE: On the A-series processors it is NOT possible to use 'diff input with gain' on MORE than A0-A7
// On later processors (like D series) it _IS_ possible.
#define ANALOG_READ_DELTA_USE_GND 0xff
// there is a bug in several headers for ADC_REFSEL_gm - should be 0x70, not 0x30 (and it gets re-defined, too)
#ifdef ADC_REFSEL_gm
#undef ADC_REFSEL_gm
#endif // ADC_REFSEL_gm
#define ADC_REFSEL_gm 0x70
enum _analogReference_ // pass to 'analogReference' function - see D manual section 22.14.3, or 28.16.3 in 'AU' manual
{
analogReference_INT1V = (ADC_REFSEL_INT1V_gc),
analogReference_PORTA0 = (ADC_REFSEL_AREFA_gc), // PORT A pin 0 is the AREF
#if !defined (__AVR_ATxmega8E5__) && !defined (__AVR_ATxmega16E5__) && !defined (__AVR_ATxmega32E5__)
// these 2 aren't valid for 'E' series
analogReference_PORTB0 = (ADC_REFSEL_AREFB_gc), // PORT B pin 0 is the AREF
analogReference_VCC = (ADC_REFSEL0_bm) /* (ADC_REFSEL_VCC_gc)*/, // VCC / 10, actually
// NOTE: 'ADC_REFSEL_VCC_gc' exists for some headers, and others 'ADC_REFSEL_INTVCC_gc'
// to avoid compile problems I use the bitmask instead.
#endif // E series
#if defined(__AVR_ATxmega64d4__) || defined(__AVR_ATxmega64a1u__) || defined(__AVR_ATxmega128a1u__)
analogReference_VCCDIV2 = (ADC_REFSEL_VCCDIV2_gc) // using THIS forces gain to 1/2, so it's rail-rail
#else
analogReference_VCCDIV2 = (0x04<<4) // (ADC_REFSEL_VCCDIV2_gc)
// NOTE that for some processor headers, ADC_REFSEL_VCCDIV2_gc is not properly defined
// this definition '(0x04<<4)' is taken from the 64d4 header. it's also THE DEFAULT for max compatibility
#endif // processors that define ADC_REFSEL_VCCDIV2_gc correctly
};
// NOTE: this constant isn't always defined, either
#ifndef ADC_CH_GAIN_gm
#define ADC_CH_GAIN_gm 0x1C /* Gain Factor group mask. */
#endif // ADC_CH_GAIN_gm
unsigned long millis(void);
unsigned long micros(void);
void delay(unsigned long);
void delayMicroseconds(unsigned int us);
unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout);
void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val);
uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder);
// XMEGA specific
void wait_for_interrupt(void); // uses 'IDLE' sleep mode to wait for an interrupt, then returns
void low_power_delay(unsigned long ms); // similar to 'delay' but goes into low power 'IDLE sleep' state
// X M E G A X M E G A X M E G A X M E G A X M E G A X M E G A X M E G A X M E G A
//
// NOTE: for 'attachInterrupt' the 'mode' parameter indicates non-default input pins
// and the interrupt mode, as well as the interrupt priority. If the interrupt
// priority is INT_MODE_PRI_DEFAULT (0), it will be assigned a 'default' value.
// Default interrupt pin is pin 2 except for PORTR (since it doesn't have a pin 2)
// when it has not been specified.
//
// usage:
// attachInterrupt(PORTD_INT0, the specific interrupt vector - see pins_arduino.h
// my_callback, user-defined callback function
// RISING interrupt mode (can be LOW, HIGH, RISING, FALLING, CHANGE)
// | INT_MODE_PIN_DEFAULT the pin(s) to assign to this interrupt, or default pin 2 (optional)
// | INT_MODE_PRI_DEFAULT); interrupt priority, default is 'high' (optional)
//
// Additional note, the 'pin' constants (see below) refer to the port's pin number, and
// NOT the 'digital I/O pin' number. See 'pins_arduino.h' for more on this.
//
// for compatibility with newer arduino environment, attachInterrupt 'interruptNum' parameter
// can use the return value from 'digitalPinToInterrupt(pin)'
//
// X M E G A X M E G A X M E G A X M E G A X M E G A X M E G A X M E G A X M E G A
#ifdef __cplusplus
void attachInterrupt(uint8_t interruptNum, void (*)(void), int mode = 0); // default 'mode' param is: LOW | INT_MODE_PRI_DEFAULT | INT_MODE_PIN_DEFAULT
#else // not __cplusplus
void attachInterrupt(uint8_t interruptNum, void (*)(void), int mode);
#endif // __cplusplus
void detachInterrupt(uint8_t interruptNum); // NOTE: detaches ALL interrupts for that port (special exceptions for serial flow control)
// this next function reads data from the calibration row, including the serial # info.
// This is often referred to as the 'PRODUCT SIGNATURE ROW'. It is xmega-specific.
uint8_t readCalibrationData(uint16_t iIndex);
// INTERRUPT MODE FLAGS - for attachInterrupt 'mode' parameter
#define INT_MODE_MODE_MASK 0x003f
#define INT_MODE_PRI_MASK 0x00c0
#define INT_MODE_PRI_DEFAULT 0
#define INT_MODE_PRI_LOW 0x0040
#define INT_MODE_PRI_MED 0x0080
#define INT_MODE_PRI_HIGH 0x00c0
#define INT_MODE_PRI_SHIFT 6 /* shift right 6 bits to get a 0, 1, 2 or 3 for priority (0 is 'default') */
#define INT_MODE_PIN_MASK 0xff00
#define INT_MODE_PIN0 0x0100
#define INT_MODE_PIN1 0x0200
#define INT_MODE_PIN2 0x0400
#define INT_MODE_PIN3 0x0800
#define INT_MODE_PIN4 0x1000
#define INT_MODE_PIN5 0x2000
#define INT_MODE_PIN6 0x4000
#define INT_MODE_PIN7 0x8000
#define INT_MODE_PIN_DEFAULT 0 /* no 'pin bits' set implies 'default' which is pin 2 on each capable port */
#define INT_MODE_PIN_SHIFT 8 /* shift right 8 bits to get the pin bits in a single byte */
// NOTE: the 'pin' constants refer to the port's pin number, and not the digital I/O pin
// The default 'pin 2' refers to the port's pin 2. See 'pins_arduino.h' for more on this.
// Multiple pins may be specified, so it is a bit mask. If a pin is specified by using
// digitalPinToInterrupt() and you also specify pins using the 'INT_MODE_PINx' flags, the
// pin specified in the 'interruptNum' parameter will be 'or'd with the pins specified in
// 'mode'. This can result in some unpredictable outcomes, so you should either use
// 'digitalPinToInterrupt' for 'interruptNum', or specify the port as 'interruptNum' and
// then specfify the pin info in 'mode'.
#define NOT_AN_INTERRUPT (-1) /* a placeholder for various arrays, etc. */
// SETUP and LOOP (no changes from Arduino classic)
void setup(void);
void loop(void);
// hardware flow control 'helpers'
void serial_0_cts_callback(void);
void serial_1_cts_callback(void);
void InitSerialFlowControlInterrupts(void);
// On the xmega, the addresses of the port registers are
// greater than 255, so we can't store them in uint8_t's.
extern const uint16_t PROGMEM port_to_mode_PGM[];
extern const uint16_t PROGMEM port_to_input_PGM[];
extern const uint16_t PROGMEM port_to_output_PGM[];
extern const uint16_t PROGMEM digital_pin_to_control_PGM[];
// these contain index values so they CAN be uint8_t's
extern const uint8_t PROGMEM digital_pin_to_port_PGM[];
extern const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[];
extern const uint8_t PROGMEM digital_pin_to_timer_PGM[];
// extern const uint8_t PROGMEM digital_pin_to_bit_PGM[]; not used on xmega
extern const uint16_t PROGMEM port_to_input_PGM[];
// Get the bit location within the hardware port of the given virtual pin.
// This comes from the pins_*.c file for the active board configuration.
//
// These perform slightly better as macros compared to inline functions
//
#define digitalPinToPort(P) ( pgm_read_byte( digital_pin_to_port_PGM + (P) ) )
#define digitalPinToBitMask(P) ( pgm_read_byte( digital_pin_to_bit_mask_PGM + (P) ) )
#define digitalPinToTimer(P) ( pgm_read_byte( digital_pin_to_timer_PGM + (P) ) )
// note pins_arduino.h may need to override this next one, depending
#define analogInPinToBit(P) ((P) & 7) /* analog pin 0 = 0 (PORTA), analog pin 8 = 0 (PORTB) */
#define portOutputRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_output_PGM + (P))) )
#define portInputRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_input_PGM + (P))) )
#define portModeRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_mode_PGM + (P))) )
#define pinControlRegister(P) ( (volatile uint8_t *)( pgm_read_word( digital_pin_to_control_PGM + (P))) )
// use THIS macro to convert a _BV(n) value into 'n'
#define pinBitValueToIndex(B) ( (B)==_BV(0) ? 0 : (B)==_BV(1) ? 1 : (B)==_BV(2) ? 2 : (B)==_BV(3) ? 3 : \
(B)==_BV(4) ? 4 : (B)==_BV(5) ? 5 : (B)==_BV(6) ? 6 : (B)==_BV(7) ? 7 : 0 )
#define NOT_A_PIN 0
#define NOT_A_PORT 0
#ifdef ARDUINO_MAIN
// use of '_' prefix to prevent collisions with iox64d#.h and for consistency
#define _PA 1
#define _PB 2
#define _PC 3
#define _PD 4
#define _PE 5
#define _PR 6 /* was PF */
#define _PF 7
#define _PH 8
#define _PJ 9
#define _PK 10
#define _PQ 11
#endif
// modified timer definitions for xmega
// TCD2 --> TIMERD2
// TCC2 --> TIMERC2
// TCE0 --> TIMERE0 - 'D' series which has only 4 pins on PORTE */
// TCE2 --> TIMERE2 - A series and others that use all 8 pins for port E
// TCF2 --> TIMERF2 - A series and others that have PORT F
#define NOT_ON_TIMER 0
#define TIMERD2 1
#define TIMERC2 2
#define TIMERE0 3
#define TIMERE2 4
#define TIMERF2 5
#define TIMERC4 6
#define TIMERD5 7
// not using TCD0,1 nor TCC0,1
// The first 16 IO pins (PD0-PD7, PC0-PC7) will be PWM capable, as are PE0-PE3 (or PE0-PE7) and PF0-PF7 (when there)
#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus
#ifdef __cplusplus
#include "WCharacter.h"
#include "WString.h"
#include "HardwareSerial.h"
uint16_t makeWord(uint16_t w);
uint16_t makeWord(byte h, byte l);
#define word(...) makeWord(__VA_ARGS__)
#if 0
// these are not currently implemented - TODO implement them
unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout = 1000000L);
#endif // 0
void tone(uint8_t _pin, unsigned int frequency, unsigned long duration = 0);
void noTone(uint8_t _pin);
// WMath prototypes
long random(long);
long random(long, long);
void randomSeed(unsigned int);
long map(long, long, long, long, long);
#endif // __cplusplus
// at this point we include the pin definitions from 'pins_arduino.h'
// you can customize 'pins_arduino.h' for your specific hardware
#include "pins_arduino.h"
// The default SPI interface is SPIC if not already defined
#ifndef DEFAULT_SPI
#define DEFAULT_SPI SPIC
#endif // DEFAULT_SPI
// the default TWI interface is TWIC if not already defined
#ifndef DEFAULT_TWI
#define DEFAULT_TWI TWIC
#endif // DEFAULT_TWI
// added support for hardware serial flow control - spans multiple files
#if defined(SERIAL_0_RTS_PORT_NAME) && defined(SERIAL_0_RTS_PIN_INDEX)
#define SERIAL_0_RTS_ENABLED
#define SERIAL_0_RTS_PORT (&SERIAL_0_RTS_PORT_NAME)
#define SERIAL_0_RTS_PIN _BV(SERIAL_0_RTS_PIN_INDEX)
#endif // defined(SERIAL_0_RTS_PORT) && defined(SERIAL_0_RTS_PIN)
#if defined(SERIAL_1_RTS_PORT_NAME) && defined(SERIAL_1_RTS_PIN_INDEX)
#define SERIAL_1_RTS_ENABLED
#define SERIAL_1_RTS_PORT (&SERIAL_1_RTS_PORT_NAME)
#define SERIAL_1_RTS_PIN _BV(SERIAL_1_RTS_PIN_INDEX)
#endif // defined(SERIAL_1_RTS_PORT) && defined(SERIAL_1_RTS_PIN)
#if defined(SERIAL_0_CTS_PORT_NAME) && defined(SERIAL_0_CTS_PIN_INDEX)
#define SERIAL_0_CTS_ENABLED
#define SERIAL_0_CTS_PORT (&SERIAL_0_CTS_PORT_NAME)
#define SERIAL_0_CTS_PIN _BV(SERIAL_0_CTS_PIN_INDEX)
#endif // defined(SERIAL_0_CTS_PORT) && defined(SERIAL_0_CTS_PIN)
#if defined(SERIAL_1_CTS_PORT_NAME) && defined(SERIAL_1_CTS_PIN_INDEX)
#define SERIAL_1_CTS_ENABLED
#define SERIAL_1_CTS_PORT (&SERIAL_1_CTS_PORT_NAME)
#define SERIAL_1_CTS_PIN _BV(SERIAL_1_CTS_PIN_INDEX)
#endif // defined(SERIAL_1_CTS_PORT) && defined(SERIAL_1_CTS_PIN)
#endif // Arduino_h

View File

@@ -1,541 +0,0 @@
//////////////////////////////////////////////////////////////////////////////
// //
// ____ ____ ____ //
// / ___|| _ \ / ___| ___ _ __ _ __ //
// | | | | | || | / __|| '_ \ | '_ \ //
// | |___ | |_| || |___ _| (__ | |_) || |_) | //
// \____||____/ \____|(_)\___|| .__/ | .__/ //
// |_| |_| //
// //
//////////////////////////////////////////////////////////////////////////////
/* Copyright (c) 2011, Peter Barrett
**
** Permission to use, copy, modify, and/or distribute this software for
** any purpose with or without fee is hereby granted, provided that the
** above copyright notice and this permission notice appear in all copies.
**
** THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
** WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
** WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR
** BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
** OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
** WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
** ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
** SOFTWARE.
*/
// Updated for the XMegaForArduino project by Bob Frazier, S.F.T. Inc.
/////////////////////////////////////////////////////////////////////////////////
// XMEGA NOTES:
//
// a) major re-factoring, including API functions
// b) K&R style is hard to read. I won't use it. Hard tabs are evil. Same.
//
/////////////////////////////////////////////////////////////////////////////////
#include "Platform.h"
#include "USBAPI.h"
#include <avr/wdt.h>
#if defined(USBCON)
#ifdef CDC_ENABLED
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
#define PROGMEM_ORIG PROGMEM
#else // PROGMEM workaround
// to avoid the bogus "initialized variables" warning
#ifdef PROGMEM
#undef PROGMEM
#endif // PROGMEM re-define
#define PROGMEM __attribute__((section(".progmem.cdc")))
#define PROGMEM_ORIG __attribute__((__progmem__))
#endif // check for GNUC >= or < 4.6
typedef struct
{
u32 dwDTERate; // little-endian line rate
u8 bCharFormat; // stop bits = one, one-and-a-half, two (0, 1, 2 respectively)
u8 bParityType; // none, odd, even, mark, space (0 through 4)
u8 bDataBits; // char bits 5, 6, 7, 8
} __attribute__((aligned(1))) LineInfo;
static volatile LineInfo _usbLineInfo; // for initialization, see CDC_Reset
static u8 _cdcLineState;
static u16 _cdcSerialState;
static uint16_t wInterval;
#define WEAK __attribute__ ((weak))
extern const DeviceDescriptor _cdcDeviceDescriptor PROGMEM;
extern const IADDescriptor _cdcIADDesc PROGMEM;
extern const CDCDescriptor _cdcInterface PROGMEM;
// CDC DEVICE DESCRIPTOR (for CDC device) - sent by CDC_SendDeviceDescriptor()
const DeviceDescriptor _cdcDeviceDescriptor PROGMEM =
D_DEVICE(USB_DEVICE_CLASS_COMMUNICATIONS, // device class (COMM)
CDC_COMMUNICATION_INTERFACE_CLASS, // device sub-class (CDC COMM)
CDC_ABSTRACT_CONTROL_MODEL, // device protocol (ACM)
64, // packet size (64)
USB_VID, // vendor ID for the USB device
USB_PID, // product ID for the USB device
0x100, // device release version as BCD (1.00)
USB_STRING_INDEX_MANUFACTURER, // string index for mfg
USB_STRING_INDEX_PRODUCT, // string index for product name
USB_STRING_INDEX_SERIAL, // string index for serial number (0 for 'none')
1); // number of configurations (1)
// IAD descriptor - REQUIRED for composite interfaces, sent via CDC_SendIAD()
const IADDescriptor _cdcIADDesc = D_IAD(0, // first interface
2, // count (interfaces, not endpoints)
CDC_COMMUNICATION_INTERFACE_CLASS, // interface class
CDC_ABSTRACT_CONTROL_MODEL, // interface sub-class
1); // protocol
// CDC interface descriptor - sent by CDC_SendInterfaceData()
const CDCDescriptor _cdcInterface = // needs to be no more than 55 bytes in length
{
// FIRST INTERFACE
// CDC communication interface (endpoint 0)
D_INTERFACE(CDC_ACM_INTERFACE, // 'n'
1, // number of endpoints
CDC_COMMUNICATION_INTERFACE_CLASS, // interface class
CDC_ABSTRACT_CONTROL_MODEL, // interface sub-class
0), // protocol
// these headers describe the supported interfaces
D_CDCCS(CDC_HEADER,0x10,0x01), // CDCCS InterfaceDescriptor Header (1.10 bcd) - version 1.10?
// D_CDCCS(CDC_CALL_MANAGEMENT,1,1), // Device handles call management (seems to be optional)
D_CDCCS4(CDC_ABSTRACT_CONTROL_MANAGEMENT,6), // SET_LINE_CODING, GET_LINE_CODING, SET_CONTROL_LINE_STATE supported
D_CDCCS(CDC_UNION,CDC_ACM_INTERFACE,CDC_DATA_INTERFACE), // Communication interface is master, data interface is slave 0 (?)
D_ENDPOINT(USB_ENDPOINT_IN (CDC_ENDPOINT_ACM), // IN endpoint for CDC_ENDPOINT_ACM
USB_ENDPOINT_TYPE_INTERRUPT, // INTERRUPT type
0x10, // max packet size 16
0x40), // interval 64 frames i.e. 64 msec (see USB spec table 9-13)
// SECOND INTERFACE
// CDC data interface (endpoints 1, 2)
D_INTERFACE(CDC_DATA_INTERFACE, // 'n'
2, // number of endpoints
CDC_DATA_INTERFACE_CLASS, // interface class
0, // interface sub-class
0), // protocol
D_ENDPOINT(USB_ENDPOINT_OUT(CDC_ENDPOINT_OUT), // OUT endpoint, index 'CDC_ENDPOINT_OUT'
USB_ENDPOINT_TYPE_BULK, // BULK data transfers
0x40, // max packet size 64
1), // interval 1 (was 0)
D_ENDPOINT(USB_ENDPOINT_IN (CDC_ENDPOINT_IN), // IN endpoint, index 'CDC_ENDPOINT_IN'
USB_ENDPOINT_TYPE_BULK, // BULK data transfers
0x40, // max packet size 64
0) // interval 0 (apparently not needed)
};
void WEAK CDC_Reset(void)
{
_usbLineInfo.dwDTERate = 115200;
_usbLineInfo.bCharFormat
= _usbLineInfo.bParityType
= _usbLineInfo.bDataBits
= 0; // says I'm not initialized, basically
_cdcLineState = 0;
_cdcSerialState = 0;
wInterval = 0;
}
bool WEAK CDC_SendIAD(void)
{
return USB_SendControl(TRANSFER_PGM, &_cdcIADDesc, sizeof(_cdcIADDesc))
!= 0;
}
int WEAK CDC_GetNumInterfaces(void)
{
return 2; // always 2
}
int WEAK CDC_GetInterfaceDataLength(void)
{
return sizeof(_cdcInterface);
}
int WEAK CDC_SendInterfaceData(void)
{
return USB_SendControl(TRANSFER_PGM, &_cdcInterface, sizeof(_cdcInterface));
}
bool WEAK CDC_SendDeviceDescriptor(void)
{
return 0 != USB_SendControl(TRANSFER_PGM, &_cdcDeviceDescriptor, sizeof(_cdcDeviceDescriptor));
}
bool WEAK CDC_Setup(Setup& setup)
{
u8 r = setup.bRequest;
u8 requestType = setup.bmRequestType;
if(REQUEST_DEVICETOHOST_CLASS_INTERFACE == requestType)
{
if (CDC_GET_LINE_CODING == r)
{
error_printP(F("Get Line Coding"));
#if 1
USB_SendControl(0,(void*)&_usbLineInfo, sizeof(_usbLineInfo)/*7*/);
#endif // 0
return true;
}
}
else if(REQUEST_HOSTTODEVICE_CLASS_INTERFACE == requestType)
{
if(CDC_SET_LINE_CODING == r)
{
error_printP_(F("CDC_SET_LINE_CODING"));
// setup packet is followed by data?
memcpy((void *)&_usbLineInfo, (char *)&(setup) + sizeof(Setup), sizeof(_usbLineInfo));
error_printP_(F(" rate:"));
error_printL_(_usbLineInfo.dwDTERate);
error_printP_(F(" fmt:"));
error_printL_(_usbLineInfo.bCharFormat);
error_printP_(F(" par:"));
error_printL_(_usbLineInfo.bParityType);
error_printP_(F(" bit:"));
error_printL(_usbLineInfo.bDataBits);
USB_SendControl(0, NULL, 0); // send a ZLP
_cdcLineState = CONTROL_LINE_STATE_DTR; // for now... assume "this"
// now set up the ACM interrupt info in '_cdcSerialState' and send it back
_cdcSerialState = SERIAL_STATE_TX_CARRIER_DSR; // to tell host "I have data" (always)
return true;
}
else if(CDC_SET_CONTROL_LINE_STATE == r)
{
error_printP_(F("Set Control Line State: "));
error_printL(setup.wValueL);
_cdcLineState = setup.wValueL;
// NOTE: this next part is for the 'caterina' CDC bootloader, arduino/bootloaders/caterina/Caterina.c
// it has some "special" code in it, like using 0x0800 in RAM as an address for a 'key' (7777H)
// to indicate it was soft-booted. XMEGA has better ways of handling this, like a CPU flag that
// indicates "I was soft-booted" as one example, and a 'WDT' timeout flag on top of that.
// auto-reset into the bootloader is triggered when the port, already
// open at 1200 bps, is closed. this is the signal to start the watchdog
// with a relatively long period so it can finish housekeeping tasks
// like servicing endpoints before the sketch ends
if (1200 == _usbLineInfo.dwDTERate)
{
// We check DTR state to determine if host port is open (bit 0 of _cdcLineState).
if ((_cdcLineState & 0x01) == 0)
{
// This section of code is support for the 'caterina' bootloader, which allows USB flashing (apparently)
//
// *(uint16_t *)0x0800 = 0x7777; note that on XMEGA this is a VERY bad thing
// wdt_enable(WDTO_120MS);
//
// on the atmega, address 800H is the start of the final 256-byte page in RAM space for 2k RAM
//
// atmega328(p) RAM goes from 0x100 through 0x8ff - see datasheet for atmega 328 [etc.] section 8.3
// 32U4 RAM goes through 0xaff - see datasheet for U4 processors, section 5.2
// 8/16/32U2 RAM goes through 4FFH so this won't even work - see datasheet for U2 processors, section 7.2
// basically it's a 'hack' and needs to be re-evaluated
// TODO: would it be safe to enable interrupts, NOT return from this function,
// and simply wait until the appropriate time has elapsed? Or, as is
// handled in the section below, this 'wait period' is canceled
// TODO: if I use a function that's part of the USB driver to trigger a soft boot, I can detect
// that a soft boot has taken place using the bits in the 'RESET' status register. If all
// I have to do is detect this, it's not a problem, and I won't need "magic memory locations"
// TODO: timeout-based reboot
}
else
{
// Most OSs do some intermediate steps when configuring ports and DTR can
// twiggle more than once before stabilizing.
// To avoid spurious resets we set the watchdog to 250ms and eventually
// cancel if DTR goes back high.
// This section of code is support for the 'caterina' bootloader, which allows USB flashing (apparently)
//
// TODO: reset whatever boot timeout I did
// wdt_disable();
// wdt_reset();
// *(uint16_t *)0x0800 = 0x0; note that on XMEGA this is a VERY bad thing
}
}
USB_SendControl(0, NULL, 0); // send a ZLP
return true;
}
}
// unrecognized request - report it
error_printP_(F("CDC request: type="));
error_printL_(requestType);
error_printP_(F(" request="));
error_printL(r);
return false;
}
// 'frame received' callback - notification that a 'Start Of Frame' took place
void CDC_FrameReceived(void)
{
bool bSend = false;
// NOTE: if I haven't configured the baud/bits yet, or the DTR bit is cleared,
// do NOT send anything nor muck with the flags. Wait until the device
// is actually RUNNING, first.
if(!_usbLineInfo.bDataBits || !(_cdcLineState & CONTROL_LINE_STATE_DTR))
{
return; // don't do anything if I haven't properly set up the data bits yet
}
if(USB_Available(CDC_RX) >= 64) // allow ~64 buffered bytes
{
if(_cdcSerialState & SERIAL_STATE_RX_CARRIER_DCD) // was on?
{
_cdcSerialState &= ~SERIAL_STATE_RX_CARRIER_DCD;
bSend = true;
}
}
else
{
if(!(_cdcSerialState & SERIAL_STATE_RX_CARRIER_DCD)) // was off?
{
_cdcSerialState |= SERIAL_STATE_RX_CARRIER_DCD;
bSend = true;
}
}
// if(USB_SendQLength(CDC_TX) > 0) // anything to send??
// {
// if(!(_cdcSerialState & SERIAL_STATE_TX_CARRIER_DSR))
// {
// _cdcSerialState |= SERIAL_STATE_TX_CARRIER_DSR; // to tell host "I have data"
//
// bSend = true;
// }
// }
// else
// {
// if(_cdcSerialState & SERIAL_STATE_TX_CARRIER_DSR)
// {
// _cdcSerialState &= ~SERIAL_STATE_TX_CARRIER_DSR; // to tell host "I have data"
//
// bSend = true;
// }
// }
if((bSend || wInterval >= 64) // will send every 64 'bus cycles' or when there's a change
&& !USB_SendQLength(CDC_ACM))
{
CDC_SendACM();
wInterval = 0;
}
else if(wInterval < 64)
{
wInterval++;
}
}
void CDC_SendACM(void)
{
USB_Send(CDC_ACM, &_cdcSerialState, sizeof(_cdcSerialState), 1);
}
void Serial_::begin(unsigned long baud_count)
{
peek_buffer = -1;
}
void Serial_::begin(unsigned long baud_count, byte config)
{
peek_buffer = -1;
}
void Serial_::end(void)
{
}
int Serial_::available(void)
{
if (peek_buffer >= 0)
{
return 1 + USB_Available(CDC_RX);
}
return USB_Available(CDC_RX);
}
int Serial_::peek(void)
{
if (peek_buffer < 0)
{
if(USBDevice.configured())
{
peek_buffer = USB_Recv(CDC_RX);
}
}
return peek_buffer;
}
int Serial_::read(void)
{
if (peek_buffer >= 0)
{
int c = peek_buffer;
peek_buffer = -1;
return c;
}
if(USBDevice.configured())
{
return USB_Recv(CDC_RX);
}
return -1;
}
void Serial_::flush(void)
{
if(USBDevice.configured())
{
USB_Flush(CDC_TX);
}
}
size_t Serial_::write(uint8_t c)
{
return write(&c, 1);
}
size_t Serial_::write(const uint8_t *buffer, size_t size)
{
/* only try to send bytes if the high-level CDC connection itself
is open (not just the pipe) - the OS should set _cdcLineState when the port
is opened and clear _cdcLineState when the port is closed.
bytes sent before the user opens the connection or after
the connection is closed are lost - just like with a UART. */
// NOTE: if my outgoing buffer is too full, stop sending
// TODO - ZE - check behavior on different OSes and test what happens if an
// open connection isn't broken cleanly (cable is yanked out, host dies
// or locks up, or host virtual serial port hangs)
if(USBDevice.configured() && // make sure I'm running
// !USB_IsStalled(CDC_TX) && // make sure I'm not stalled
!USB_IsSendQFull(CDC_TX)) // make sure I'm not flooding the queue
{
if(_cdcLineState & CONTROL_LINE_STATE_DTR) // make sure DTR is set
{
if(size > 128)
{
size = 128; // adjust size DOWN to limit output buffer size
}
int r = USB_Send(CDC_TX, buffer, size, 1);
// TODO: check for partial sends and retry??
if(r > 0)
{
CDC_FrameReceived(); // inform the host of my data send/receive state
return r;
}
}
}
// TODO: block?
setWriteError();
return 0;
}
// This operator is a convenient way for a sketch to check whether the
// port has actually been configured and opened by the host (as opposed
// to just being connected to the host). It can be used, for example, in
// setup() before printing to ensure that an application on the host is
// actually ready to receive and display the data.
Serial_::operator bool()
{
bool result = false;
if(USBDevice.configured()
&& (_cdcLineState & CONTROL_LINE_STATE_DTR)
&& !USB_IsSendQFull(CDC_TX)
// && !USB_IsStalled(CDC_TX)
)
{
result = true;
}
// We add a short delay before returning to fix a bug observed by Federico
// where the port is configured (_cdcLineState != 0) but not quite opened.
// delay(10);
if(!result)
{
if(!USBDevice.configured())
{
error_printP(F("USB device not configured"));
}
else if(!(_cdcLineState & CONTROL_LINE_STATE_DTR))
{
error_printP(F("DTR is off"));
}
else if(USB_IsSendQFull(CDC_TX))
{
error_printP(F("Send Queue FULL"));
}
// else if(USB_IsStalled(CDC_TX))
// {
// error_printP(F("USB is stalled"));
// }
}
return result;
}
Serial_ Serial;
#endif
#endif /* if defined(USBCON) */

View File

@@ -1,45 +0,0 @@
/*
Client.h - Base class that provides Client
Copyright (c) 2011 Adrian McEwen. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef client_h
#define client_h
#include "Print.h"
#include "Stream.h"
#include "IPAddress.h"
class Client : public Stream {
public:
virtual int connect(IPAddress ip, uint16_t port) =0;
virtual int connect(const char *host, uint16_t port) =0;
virtual size_t write(uint8_t) =0;
virtual size_t write(const uint8_t *buf, size_t size) =0;
virtual int available() = 0;
virtual int read() = 0;
virtual int read(uint8_t *buf, size_t size) = 0;
virtual int peek() = 0;
virtual void flush() = 0;
virtual void stop() = 0;
virtual uint8_t connected() = 0;
virtual operator bool() = 0;
protected:
uint8_t* rawIPAddress(IPAddress& addr) { return addr.raw_address(); };
};
#endif

View File

@@ -1,593 +0,0 @@
//////////////////////////////////////////////////////////////////////////////
// //
// _ _ ___ ____ //
// | | | ||_ _|| _ \ ___ _ __ _ __ //
// | |_| | | | | | | | / __|| '_ \ | '_ \ //
// | _ | | | | |_| |_| (__ | |_) || |_) | //
// |_| |_||___||____/(_)\___|| .__/ | .__/ //
// |_| |_| //
// //
//////////////////////////////////////////////////////////////////////////////
/* Copyright (c) 2011, Peter Barrett
**
** Permission to use, copy, modify, and/or distribute this software for
** any purpose with or without fee is hereby granted, provided that the
** above copyright notice and this permission notice appear in all copies.
**
** THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
** WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
** WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR
** BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
** OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
** WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
** ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
** SOFTWARE.
*/
/////////////////////////////////////////////////////////////////////////////////
// XMEGA NOTES:
//
// a) it appears that, at one time at least, this was intended to be overridden
// by user code, hence the use of 'WEAK' all over the place;
// b) This API is *VERY* 'tricky' in that it's tied in heavily with the atmega
// USB implementation and (in some cases) does 'magic things' that are not
// apparently obvious to someone trying to port it to another processor
// (for an example see original use of CDC_GetInterface - lame!)
// c) Given the fact that it's (in my view) POORLY WRITTEN, it deserves a makeover.
// d) K&R style is hard to read. I won't use it. Hard tabs are evil. Same.
//
/////////////////////////////////////////////////////////////////////////////////
#include "Platform.h"
#include "USBAPI.h"
#include "USBDesc.h"
#if defined(USBCON)
#ifdef HID_ENABLED
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
#define PROGMEM_ORIG PROGMEM
#else // PROGMEM workaround
// to avoid the bogus "initialized variables" warning
#ifdef PROGMEM
#undef PROGMEM
#endif // PROGMEM re-define
#define PROGMEM __attribute__((section(".progmem.hid")))
#define PROGMEM_ORIG __attribute__((__progmem__))
#endif // check for GNUC >= or < 4.6
//#define RAWHID_ENABLED
// Singletons for mouse and keyboard
Mouse_ Mouse;
Keyboard_ Keyboard;
//================================================================================
//================================================================================
// HID report descriptor
#define LSB(_x) ((_x) & 0xFF)
#define MSB(_x) ((_x) >> 8)
#define RAWHID_USAGE_PAGE 0xFFC0
#define RAWHID_USAGE 0x0C00
#define RAWHID_TX_SIZE 64
#define RAWHID_RX_SIZE 64
const u8 _hidReportDescriptor[] PROGMEM =
{
// Mouse
0x05, 0x01, // USAGE_PAGE (Generic Desktop) // 54
0x09, 0x02, // USAGE (Mouse)
0xa1, 0x01, // COLLECTION (Application)
0x09, 0x01, // USAGE (Pointer)
0xa1, 0x00, // COLLECTION (Physical)
0x85, 0x01, // REPORT_ID (1)
0x05, 0x09, // USAGE_PAGE (Button)
0x19, 0x01, // USAGE_MINIMUM (Button 1)
0x29, 0x03, // USAGE_MAXIMUM (Button 3)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x25, 0x01, // LOGICAL_MAXIMUM (1)
0x95, 0x03, // REPORT_COUNT (3)
0x75, 0x01, // REPORT_SIZE (1)
0x81, 0x02, // INPUT (Data,Var,Abs)
0x95, 0x01, // REPORT_COUNT (1)
0x75, 0x05, // REPORT_SIZE (5)
0x81, 0x03, // INPUT (Cnst,Var,Abs)
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x30, // USAGE (X)
0x09, 0x31, // USAGE (Y)
0x09, 0x38, // USAGE (Wheel)
0x15, 0x81, // LOGICAL_MINIMUM (-127)
0x25, 0x7f, // LOGICAL_MAXIMUM (127)
0x75, 0x08, // REPORT_SIZE (8)
0x95, 0x03, // REPORT_COUNT (3)
0x81, 0x06, // INPUT (Data,Var,Rel)
0xc0, // END_COLLECTION
0xc0, // END_COLLECTION
// Keyboard
0x05, 0x01, // USAGE_PAGE (Generic Desktop) // 47
0x09, 0x06, // USAGE (Keyboard)
0xa1, 0x01, // COLLECTION (Application)
0x85, 0x02, // REPORT_ID (2)
0x05, 0x07, // USAGE_PAGE (Keyboard)
0x19, 0xe0, // USAGE_MINIMUM (Keyboard LeftControl)
0x29, 0xe7, // USAGE_MAXIMUM (Keyboard Right GUI)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x25, 0x01, // LOGICAL_MAXIMUM (1)
0x75, 0x01, // REPORT_SIZE (1)
0x95, 0x08, // REPORT_COUNT (8)
0x81, 0x02, // INPUT (Data,Var,Abs)
0x95, 0x01, // REPORT_COUNT (1)
0x75, 0x08, // REPORT_SIZE (8)
0x81, 0x03, // INPUT (Cnst,Var,Abs)
0x95, 0x06, // REPORT_COUNT (6)
0x75, 0x08, // REPORT_SIZE (8)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x25, 0x65, // LOGICAL_MAXIMUM (101)
0x05, 0x07, // USAGE_PAGE (Keyboard)
0x19, 0x00, // USAGE_MINIMUM (Reserved (no event indicated))
0x29, 0x65, // USAGE_MAXIMUM (Keyboard Application)
0x81, 0x00, // INPUT (Data,Ary,Abs)
0xc0, // END_COLLECTION
#ifdef RAWHID_ENABLED
// RAW HID
0x06, LSB(RAWHID_USAGE_PAGE), MSB(RAWHID_USAGE_PAGE), // 30
0x0A, LSB(RAWHID_USAGE), MSB(RAWHID_USAGE),
0xA1, 0x01, // Collection 0x01
0x85, 0x03, // REPORT_ID (3)
0x75, 0x08, // report size = 8 bits
0x15, 0x00, // logical minimum = 0
0x26, 0xFF, 0x00, // logical maximum = 255
0x95, 64, // report count TX
0x09, 0x01, // usage
0x81, 0x02, // Input (array)
0x95, 64, // report count RX
0x09, 0x02, // usage
0x91, 0x02, // Output (array)
0xC0 // end collection
#endif
};
const HIDDescriptor _hidInterface PROGMEM =
{
D_INTERFACE(HID_INTERFACE,1,3,0,0),
D_HIDREPORT(sizeof(_hidReportDescriptor)),
D_ENDPOINT(USB_ENDPOINT_IN (HID_ENDPOINT_INT),USB_ENDPOINT_TYPE_INTERRUPT,0x40,0x01)
};
//================================================================================
//================================================================================
// Driver
u8 _hid_protocol = 1;
u8 _hid_idle = 1;
#define WEAK __attribute__ ((weak))
int WEAK HID_GetNumInterfaces(void)
{
return 1; // always 1
}
int WEAK HID_GetInterfaceDataLength(void)
{
return sizeof(_hidInterface);
}
int WEAK HID_SendInterfaceData(void)
{
return USB_SendControl(TRANSFER_PGM, &_hidInterface, sizeof(_hidInterface));
}
int WEAK HID_GetDescriptor(int i)
{
// NOTE: 'i' is the max size for the request. Should I pay attention to it?
return USB_SendControl(TRANSFER_PGM,_hidReportDescriptor,sizeof(_hidReportDescriptor));
}
void WEAK HID_SendReport(u8 id, const void* data, int len)
{
USB_Send(HID_TX, &id, 1, 0);
USB_Send(HID_TX,data,len, 1);
}
bool WEAK HID_Setup(Setup& setup)
{
u8 r = setup.bRequest;
u8 requestType = setup.bmRequestType;
if (REQUEST_DEVICETOHOST_CLASS_INTERFACE == requestType)
{
if (HID_GET_REPORT == r)
{
//HID_GetReport();
return true;
}
if (HID_GET_PROTOCOL == r)
{
//Send8(_hid_protocol); // TODO
return true;
}
}
if (REQUEST_HOSTTODEVICE_CLASS_INTERFACE == requestType)
{
if (HID_SET_PROTOCOL == r)
{
_hid_protocol = setup.wValueL;
return true;
}
if (HID_SET_IDLE == r)
{
_hid_idle = setup.wValueL;
return true;
}
}
return false;
}
//================================================================================
//================================================================================
// Mouse
Mouse_::Mouse_(void) : _buttons(0)
{
}
void Mouse_::begin(void)
{
}
void Mouse_::end(void)
{
}
void Mouse_::click(uint8_t b)
{
_buttons = b;
move(0,0,0);
_buttons = 0;
move(0,0,0);
}
void Mouse_::move(signed char x, signed char y, signed char wheel)
{
u8 m[4];
m[0] = _buttons;
m[1] = x;
m[2] = y;
m[3] = wheel;
HID_SendReport(1,m,4);
}
void Mouse_::buttons(uint8_t b)
{
if (b != _buttons)
{
_buttons = b;
move(0,0,0);
}
}
void Mouse_::press(uint8_t b)
{
buttons(_buttons | b);
}
void Mouse_::release(uint8_t b)
{
buttons(_buttons & ~b);
}
bool Mouse_::isPressed(uint8_t b)
{
if ((b & _buttons) > 0)
{
return true;
}
return false;
}
//================================================================================
//================================================================================
// Keyboard
Keyboard_::Keyboard_(void)
{
}
void Keyboard_::begin(void)
{
}
void Keyboard_::end(void)
{
}
void Keyboard_::sendReport(KeyReport* keys)
{
HID_SendReport(2,keys,sizeof(KeyReport));
}
extern
const uint8_t _asciimap[128] PROGMEM;
#define SHIFT 0x80
const uint8_t _asciimap[128] =
{
0x00, // NUL
0x00, // SOH
0x00, // STX
0x00, // ETX
0x00, // EOT
0x00, // ENQ
0x00, // ACK
0x00, // BEL
0x2a, // BS Backspace
0x2b, // TAB Tab
0x28, // LF Enter
0x00, // VT
0x00, // FF
0x00, // CR
0x00, // SO
0x00, // SI
0x00, // DEL
0x00, // DC1
0x00, // DC2
0x00, // DC3
0x00, // DC4
0x00, // NAK
0x00, // SYN
0x00, // ETB
0x00, // CAN
0x00, // EM
0x00, // SUB
0x00, // ESC
0x00, // FS
0x00, // GS
0x00, // RS
0x00, // US
0x2c, // ' '
0x1e|SHIFT, // !
0x34|SHIFT, // "
0x20|SHIFT, // #
0x21|SHIFT, // $
0x22|SHIFT, // %
0x24|SHIFT, // &
0x34, // '
0x26|SHIFT, // (
0x27|SHIFT, // )
0x25|SHIFT, // *
0x2e|SHIFT, // +
0x36, // ,
0x2d, // -
0x37, // .
0x38, // /
0x27, // 0
0x1e, // 1
0x1f, // 2
0x20, // 3
0x21, // 4
0x22, // 5
0x23, // 6
0x24, // 7
0x25, // 8
0x26, // 9
0x33|SHIFT, // :
0x33, // ;
0x36|SHIFT, // <
0x2e, // =
0x37|SHIFT, // >
0x38|SHIFT, // ?
0x1f|SHIFT, // @
0x04|SHIFT, // A
0x05|SHIFT, // B
0x06|SHIFT, // C
0x07|SHIFT, // D
0x08|SHIFT, // E
0x09|SHIFT, // F
0x0a|SHIFT, // G
0x0b|SHIFT, // H
0x0c|SHIFT, // I
0x0d|SHIFT, // J
0x0e|SHIFT, // K
0x0f|SHIFT, // L
0x10|SHIFT, // M
0x11|SHIFT, // N
0x12|SHIFT, // O
0x13|SHIFT, // P
0x14|SHIFT, // Q
0x15|SHIFT, // R
0x16|SHIFT, // S
0x17|SHIFT, // T
0x18|SHIFT, // U
0x19|SHIFT, // V
0x1a|SHIFT, // W
0x1b|SHIFT, // X
0x1c|SHIFT, // Y
0x1d|SHIFT, // Z
0x2f, // [
0x31, // bslash
0x30, // ]
0x23|SHIFT, // ^
0x2d|SHIFT, // _
0x35, // `
0x04, // a
0x05, // b
0x06, // c
0x07, // d
0x08, // e
0x09, // f
0x0a, // g
0x0b, // h
0x0c, // i
0x0d, // j
0x0e, // k
0x0f, // l
0x10, // m
0x11, // n
0x12, // o
0x13, // p
0x14, // q
0x15, // r
0x16, // s
0x17, // t
0x18, // u
0x19, // v
0x1a, // w
0x1b, // x
0x1c, // y
0x1d, // z
0x2f|SHIFT, //
0x31|SHIFT, // |
0x30|SHIFT, // }
0x35|SHIFT, // ~
0 // DEL
};
uint8_t USBPutChar(uint8_t c);
// press() adds the specified key (printing, non-printing, or modifier)
// to the persistent key report and sends the report. Because of the way
// USB HID works, the host acts like the key remains pressed until we
// call release(), releaseAll(), or otherwise clear the report and resend.
size_t Keyboard_::press(uint8_t k)
{
uint8_t i;
if (k >= 136) // it's a non-printing key (not a modifier)
{
k = k - 136;
}
else if (k >= 128)
{ // it's a modifier key
_keyReport.modifiers |= (1<<(k-128));
k = 0;
}
else // it's a printing key
{
k = pgm_read_byte(_asciimap + k);
if (!k)
{
setWriteError();
return 0;
}
if (k & 0x80) // it's a capital letter or other character reached with shift
{
_keyReport.modifiers |= 0x02; // the left shift modifier
k &= 0x7F;
}
}
// Add k to the key report only if it's not already present
// and if there is an empty slot.
if (_keyReport.keys[0] != k && _keyReport.keys[1] != k &&
_keyReport.keys[2] != k && _keyReport.keys[3] != k &&
_keyReport.keys[4] != k && _keyReport.keys[5] != k)
{
for (i=0; i<6; i++)
{
if (_keyReport.keys[i] == 0x00)
{
_keyReport.keys[i] = k;
break;
}
}
if (i == 6)
{
setWriteError();
return 0;
}
}
sendReport(&_keyReport);
return 1;
}
// release() takes the specified key out of the persistent key report and
// sends the report. This tells the OS the key is no longer pressed and that
// it shouldn't be repeated any more.
size_t Keyboard_::release(uint8_t k)
{
uint8_t i;
if (k >= 136)
{ // it's a non-printing key (not a modifier)
k = k - 136;
}
else if (k >= 128)
{ // it's a modifier key
_keyReport.modifiers &= ~(1<<(k-128));
k = 0;
}
else
{ // it's a printing key
k = pgm_read_byte(_asciimap + k);
if (!k)
{
return 0;
}
if (k & 0x80)
{ // it's a capital letter or other character reached with shift
_keyReport.modifiers &= ~(0x02); // the left shift modifier
k &= 0x7F;
}
}
// Test the key report to see if k is present. Clear it if it exists.
// Check all positions in case the key is present more than once (which it shouldn't be)
for (i=0; i<6; i++)
{
if (0 != k && _keyReport.keys[i] == k)
{
_keyReport.keys[i] = 0x00;
}
}
sendReport(&_keyReport);
return 1;
}
void Keyboard_::releaseAll(void)
{
_keyReport.keys[0] = 0;
_keyReport.keys[1] = 0;
_keyReport.keys[2] = 0;
_keyReport.keys[3] = 0;
_keyReport.keys[4] = 0;
_keyReport.keys[5] = 0;
_keyReport.modifiers = 0;
sendReport(&_keyReport);
}
size_t Keyboard_::write(uint8_t c)
{
uint8_t p = press(c); // Keydown
/*uint8_t r =*/ release(c); // Keyup
return (p); // just return the result of press() since release() almost always returns 1
}
#endif
#endif /* if defined(USBCON) */

File diff suppressed because it is too large Load Diff

View File

@@ -1,143 +0,0 @@
/*
HardwareSerial.h - Hardware serial library for Wiring
Copyright (c) 2006 Nicholas Zambetti. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Modified 28 September 2010 by Mark Sproul
Modified 14 August 2012 by Alarus
Updated for 'xmega' core by bob frazier, S.F.T. Inc. - http://mrp3.com/
In some cases, the xmega updates make assumptions about the pin assignments.
See 'pins_arduino.h' for more detail.
*/
#ifndef HardwareSerial_h
#define HardwareSerial_h
#include <inttypes.h>
#include "Stream.h"
struct ring_buffer;
class HardwareSerial : public Stream
{
protected: // NEVER 'private'
// NOTE: xmega uses a structure pointer rather than individual pointers
// and the bit flags are consistent for all USART devices
ring_buffer *_rx_buffer;
ring_buffer *_tx_buffer;
volatile USART_t *_usart;
bool transmitting;
public:
HardwareSerial(ring_buffer *rx_buffer, ring_buffer *tx_buffer, uint16_t usart) __attribute__ ((noinline));
void init(ring_buffer *rx_buffer, ring_buffer *tx_buffer, uint16_t usart) __attribute__ ((noinline));
void begin(unsigned long);
void begin(unsigned long, uint8_t);
void end();
virtual int available(void);
virtual int peek(void);
virtual int read(void);
virtual void flush(void);
virtual size_t write(uint8_t);
inline size_t write(unsigned long n) { return write((uint8_t)n); }
inline size_t write(long n) { return write((uint8_t)n); }
inline size_t write(unsigned int n) { return write((uint8_t)n); }
inline size_t write(int n) { return write((uint8_t)n); }
using Print::write; // pull in write(str) and write(buf, size) from Print
operator bool();
};
// Define config for Serial.begin(baud, config);
// PMODE 5:4 00=none 10=even 11=odd
// SBMODE 3 0=1 stop 1=2 stop
// CHSIZE 2:0 000=5 bit 001=6 bit 010=7 bit 011=8 bit 111=9 bit
#define SERIAL_TWO_STOP _BV(USART_SBMODE_bp)
#define SERIAL_EVEN_PARITY _BV(USART_PMODE1_bp)
#define SERIAL_ODD_PARITY (_BV(USART_PMODE1_bp) | _BV(USART_PMODE0_bp))
#define SERIAL_5N1 0x00
#define SERIAL_6N1 0x01
#define SERIAL_7N1 0x02
#define SERIAL_8N1 0x03
#define SERIAL_5N2 (SERIAL_5N1 | SERIAL_TWO_STOP)
#define SERIAL_6N2 (SERIAL_6N1 | SERIAL_TWO_STOP)
#define SERIAL_7N2 (SERIAL_7N1 | SERIAL_TWO_STOP)
#define SERIAL_8N2 (SERIAL_8N1 | SERIAL_TWO_STOP)
#define SERIAL_5E1 (SERIAL_5N1 | SERIAL_EVEN_PARITY)
#define SERIAL_6E1 (SERIAL_6N1 | SERIAL_EVEN_PARITY)
#define SERIAL_7E1 (SERIAL_7N1 | SERIAL_EVEN_PARITY)
#define SERIAL_8E1 (SERIAL_8N1 | SERIAL_EVEN_PARITY)
#define SERIAL_5E2 (SERIAL_5N2 | SERIAL_EVEN_PARITY)
#define SERIAL_6E2 (SERIAL_6N2 | SERIAL_EVEN_PARITY)
#define SERIAL_7E2 (SERIAL_7N2 | SERIAL_EVEN_PARITY)
#define SERIAL_8E2 (SERIAL_8N2 | SERIAL_EVEN_PARITY)
#define SERIAL_5O1 (SERIAL_5N1 | SERIAL_ODD_PARITY)
#define SERIAL_6O1 (SERIAL_6N1 | SERIAL_ODD_PARITY)
#define SERIAL_7O1 (SERIAL_7N1 | SERIAL_ODD_PARITY)
#define SERIAL_8O1 (SERIAL_8N1 | SERIAL_ODD_PARITY)
#define SERIAL_5O2 (SERIAL_5N2 | SERIAL_ODD_PARITY)
#define SERIAL_6O2 (SERIAL_6N2 | SERIAL_ODD_PARITY)
#define SERIAL_7O2 (SERIAL_7N2 | SERIAL_ODD_PARITY)
#define SERIAL_8O2 (SERIAL_8N2 | SERIAL_ODD_PARITY)
// this is where I must include 'pins_arduino.h' to get the 'USBCON' definition
#include "pins_arduino.h"
// DEFAULT SERIAL or 'SERIAL 1'
#if defined(USBCON)
// NOTE: 'Serial1' will be the hardware serial and 'Serial' the USB serial
// whenever 'USBCON' is defined in pins_arduino.h
#include <USBAPI.h>
extern HardwareSerial Serial1;
#else // normal hardware serial
extern HardwareSerial Serial;
#define Serial1 Serial /* define as 'Serial' so compatible code won't break */
#endif
extern HardwareSerial Serial2; // this is the same regardless of USBCON (there will always be at least 2)
#ifdef SERIAL_2_PORT_NAME /* note these names are off by 1 with the 'Serial_N_' definitions */
extern HardwareSerial Serial3;
#endif // SERIAL_2_PORT_NAME
#ifdef SERIAL_3_PORT_NAME
extern HardwareSerial Serial4;
#endif // SERIAL_3_PORT_NAME
#ifdef SERIAL_4_PORT_NAME
extern HardwareSerial Serial5;
#endif // SERIAL_4_PORT_NAME
#ifdef SERIAL_5_PORT_NAME
extern HardwareSerial Serial6;
#endif // SERIAL_5_PORT_NAME
#ifdef SERIAL_6_PORT_NAME
extern HardwareSerial Serial7;
#endif // SERIAL_6_PORT_NAME
#ifdef SERIAL_7_PORT_NAME
extern HardwareSerial Serial8;
#endif // SERIAL_7_PORT_NAME
// this function calls the serial event handlers. you can override them (hence 'weak')
// the default implementation checks for data available and executes the callback if so
extern void serialEventRun(void) __attribute__((weak));
#endif // HardwareSerial_h

View File

@@ -1,74 +0,0 @@
/*
IPAddress.cpp - Base class that provides IPAddress
Copyright (c) 2011 Adrian McEwen. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <Arduino.h>
#include <IPAddress.h>
IPAddress::IPAddress()
{
memset(_address, 0, sizeof(_address));
}
IPAddress::IPAddress(uint8_t first_octet, uint8_t second_octet, uint8_t third_octet, uint8_t fourth_octet)
{
_address[0] = first_octet;
_address[1] = second_octet;
_address[2] = third_octet;
_address[3] = fourth_octet;
}
IPAddress::IPAddress(uint32_t address)
{
memcpy(_address, &address, sizeof(_address));
}
IPAddress::IPAddress(const uint8_t *address)
{
memcpy(_address, address, sizeof(_address));
}
IPAddress& IPAddress::operator=(const uint8_t *address)
{
memcpy(_address, address, sizeof(_address));
return *this;
}
IPAddress& IPAddress::operator=(uint32_t address)
{
memcpy(_address, (const uint8_t *)&address, sizeof(_address));
return *this;
}
bool IPAddress::operator==(const uint8_t* addr)
{
return memcmp(addr, _address, sizeof(_address)) == 0;
}
size_t IPAddress::printTo(Print& p) const
{
size_t n = 0;
for (int i =0; i < 3; i++)
{
n += p.print(_address[i], DEC);
n += p.print('.');
}
n += p.print(_address[3], DEC);
return n;
}

View File

@@ -1,82 +0,0 @@
/*
IPAddress.h - Base class that provides IPAddress
Copyright (c) 2011 Adrian McEwen. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef IPAddress_h
#define IPAddress_h
#include <Printable.h>
// A class to make it easier to handle and pass around IP addresses
class IPAddress : public Printable
{
private:
uint8_t _address[4]; // IPv4 address
// Access the raw byte array containing the address. Because this returns a pointer
// to the internal structure rather than a copy of the address this function should only
// be used when you know that the usage of the returned uint8_t* will be transient and not
// stored.
uint8_t* raw_address() { return _address; };
public:
// Constructors
IPAddress();
IPAddress(uint8_t first_octet, uint8_t second_octet, uint8_t third_octet, uint8_t fourth_octet);
IPAddress(uint32_t address);
IPAddress(const uint8_t *address);
// Overloaded cast operator to allow IPAddress objects to be used where a pointer
// to a four-byte uint8_t array is expected
operator uint32_t()
{
register const uint32_t *p1 = (const uint32_t *)(const void *)_address;
return *p1;
};
bool operator==(const IPAddress& addr)
{
register const uint32_t *p1 = (const uint32_t*)_address;
register const uint32_t *p2 = (const uint32_t*)(addr._address);
return *p1 == *p2;
};
bool operator==(const uint8_t* addr);
// Overloaded index operator to allow getting and setting individual octets of the address
uint8_t operator[](int index) const { return _address[index]; };
uint8_t& operator[](int index) { return _address[index]; };
// Overloaded copy operators to allow initialisation of IPAddress objects from other types
IPAddress& operator=(const uint8_t *address);
IPAddress& operator=(uint32_t address);
virtual size_t printTo(Print& p) const;
friend class EthernetClass;
friend class UDP;
friend class Client;
friend class Server;
friend class DhcpClass;
friend class DNSClient;
};
const IPAddress INADDR_NONE(0,0,0,0);
#endif

View File

@@ -1,27 +0,0 @@
#ifndef __PLATFORM_H__
#define __PLATFORM_H__
#include <inttypes.h>
#include <avr/pgmspace.h>
#include <avr/eeprom.h>
#include <avr/interrupt.h>
#include <util/delay.h>
#ifndef _PLATFORM_H_TYPES_DEFINED_
#define _PLATFORM_H_TYPES_DEFINED_
// this is a temporary fix for USCore.h data types and header file include order issues
typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned long u32;
#endif // _PLATFORM_H_TYPES_DEFINED_
#include "Arduino.h"
#if defined(USBCON)
#include "USBDesc.h"
#include "USBCore.h"
#include "USBAPI.h"
#endif /* if defined(USBCON) */
#endif

View File

@@ -1,381 +0,0 @@
/*
Print.cpp - Base class that provides print() and println()
Copyright (c) 2008 David A. Mellis. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Modified 23 November 2006 by David A. Mellis
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include "Arduino.h"
#include "Print.h"
// Public Methods //////////////////////////////////////////////////////////////
/* default implementation: may be overridden */
size_t Print::write(const uint8_t *buffer, size_t size)
{
size_t n = 0;
while (size--)
{
register size_t cb = write(*buffer++);
if(!cb) // error return (prevents infinite loops)
{
break;
}
n += cb;
}
return n;
}
size_t Print::print(const __FlashStringHelper *ifsh)
{
PGM_P p = reinterpret_cast<PGM_P>(ifsh);
size_t n = 0;
char tbuf[32]; // will write 32 chars at a time (helps for USB)
register char *p1;
p1 = tbuf;
while (1)
{
unsigned char c = pgm_read_byte(p++);
if(c == 0)
{
if(p1 > &(tbuf[0]))
{
n += write(tbuf, p1 - &(tbuf[0])); // write whatever I've got
}
break;
}
if(p1 >= &(tbuf[sizeof(tbuf)]))
{
register size_t cb = write(tbuf, p1 - &(tbuf[0]));
if(!cb) // error (prevents infinite loops)
{
break;
}
n += cb;
p1 = tbuf;
}
*(p1++) = c;
}
return n;
}
size_t Print::print(const String &s)
{
return write(s.c_str(), s.length());
}
size_t Print::print(const char str[])
{
return write(str);
}
size_t Print::print(char c)
{
return write(c);
}
size_t Print::print(unsigned char b, int base)
{
return print((unsigned long) b, base);
}
size_t Print::print(int n, int base)
{
return print((long) n, base);
}
size_t Print::print(unsigned int n, int base)
{
return print((unsigned long) n, base);
}
size_t Print::print(long n, int base)
{
if (base == 0)
{
return write(n);
}
else if (base == 10)
{
if (n < 0)
{
int t = print('-');
n = -n;
return printNumber(n, 10) + t;
}
return printNumber(n, 10);
}
else
{
return printNumber(n, base);
}
}
size_t Print::print(unsigned long n, int base)
{
if (base == 0)
return write(n);
else
return printNumber(n, base);
}
size_t Print::print(double n, int digits)
{
return printFloat(n, digits);
}
size_t Print::println(const __FlashStringHelper *ifsh)
{
size_t n = print(ifsh);
n += println();
return n;
}
size_t Print::print(const Printable& x)
{
return x.printTo(*this);
}
size_t Print::println(void)
{
char tbuf[2];
tbuf[0] = '\r'; // this should be more efficient, and smaller
tbuf[1] = '\n';
return write(tbuf, 2);
// size_t n = print('\r');
// n += print('\n');
// return n;
}
size_t Print::println(const String &s)
{
size_t n = print(s);
n += println();
return n;
}
size_t Print::println(const char c[])
{
size_t n = print(c);
n += println();
return n;
}
size_t Print::println(char c)
{
size_t n = print(c);
n += println();
return n;
}
size_t Print::println(unsigned char b, int base)
{
size_t n = print(b, base);
n += println();
return n;
}
size_t Print::println(int num, int base)
{
size_t n = print(num, base);
n += println();
return n;
}
size_t Print::println(unsigned int num, int base)
{
size_t n = print(num, base);
n += println();
return n;
}
size_t Print::println(long num, int base)
{
size_t n = print(num, base);
n += println();
return n;
}
size_t Print::println(unsigned long num, int base)
{
size_t n = print(num, base);
n += println();
return n;
}
size_t Print::println(double num, int digits)
{
size_t n = print(num, digits);
n += println();
return n;
}
size_t Print::println(const Printable& x)
{
size_t n = print(x);
n += println();
return n;
}
// Private Methods /////////////////////////////////////////////////////////////
size_t Print::printNumber(unsigned long n, uint8_t base)
{
char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte.
char *str = &buf[sizeof(buf) - 1];
*str = '\0';
// prevent crash if called with base == 1
if (base < 2)
base = 10;
do
{
unsigned long m = n;
n /= base;
char c = m - base * n;
*--str = c < 10 ? c + '0' : c + 'A' - 10;
} while(n);
return write(str);
}
size_t Print::printFloat(double number, uint8_t digits)
{
size_t n = 0;
if (isnan(number))
return print("nan");
if (isinf(number))
return print("inf");
if (number > 4294967040.0)
return print ("ovf"); // constant determined empirically
if (number <-4294967040.0)
return print ("ovf"); // constant determined empirically
// Handle negative numbers
if (number < 0.0)
{
n += print('-');
number = -number;
}
// Round correctly so that print(1.999, 2) prints as "2.00"
double rounding = 0.5;
for (uint8_t i=0; i<digits; ++i)
{
rounding /= 10.0;
}
number += rounding;
// Extract the integer part of the number and print it
unsigned long int_part = (unsigned long)number;
double remainder = number - (double)int_part;
n += print(int_part);
// Print the decimal point, but only if there are digits beyond
if (digits > 0)
{
n += print(".");
}
// Extract digits from the remainder one at a time
while (digits-- > 0)
{
remainder *= 10.0;
int toPrint = int(remainder);
n += print(toPrint);
remainder -= toPrint;
}
return n;
}
// things that I added
int Print::printf(const char *pszFormat, ...) /*__attribute__ ((format(printf, 2, 3)))*/ // added API for 'printf' since it has been suggested...
{
va_list va;
int cbOut;
va_start(va, pszFormat);
cbOut = vsnprintf(NULL, 0, pszFormat, va);
if(cbOut > 0)
{
char *p1 = (char *)malloc(cbOut + 2);
if(p1)
{
cbOut = vsnprintf(p1, cbOut + 1, pszFormat, va);
print(p1);
free(p1);
}
}
va_end(va);
return cbOut;
}
int Print::printf_P(const char *pszFormat, ...) /*__attribute__ ((format(printf_P, 2, 3)))*/ // added API for 'printf' since it has been suggested...
{
va_list va;
int cbOut;
va_start(va, pszFormat);
cbOut = vsnprintf_P(NULL, 0, (const char *)pszFormat, va);
if(cbOut > 0)
{
char *p1 = (char *)malloc(cbOut + 2);
if(p1)
{
cbOut = vsnprintf_P(p1, cbOut + 1, (const char *)pszFormat, va);
print(p1);
free(p1);
}
}
va_end(va);
return cbOut;
}

View File

@@ -1,97 +0,0 @@
/*
Print.h - Base class that provides print() and println()
Copyright (c) 2008 David A. Mellis. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef Print_h
#define Print_h
#include <inttypes.h>
#include <stdio.h> // for size_t
#include "WString.h"
#include "Printable.h"
#define DEC 10
#define HEX 16
#define OCT 8
#define BIN 2
class Print
{
private:
int write_error;
size_t printNumber(unsigned long, uint8_t);
size_t printFloat(double, uint8_t);
protected:
void setWriteError(int err = 1) { write_error = err; }
public:
Print() : write_error(0) {} // default constructor only assigns 0 to 'write_error'
int getWriteError() { return write_error; }
void clearWriteError() { setWriteError(0); }
virtual size_t write(uint8_t) = 0; // derived class must implement
size_t write(const char *str)
{
if (str == NULL) return 0;
return write((const uint8_t *)str, strlen(str));
}
// write multiple characters from a buffer - default calls 'write(uint8_t)' on each byte
// NOTE: for better efficiency, a derived class SHOULD implement its own 'write' for a buffer
virtual size_t write(const uint8_t *buffer, size_t size); // overridable
size_t write(const char *buffer, size_t size)
{
return write((const uint8_t *)buffer, size);
}
// custom mod - implement 'printf' member function
int printf(const char *pszFormat, ...) __attribute__ ((format(printf, 2, 3))); // added API for 'printf' since it has been suggested...
int printf_P(const char *pszFormat, ...) __attribute__ ((format(printf, 2, 3))); // added API for 'printf_P' since it has been suggested...
size_t print(const __FlashStringHelper *);
size_t print(const String &);
size_t print(const char[]);
size_t print(char);
size_t print(unsigned char, int = DEC);
size_t print(int, int = DEC);
size_t print(unsigned int, int = DEC);
size_t print(long, int = DEC);
size_t print(unsigned long, int = DEC);
size_t print(double, int = 2);
size_t print(const Printable&);
size_t println(const __FlashStringHelper *);
size_t println(const String &s);
size_t println(const char[]);
size_t println(char);
size_t println(unsigned char, int = DEC);
size_t println(int, int = DEC);
size_t println(unsigned int, int = DEC);
size_t println(long, int = DEC);
size_t println(unsigned long, int = DEC);
size_t println(double, int = 2);
size_t println(const Printable&);
size_t println(void);
};
#endif

View File

@@ -1,40 +0,0 @@
/*
Printable.h - Interface class that allows printing of complex types
Copyright (c) 2011 Adrian McEwen. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef Printable_h
#define Printable_h
#include <new.h>
class Print;
/** The Printable class provides a way for new classes to allow themselves to be printed.
By deriving from Printable and implementing the printTo method, it will then be possible
for users to print out instances of this class by passing them into the usual
Print::print and Print::println methods.
*/
class Printable
{
public:
virtual size_t printTo(Print& p) const = 0;
};
#endif

View File

@@ -1,28 +0,0 @@
/*
Server.h - Base class that provides Server
Copyright (c) 2011 Adrian McEwen. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef server_h
#define server_h
class Server : public Print {
public:
virtual void begin() =0;
};
#endif

View File

@@ -1,362 +0,0 @@
/*
Stream.cpp - adds parsing methods to Stream class
Copyright (c) 2008 David A. Mellis. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Created July 2011
parsing functions based on TextFinder library by Michael Margolis
*/
#include "Arduino.h"
#include "Stream.h"
// if/branch optimization
#define UNLIKELY(x) (__builtin_expect (!!(x), 0))
#define LIKELY(x) (__builtin_expect (!!(x), 1))
#define PARSE_TIMEOUT 1000 // default number of milli-seconds to wait
#define NO_SKIP_CHAR 1 // a magic char not found in a valid ASCII numeric field
// private method to read stream with timeout
int Stream::timedRead()
{
int c;
_startMillis = millis();
do
{
c = read();
if (c >= 0)
return c;
wait_for_interrupt(); // XMega enhancement
} while(millis() - _startMillis < _timeout);
return -1; // -1 indicates timeout
}
// private method to peek stream with timeout
int Stream::timedPeek()
{
int c;
_startMillis = millis();
do
{
c = peek();
if (c >= 0)
return c;
wait_for_interrupt(); // XMega enhancement
} while(millis() - _startMillis < _timeout);
return -1; // -1 indicates timeout
}
// returns peek of the next digit in the stream or -1 if timeout
// discards non-numeric characters
int Stream::peekNextDigit()
{
int c;
while (1)
{
c = timedPeek();
// refactored this for (possibly) better efficiency AND readability - seems to be the same size/footprint
// if (c < 0)
// return c; // timeout
//
// if (c == '-')
// return c;
//
// if (c >= '0' && c <= '9')
// return c;
if(UNLIKELY(c < 0) || // refactored. < 0 is a timeout
UNLIKELY(c == '-') || // negative (TODO: test for leading char only, or lead on exponent)
LIKELY(c >= '0' && c <= '9')) // numeric digit; TODO test for exponent on float?
{
return c;
}
read(); // discard non-numeric
}
}
// Public Methods
//////////////////////////////////////////////////////////////
void Stream::setTimeout(unsigned long timeout) // sets the maximum number of milliseconds to wait
{
_timeout = timeout;
}
// find returns true if the target string is found
bool Stream::find(char *target)
{
return findUntil(target, NULL/*""*/);
}
// reads data from the stream until the target string of given length is found
// returns true if target string is found, false if timed out
bool Stream::find(char *target, size_t length)
{
return findUntil(target, length, NULL, 0);
}
// as find but search ends if the terminator string is found
bool Stream::findUntil(char *target, char *terminator)
{
return findUntil(target, strlen(target), terminator, strlen(terminator));
}
// reads data from the stream until the target string of the given length is found
// search terminated if the terminator string is found
// returns true if target string is found, false if terminated or timed out
bool Stream::findUntil(char *target, size_t targetLen, char *terminator, size_t termLen)
{
size_t index = 0; // maximum target string length is 64k bytes!
size_t termIndex = 0;
int c;
if(!target || *target == 0) // update, allow NULL pointer
{
return true; // return true if target is a null string
}
while( (c = timedRead()) > 0)
{
if(c != target[index])
{
index = 0; // reset index if any char does not match
}
if( c == target[index])
{
//////Serial.print("found "); Serial.write(c); Serial.print("index now"); Serial.println(index+1);
if(++index >= targetLen) // return true if all chars in the target match
{
return true;
}
}
// allow for NULL 'terminator'
if(terminator && termLen > 0 &&
UNLIKELY(c == terminator[termIndex]))
{
if(++termIndex >= termLen)
{
return false; // return false if terminate string found before target string
}
}
else
{
termIndex = 0;
}
}
return false;
}
// returns the first valid (long) integer value from the current position.
// initial characters that are not digits (or the minus sign) are skipped
// function is terminated by the first character that is not a digit.
long Stream::parseInt()
{
return parseInt(NO_SKIP_CHAR); // terminate on first non-digit character (or timeout)
}
// as above but a given skipChar is ignored
// this allows format characters (typically commas) in values to be ignored
long Stream::parseInt(char skipChar)
{
boolean isNegative = false;
long value = 0;
int c;
c = peekNextDigit();
// ignore non numeric leading characters
if(c < 0)
return 0; // zero returned if timeout
do
{
if(c == skipChar)
; // ignore this charactor
else if(c == '-')
isNegative = true;
else if(c >= '0' && c <= '9') // is c a digit?
value = value * 10 + c - '0';
read(); // consume the character we got with peek
c = timedPeek();
}
while( (c >= '0' && c <= '9') || c == skipChar )
;
if(isNegative)
value = -value;
return value;
}
// as parseInt but returns a floating point value
float Stream::parseFloat()
{
return parseFloat(NO_SKIP_CHAR);
}
// as above but the given skipChar is ignored
// this allows format characters (typically commas) in values to be ignored
float Stream::parseFloat(char skipChar)
{
boolean isNegative = false;
boolean isFraction = false;
long value = 0;
char c;
float fraction = 1.0;
c = peekNextDigit();
// ignore non numeric leading characters
if(c < 0)
{
return 0; // zero returned if timeout
}
do
{
if(c == skipChar)
{
// ignore
}
else if(c == '-')
{
isNegative = true;
}
else if (c == '.')
{
isFraction = true;
}
else if(c >= '0' && c <= '9') // is c a digit?
{
value = value * 10 + c - '0';
if(isFraction)
{
fraction *= 0.1;
}
}
read(); // consume the character we got with peek
c = timedPeek();
}
while( (c >= '0' && c <= '9') || c == '.' || c == skipChar )
;
if(isNegative)
value = -value;
if(isFraction)
return value * fraction;
else
return value;
}
// read characters from stream into buffer
// terminates if length characters have been read, or timeout (see setTimeout)
// returns the number of characters placed in the buffer
// the buffer is NOT null terminated.
//
size_t Stream::readBytes(char *buffer, size_t length)
{
size_t count = 0;
while (count < length)
{
int c = timedRead();
if (c < 0)
break;
*buffer++ = (char)c;
count++;
}
return count;
}
// as readBytes with terminator character
// terminates if length characters have been read, timeout, or if the terminator character detected
// returns the number of characters placed in the buffer (0 means no valid data found)
size_t Stream::readBytesUntil(char terminator, char *buffer, size_t length)
{
if (length < 1)
return 0;
size_t index = 0;
while (index < length)
{
int c = timedRead();
if (c < 0 || c == terminator) break;
*buffer++ = (char)c;
index++;
}
return index; // return number of characters, not including null terminator
}
String Stream::readString()
{
String ret;
int c = timedRead();
while (c >= 0)
{
ret += (char)c;
c = timedRead();
}
return ret;
}
String Stream::readStringUntil(char terminator)
{
String ret;
int c = timedRead();
while (c >= 0 && c != terminator)
{
ret += (char)c;
c = timedRead();
}
return ret;
}

View File

@@ -1,96 +0,0 @@
/*
Stream.h - base class for character-based streams.
Copyright (c) 2010 David A. Mellis. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
parsing functions based on TextFinder library by Michael Margolis
*/
#ifndef Stream_h
#define Stream_h
#include <inttypes.h>
#include "Print.h"
// compatability macros for testing
/*
#define getInt() parseInt()
#define getInt(skipChar) parseInt(skipchar)
#define getFloat() parseFloat()
#define getFloat(skipChar) parseFloat(skipChar)
#define getString( pre_string, post_string, buffer, length)
readBytesBetween( pre_string, terminator, buffer, length)
*/
class Stream : public Print
{
protected:
unsigned long _timeout; // number of milliseconds to wait for the next char before aborting timed read
unsigned long _startMillis; // used for timeout measurement
int timedRead(); // private method to read stream with timeout
int timedPeek(); // private method to peek stream with timeout
int peekNextDigit(); // returns the next numeric digit in the stream or -1 if timeout
public:
virtual int available() = 0;
virtual int read() = 0;
virtual int peek() = 0;
virtual void flush() = 0;
Stream() {_timeout=1000;}
// parsing methods
void setTimeout(unsigned long timeout); // sets maximum milliseconds to wait for stream data, default is 1 second
bool find(char *target); // reads data from the stream until the target string is found
// returns true if target string is found, false if timed out (see setTimeout)
bool find(char *target, size_t length); // reads data from the stream until the target string of given length is found
// returns true if target string is found, false if timed out
bool findUntil(char *target, char *terminator); // as find but search ends if the terminator string is found
bool findUntil(char *target, size_t targetLen, char *terminate, size_t termLen); // as above but search ends if the terminate string is found
long parseInt(); // returns the first valid (long) integer value from the current position.
// initial characters that are not digits (or the minus sign) are skipped
// integer is terminated by the first character that is not a digit.
float parseFloat(); // float version of parseInt
size_t readBytes( char *buffer, size_t length); // read chars from stream into buffer
// terminates if length characters have been read or timeout (see setTimeout)
// returns the number of characters placed in the buffer (0 means no valid data found)
size_t readBytesUntil( char terminator, char *buffer, size_t length); // as readBytes with terminator character
// terminates if length characters have been read, timeout, or if the terminator character detected
// returns the number of characters placed in the buffer (0 means no valid data found)
// Arduino String functions to be added here
String readString();
String readStringUntil(char terminator);
protected:
long parseInt(char skipChar); // as above but the given skipChar is ignored
// as above but the given skipChar is ignored
// this allows format characters (typically commas) in values to be ignored
float parseFloat(char skipChar); // as above but the given skipChar is ignored
};
#endif

View File

@@ -1,960 +0,0 @@
/* Tone.cpp
A Tone Generator Library
Written by Brett Hagman
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Version Modified By Date Comments
------- ----------- -------- --------
0001 B Hagman 09/08/02 Initial coding
0002 B Hagman 09/08/18 Multiple pins
0003 B Hagman 09/08/18 Moved initialization from constructor to begin()
0004 B Hagman 09/09/26 Fixed problems with ATmega8
0005 B Hagman 09/11/23 Scanned prescalars for best fit on 8 bit timers
09/11/25 Changed pin toggle method to XOR
09/11/25 Fixed timer0 from being excluded
0006 D Mellis 09/12/29 Replaced objects with functions
0007 M Sproul 10/08/29 Changed #ifdefs from cpu to register
0008 S Kanemoto 12/06/22 Fixed for Leonardo by @maris_HY
*************************************************/
// COMPLETE re-write for ATXMega by Bob Frazier, S.F.T. Inc. - http://mrp3.com/
// NOTE: this still only supports one tone output. However, xmega can do more than one
// due to the way the timers are. In fact, 'E' series can probably do a LOT more
// than one. If you want to implement that, it's a public project, so get it working
// reliably and submit the changes, thanks.
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
#include "Arduino.h"
#include "pins_arduino.h"
#if defined(TCC4) || !defined(TCC2)
// in these cases this file isn't ready for prime time, so disable it for now
#ifdef TONE_SUPPORTED
#undef TONE_SUPPORTED
#endif // TONE_SUPPORTED
#else // !TCC4 && TCC2
#ifndef TONE_SUPPORTED
#define TONE_SUPPORTED // for now turn it off for 'E"
#endif // TONE_SUPPORTED
#endif // TCC4 || !TCC2
#ifdef TONE_SUPPORTED
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
#define PROGMEM_ORIG PROGMEM
#else // PROGMEM workaround
// to avoid the bogus "initialized variables" warning
#ifdef PROGMEM
#undef PROGMEM
#endif // PROGMEM re-define
#define PROGMEM __attribute__((section(".progmem.tone")))
#define PROGMEM_ORIG __attribute__((__progmem__))
#endif // check for GNUC >= or < 4.6
static PORT_t *pTonePort = NULL; // must assign at startup due to ISR
static uint8_t bToneMask = 0; // bitmask for tone pin
static unsigned long toggle_count = 0; // number of cycles to output
static void toneBegin(uint8_t _pin, uint8_t _div, uint16_t _per)
{
pTonePort = (PORT_t *)portModeRegister(digitalPinToPort(_pin));
bToneMask = digitalPinToBitMask(_pin);
// Set the pinMode as OUTPUT
pinMode(_pin, OUTPUT);
#if NUM_DIGITAL_PINS > 18 /* meaning there is a PORT E available */
TCE0_INTCTRLA = 0; // temporarily disable overflow interrupt
TCE0_INTCTRLB = 0; // disable other interrupts
TCE0_CTRLA = _div; // divisor for pre-scaler
TCE0_CTRLB = TC_WGMODE_NORMAL_gc; // 'normal' mode (interrupt on 'overflow')
TCE0_CTRLD = 0; // not an event timer, 16-bit mode (12.11.4)
TCE0_CTRLE = 0; // 16-bit mode
TCE0_PER = _per; // period (16-bit value)
TCE0_INTCTRLA = 3; // overflow int level 3 (enables interrupt)
#elif defined(TCC4) // E series and anything else with 'TCC4'
TCC4_INTCTRLA = 0; // temporarily disable overflow interrupt
TCC4_INTCTRLB = 0; // disable other interrupts
TCC4_CTRLA = _div; // divisor for pre-scaler
TCC4_CTRLB = TC45_WGMODE_NORMAL_gc; // 'normal' mode (interrupt on 'overflow')
TCC4_CTRLD = 0; // not an event timer, 16-bit mode (12.11.4)
TCC4_CTRLE = 0; // 16-bit mode
TCC4_PER = _per; // period (16-bit value)
TCC4_INTCTRLA = 3; // overflow int level 3 (enables interrupt)
#else // other stuff not yet explored by me
TCC0_INTCTRLA = 0; // temporarily disable overflow interrupt
TCC0_INTCTRLB = 0; // disable other interrupts
TCC0_CTRLA = _div; // divisor for pre-scaler
TCC0_CTRLB = TC_WGMODE_NORMAL_gc; // 'normal' mode (interrupt on 'overflow')
TCC0_CTRLD = 0; // not an event timer, 16-bit mode (12.11.4)
TCC0_CTRLE = 0; // 16-bit mode
TCC0_PER = _per; // period (16-bit value)
TCC0_INTCTRLA = 3; // overflow int level 3 (enables interrupt)
#endif // NUM_DIGITAL_PINS > 18
// tone starts now, shuts off when the 'toggle_count' hits zero
}
// frequency (in hertz) and duration (in milliseconds).
void tone(uint8_t _pin, unsigned int frequency, unsigned long duration)
{
register int8_t b1;
unsigned short per, w2;
unsigned long ulTemp;
static const uint16_t aPreScaler[] PROGMEM = {1,2,4,8,64,256,1024}; // pre-scaler
// frequency
// based on the frequency, set up the divider and period
// period is 16-bits
// NOTE: use the smallest possible divisor
if(!frequency)
{
return;
}
ulTemp = frequency * 16384L; // ideal counter 16384
for(b1=sizeof(aPreScaler)/sizeof(aPreScaler[0]) - 1; b1 > 0; b1--)
{
w2 = pgm_read_word(&(aPreScaler[0]) + b1);
if(((unsigned long)F_CPU / 2 / w2) >= ulTemp) // note that I flip the bit every OTHER cycle
{
break;
}
}
if(!b1)
{
w2 = 1; // make sure
}
// b1 is the divisor bit value for CTRLA, per caches the actual divisor
per = (F_CPU / 2 / w2) / frequency;
if(!per)
{
per++;
}
// Calculate the toggle count
if (duration > 0)
{
toggle_count = 2 * frequency * duration / 1000;
}
else
{
toggle_count = -1;
}
toneBegin(_pin, b1, per);
}
// XXX: this function only works properly for timer E (the only one we use
// currently). Since I use the ISR on timer E to toggle the pin, it should
// be just fine.
void disableTimer(uint8_t _timer)
{
// parameter is ignored
#if NUM_DIGITAL_PINS > 18 /* meaning there is a PORT E available */
// disable under/overflow and comparison interrupts FIRST
TCE0_INTCTRLA = 0; // no underflow interrupts
TCE0_INTCTRLB = 0; // no comparison interrupts
pTonePort = NULL; // make sure
// re-assign TCE0 defaults. see 'wiring.c'
#if NUM_DIGITAL_PINS > 22 /* meaning PORTE has 8 pins */
TCE2_CTRLA = 5; // b0101 - divide by 64 - D manual 13.9.1
TCE2_CTRLB = 0; // compare outputs disabled on all 8 bits (13.9.2)
// TCE2_CTRLC = 0; // when timer not running, sets compare (13.9.3)
TCE2_CTRLE = 0x2; // b10 - 'split' mode - D manual 13.9.4
TCE2_CTRLF = 0; // not resetting or anything (13.9.7)
TCE2_LPER = 255; // count 255 to 0 (total period = 256)
TCE2_HPER = 255;
// pre-assign comparison registers to 'zero' (for PWM out) which is actually 255
// 'timer 2' counts DOWN. This, however, would generate a '1' output.
TCE2_LCMPA = 255;
TCE2_LCMPB = 255;
TCE2_LCMPC = 255;
TCE2_LCMPD = 255;
TCE2_HCMPA = 255;
TCE2_HCMPB = 255;
TCE2_HCMPC = 255;
TCE2_HCMPD = 255;
TCE2_INTCTRLA = 0; // no underflow interrupts
TCE2_INTCTRLB = 0; // no comparison interrupts
#else // 16-bit timer on TCE0
TCE0_CTRLA = 5; // b0101 - divide by 64 - D manual 12.11.1
TCE0_CTRLB = TC_WGMODE_SS_gc; // single-slope PWM. NOTE: this counts UP, whereas the other timers count DOWN
// other bits (high nybble) are OFF - they enable output on the 4 port E pins
// TCE0_CTRLC = 0; // when timer not running, sets compare (12.11.3)
TCE0_CTRLD = 0; // not an event timer, 16-bit mode (12.11.4)
TCE0_CTRLE = 1; // normal 8-bit timer (set to 0 for 16-bit mode) (12.11.5)
// make sure the timer E 'period' register is correctly set at 255 (i.e. 0-255 or 256 clock cycles).
TCE0_PER = 255;
// pre-assign comparison registers to 'zero' (for PWM out) which is actually 255
// timer 0 can be configured to count UP or DOWN, but for single-slope PWM it is
// always 'UP'. A value of '255' should generate a '1' output for each PWM.
TCE0_CCA = 255;
TCE0_CCB = 255;
TCE0_CCC = 255;
TCE0_CCD = 255;
#endif // 8/16 bit timer on E
#elif defined(TCC4) // E series and anything else with 'TCC4'
// disable under/overflow and comparison interrupts FIRST
TCC4_INTCTRLA = 0; // no underflow interrupts
TCC4_INTCTRLB = 0; // no comparison interrupts
pTonePort = NULL; // make sure
// re-assign TCC0 defaults. see 'wiring.c'
TCC4_CTRLA = 5; // b0101 - divide by 64 - E manual 13.13.1
TCC4_CTRLB = TC45_BYTEM_BYTEMODE_gc | TC45_WGMODE_SINGLESLOPE_gc; // byte mode, single slope
// TCC5_CTRLC = 0; // when timer not running, sets compare (13.9.3)
TCC4_CTRLD = 0; // events off
TCC4_CTRLE = 0; // no output on L pins
TCC4_CTRLF = 0; // no output on H pins
TCC4_PER = 255; // 255 for period limit
// pre-assign comparison registers to 'zero' (for PWM out) which is actually 255
// 'timer 2' counts DOWN.
TCC4_CCA = 65535;
TCC4_CCB = 65535;
TCC4_CCC = 65535;
TCC4_CCD = 65535;
#else // other stuff not yet explored by me
// disable under/overflow and comparison interrupts FIRST
TCC0_INTCTRLA = 0; // no underflow interrupts
TCC0_INTCTRLB = 0; // no comparison interrupts
pTonePort = NULL; // make sure
// re-assign TCC0 defaults. see 'wiring.c'
TCC2_CTRLA = 5; // b0101 - divide by 64 - D manual 13.9.1
TCC2_CTRLB = 0; // compare outputs disabled on all 8 bits (13.9.2)
// TCC2_CTRLC = 0; // when timer not running, sets compare (13.9.3)
TCC2_CTRLE = 0x2; // b10 - 'split' mode - D manual 13.9.4
TCC2_CTRLF = 0; // not resetting or anything (13.9.7)
TCC2_LPER = 255; // count 255 to 0 (total period = 256)
TCC2_HPER = 255;
// pre-assign comparison registers to 'zero' (for PWM out) which is actually 255
// 'timer 2' counts DOWN. This, however, would generate a '1' output.
TCC2_LCMPA = 255;
TCC2_LCMPB = 255;
TCC2_LCMPC = 255;
TCC2_LCMPD = 255;
TCC2_HCMPA = 255;
TCC2_HCMPB = 255;
TCC2_HCMPC = 255;
TCC2_HCMPD = 255;
TCC2_INTCTRLA = 0; // no underflow interrupts
TCC2_INTCTRLB = 0; // no comparison interrupts
#endif // NUM_DIGITAL_PINS > 18
}
void noTone(uint8_t _pin)
{
disableTimer(0);
digitalWrite(_pin, 0);
}
#if NUM_DIGITAL_PINS > 18 /* meaning PORTE exists */
ISR(TCE0_OVF_vect) // the 'overflow' vector on timer E0
#elif defined(TCC4) // E series and anything else with 'TCC4'
ISR(TCC4_OVF_vect) // the 'overflow' vector on timer C4
#else // everything else
ISR(TCC0_OVF_vect) // the 'overflow' vector on timer C0
#endif // PORTE exist check
{
if(!toggle_count || !pTonePort || !bToneMask
#if 1 /* this section in for bullet-proofing, consider removing */
|| (pTonePort != &PORTA &&
#if NUM_ANALOG_PINS > 8
pTonePort != &PORTB &&
#endif // NUM_ANALOG_PINS > 8
pTonePort != &PORTC && pTonePort != &PORTD &&
#if NUM_DIGITAL_PINS > 18
pTonePort != &PORTE &&
#endif // PORTE exist check
pTonePort != &PORTR)
#endif // 1
)
{
// disable the timer (also disables the interrupt)
disableTimer(0);
return;
}
// each time I get an overflow, toggle the tone pin
pTonePort->OUTTGL = bToneMask; // toggle that bit
toggle_count--;
}
#if 0 // OLD CODE for reference only
#if defined(__AVR_ATmega8__) || defined(__AVR_ATmega128__)
#define TCCR2A TCCR2
#define TCCR2B TCCR2
#define COM2A1 COM21
#define COM2A0 COM20
#define OCR2A OCR2
#define TIMSK2 TIMSK
#define OCIE2A OCIE2
#define TIMER2_COMPA_vect TIMER2_COMP_vect
#define TIMSK1 TIMSK
#endif
// timerx_toggle_count:
// > 0 - duration specified
// = 0 - stopped
// < 0 - infinitely (until stop() method called, or new play() called)
#if !defined(__AVR_ATmega8__)
volatile long timer0_toggle_count;
volatile uint8_t *timer0_pin_port;
volatile uint8_t timer0_pin_mask;
#endif
volatile long timer1_toggle_count;
volatile uint8_t *timer1_pin_port;
volatile uint8_t timer1_pin_mask;
volatile long timer2_toggle_count;
volatile uint8_t *timer2_pin_port;
volatile uint8_t timer2_pin_mask;
#if defined(TIMSK3)
volatile long timer3_toggle_count;
volatile uint8_t *timer3_pin_port;
volatile uint8_t timer3_pin_mask;
#endif
#if defined(TIMSK4)
volatile long timer4_toggle_count;
volatile uint8_t *timer4_pin_port;
volatile uint8_t timer4_pin_mask;
#endif
#if defined(TIMSK5)
volatile long timer5_toggle_count;
volatile uint8_t *timer5_pin_port;
volatile uint8_t timer5_pin_mask;
#endif
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
#define AVAILABLE_TONE_PINS 1
#define USE_TIMER2
const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { 2 /*, 3, 4, 5, 1, 0 */ };
static uint8_t tone_pins[AVAILABLE_TONE_PINS] = { 255 /*, 255, 255, 255, 255, 255 */ };
#elif defined(__AVR_ATmega8__)
#define AVAILABLE_TONE_PINS 1
#define USE_TIMER2
const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { 2 /*, 1 */ };
static uint8_t tone_pins[AVAILABLE_TONE_PINS] = { 255 /*, 255 */ };
#elif defined(__AVR_ATmega32U4__)
#define AVAILABLE_TONE_PINS 1
#define USE_TIMER3
const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { 3 /*, 1 */ };
static uint8_t tone_pins[AVAILABLE_TONE_PINS] = { 255 /*, 255 */ };
#else
#define AVAILABLE_TONE_PINS 1
#define USE_TIMER2
// Leave timer 0 to last.
const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { 2 /*, 1, 0 */ };
static uint8_t tone_pins[AVAILABLE_TONE_PINS] = { 255 /*, 255, 255 */ };
#endif
// NOTE: K&R coding style edited away. Allman style rules - BF
static int8_t toneBegin(uint8_t _pin)
{
int8_t _timer = -1;
// if we're already using the pin, the timer should be configured.
for (int i = 0; i < AVAILABLE_TONE_PINS; i++)
{
if (tone_pins[i] == _pin)
{
return pgm_read_byte(tone_pin_to_timer_PGM + i);
}
}
// search for an unused timer.
for (int i = 0; i < AVAILABLE_TONE_PINS; i++)
{
if (tone_pins[i] == 255)
{
tone_pins[i] = _pin;
_timer = pgm_read_byte(tone_pin_to_timer_PGM + i);
break;
}
}
if (_timer != -1)
{
// Set timer specific stuff
// All timers in CTC mode
// 8 bit timers will require changing prescalar values,
// whereas 16 bit timers are set to either ck/1 or ck/64 prescalar
switch (_timer)
{
#if defined(TCCR0A) && defined(TCCR0B)
case 0:
// 8 bit timer
TCCR0A = 0;
TCCR0B = 0;
bitWrite(TCCR0A, WGM01, 1);
bitWrite(TCCR0B, CS00, 1);
timer0_pin_port = portOutputRegister(digitalPinToPort(_pin));
timer0_pin_mask = digitalPinToBitMask(_pin);
break;
#endif
#if defined(TCCR1A) && defined(TCCR1B) && defined(WGM12)
case 1:
// 16 bit timer
TCCR1A = 0;
TCCR1B = 0;
bitWrite(TCCR1B, WGM12, 1);
bitWrite(TCCR1B, CS10, 1);
timer1_pin_port = portOutputRegister(digitalPinToPort(_pin));
timer1_pin_mask = digitalPinToBitMask(_pin);
break;
#endif
#if defined(TCCR2A) && defined(TCCR2B)
case 2:
// 8 bit timer
TCCR2A = 0;
TCCR2B = 0;
bitWrite(TCCR2A, WGM21, 1);
bitWrite(TCCR2B, CS20, 1);
timer2_pin_port = portOutputRegister(digitalPinToPort(_pin));
timer2_pin_mask = digitalPinToBitMask(_pin);
break;
#endif
#if defined(TCCR3A) && defined(TCCR3B) && defined(TIMSK3)
case 3:
// 16 bit timer
TCCR3A = 0;
TCCR3B = 0;
bitWrite(TCCR3B, WGM32, 1);
bitWrite(TCCR3B, CS30, 1);
timer3_pin_port = portOutputRegister(digitalPinToPort(_pin));
timer3_pin_mask = digitalPinToBitMask(_pin);
break;
#endif
#if defined(TCCR4A) && defined(TCCR4B) && defined(TIMSK4)
case 4:
// 16 bit timer
TCCR4A = 0;
TCCR4B = 0;
#if defined(WGM42)
bitWrite(TCCR4B, WGM42, 1);
#elif defined(CS43)
#warning this may not be correct
// atmega32u4
bitWrite(TCCR4B, CS43, 1);
#endif
bitWrite(TCCR4B, CS40, 1);
timer4_pin_port = portOutputRegister(digitalPinToPort(_pin));
timer4_pin_mask = digitalPinToBitMask(_pin);
break;
#endif
#if defined(TCCR5A) && defined(TCCR5B) && defined(TIMSK5)
case 5:
// 16 bit timer
TCCR5A = 0;
TCCR5B = 0;
bitWrite(TCCR5B, WGM52, 1);
bitWrite(TCCR5B, CS50, 1);
timer5_pin_port = portOutputRegister(digitalPinToPort(_pin));
timer5_pin_mask = digitalPinToBitMask(_pin);
break;
#endif
}
}
return _timer;
}
// frequency (in hertz) and duration (in milliseconds).
void tone(uint8_t _pin, unsigned int frequency, unsigned long duration)
{
uint8_t prescalarbits = 0b001;
long toggle_count = 0;
uint32_t ocr = 0;
int8_t _timer;
_timer = toneBegin(_pin);
if (_timer >= 0)
{
// Set the pinMode as OUTPUT
pinMode(_pin, OUTPUT);
// if we are using an 8 bit timer, scan through prescalars to find the best fit
if (_timer == 0 || _timer == 2)
{
ocr = F_CPU / frequency / 2 - 1;
prescalarbits = 0b001; // ck/1: same for both timers
if (ocr > 255)
{
ocr = F_CPU / frequency / 2 / 8 - 1;
prescalarbits = 0b010; // ck/8: same for both timers
if (_timer == 2 && ocr > 255)
{
ocr = F_CPU / frequency / 2 / 32 - 1;
prescalarbits = 0b011;
}
if (ocr > 255)
{
ocr = F_CPU / frequency / 2 / 64 - 1;
prescalarbits = _timer == 0 ? 0b011 : 0b100;
if (_timer == 2 && ocr > 255)
{
ocr = F_CPU / frequency / 2 / 128 - 1;
prescalarbits = 0b101;
}
if (ocr > 255)
{
ocr = F_CPU / frequency / 2 / 256 - 1;
prescalarbits = _timer == 0 ? 0b100 : 0b110;
if (ocr > 255)
{
// can't do any better than /1024
ocr = F_CPU / frequency / 2 / 1024 - 1;
prescalarbits = _timer == 0 ? 0b101 : 0b111;
}
}
}
}
#if defined(TCCR0B)
if (_timer == 0)
{
TCCR0B = prescalarbits;
}
else
#endif
#if defined(TCCR2B)
{
TCCR2B = prescalarbits;
}
#else
{
// dummy place holder to make the above ifdefs work
}
#endif
}
else
{
// two choices for the 16 bit timers: ck/1 or ck/64
ocr = F_CPU / frequency / 2 - 1;
prescalarbits = 0b001;
if (ocr > 0xffff)
{
ocr = F_CPU / frequency / 2 / 64 - 1;
prescalarbits = 0b011;
}
if (_timer == 1)
{
#if defined(TCCR1B)
TCCR1B = (TCCR1B & 0b11111000) | prescalarbits;
#endif
}
#if defined(TCCR3B)
else if (_timer == 3)
TCCR3B = (TCCR3B & 0b11111000) | prescalarbits;
#endif
#if defined(TCCR4B)
else if (_timer == 4)
TCCR4B = (TCCR4B & 0b11111000) | prescalarbits;
#endif
#if defined(TCCR5B)
else if (_timer == 5)
TCCR5B = (TCCR5B & 0b11111000) | prescalarbits;
#endif
}
// Calculate the toggle count
if (duration > 0)
{
toggle_count = 2 * frequency * duration / 1000;
}
else
{
toggle_count = -1;
}
// Set the OCR for the given timer,
// set the toggle count,
// then turn on the interrupts
switch (_timer)
{
#if defined(OCR0A) && defined(TIMSK0) && defined(OCIE0A)
case 0:
OCR0A = ocr;
timer0_toggle_count = toggle_count;
bitWrite(TIMSK0, OCIE0A, 1);
break;
#endif
case 1:
#if defined(OCR1A) && defined(TIMSK1) && defined(OCIE1A)
OCR1A = ocr;
timer1_toggle_count = toggle_count;
bitWrite(TIMSK1, OCIE1A, 1);
#elif defined(OCR1A) && defined(TIMSK) && defined(OCIE1A)
// this combination is for at least the ATmega32
OCR1A = ocr;
timer1_toggle_count = toggle_count;
bitWrite(TIMSK, OCIE1A, 1);
#endif
break;
#if defined(OCR2A) && defined(TIMSK2) && defined(OCIE2A)
case 2:
OCR2A = ocr;
timer2_toggle_count = toggle_count;
bitWrite(TIMSK2, OCIE2A, 1);
break;
#endif
#if defined(TIMSK3)
case 3:
OCR3A = ocr;
timer3_toggle_count = toggle_count;
bitWrite(TIMSK3, OCIE3A, 1);
break;
#endif
#if defined(TIMSK4)
case 4:
OCR4A = ocr;
timer4_toggle_count = toggle_count;
bitWrite(TIMSK4, OCIE4A, 1);
break;
#endif
#if defined(OCR5A) && defined(TIMSK5) && defined(OCIE5A)
case 5:
OCR5A = ocr;
timer5_toggle_count = toggle_count;
bitWrite(TIMSK5, OCIE5A, 1);
break;
#endif
}
}
}
// XXX: this function only works properly for timer 2 (the only one we use
// currently). for the others, it should end the tone, but won't restore
// proper PWM functionality for the timer.
void disableTimer(uint8_t _timer)
{
switch (_timer)
{
case 0:
#if defined(TIMSK0)
TIMSK0 = 0;
#elif defined(TIMSK)
TIMSK = 0; // atmega32
#endif
break;
#if defined(TIMSK1) && defined(OCIE1A)
case 1:
bitWrite(TIMSK1, OCIE1A, 0);
break;
#endif
case 2:
#if defined(TIMSK2) && defined(OCIE2A)
bitWrite(TIMSK2, OCIE2A, 0); // disable interrupt
#endif
#if defined(TCCR2A) && defined(WGM20)
TCCR2A = (1 << WGM20);
#endif
#if defined(TCCR2B) && defined(CS22)
TCCR2B = (TCCR2B & 0b11111000) | (1 << CS22);
#endif
#if defined(OCR2A)
OCR2A = 0;
#endif
break;
#if defined(TIMSK3)
case 3:
TIMSK3 = 0;
break;
#endif
#if defined(TIMSK4)
case 4:
TIMSK4 = 0;
break;
#endif
#if defined(TIMSK5)
case 5:
TIMSK5 = 0;
break;
#endif
}
}
// XXX: this function only works properly for timer 2 (the only one we use
// currently). for the others, it should end the tone, but won't restore
// proper PWM functionality for the timer.
void disableTimer(uint8_t _timer)
void noTone(uint8_t _pin)
{
int8_t _timer = -1;
for (int i = 0; i < AVAILABLE_TONE_PINS; i++)
{
if (tone_pins[i] == _pin)
{
_timer = pgm_read_byte(tone_pin_to_timer_PGM + i);
tone_pins[i] = 255;
}
}
disableTimer(_timer);
digitalWrite(_pin, 0);
}
#ifdef USE_TIMER0
ISR(TIMER0_COMPA_vect)
{
if (timer0_toggle_count != 0)
{
// toggle the pin
*timer0_pin_port ^= timer0_pin_mask;
if (timer0_toggle_count > 0)
timer0_toggle_count--;
}
else
{
disableTimer(0);
*timer0_pin_port &= ~(timer0_pin_mask); // keep pin low after stop
}
}
#endif
#ifdef USE_TIMER1
ISR(TIMER1_COMPA_vect)
{
if (timer1_toggle_count != 0)
{
// toggle the pin
*timer1_pin_port ^= timer1_pin_mask;
if (timer1_toggle_count > 0)
timer1_toggle_count--;
}
else
{
disableTimer(1);
*timer1_pin_port &= ~(timer1_pin_mask); // keep pin low after stop
}
}
#endif
#ifdef USE_TIMER2
ISR(TIMER2_COMPA_vect)
{
if (timer2_toggle_count != 0)
{
// toggle the pin
*timer2_pin_port ^= timer2_pin_mask;
if (timer2_toggle_count > 0)
timer2_toggle_count--;
}
else
{
// need to call noTone() so that the tone_pins[] entry is reset, so the
// timer gets initialized next time we call tone().
// XXX: this assumes timer 2 is always the first one used.
noTone(tone_pins[0]);
// disableTimer(2);
// *timer2_pin_port &= ~(timer2_pin_mask); // keep pin low after stop
}
}
#endif
#ifdef USE_TIMER3
ISR(TIMER3_COMPA_vect)
{
if (timer3_toggle_count != 0)
{
// toggle the pin
*timer3_pin_port ^= timer3_pin_mask;
if (timer3_toggle_count > 0)
timer3_toggle_count--;
}
else
{
disableTimer(3);
*timer3_pin_port &= ~(timer3_pin_mask); // keep pin low after stop
}
}
#endif
#ifdef USE_TIMER4
ISR(TIMER4_COMPA_vect)
{
if (timer4_toggle_count != 0)
{
// toggle the pin
*timer4_pin_port ^= timer4_pin_mask;
if (timer4_toggle_count > 0)
timer4_toggle_count--;
}
else
{
disableTimer(4);
*timer4_pin_port &= ~(timer4_pin_mask); // keep pin low after stop
}
}
#endif
#ifdef USE_TIMER5
ISR(TIMER5_COMPA_vect)
{
if (timer5_toggle_count != 0)
{
// toggle the pin
*timer5_pin_port ^= timer5_pin_mask;
if (timer5_toggle_count > 0)
timer5_toggle_count--;
}
else
{
disableTimer(5);
*timer5_pin_port &= ~(timer5_pin_mask); // keep pin low after stop
}
}
#endif
#endif // 0 [OLD CODE]
#endif // TONE_SUPPORTED

View File

@@ -1,275 +0,0 @@
//////////////////////////////////////////////////////////////////////////////
// //
// _ _ ____ ____ _ _ _ //
// | | | |/ ___| | __ ) / \ _ __ (_) | |__ //
// | | | |\___ \ | _ \ / _ \ | '_ \ | | | '_ \ //
// | |_| | ___) || |_) |/ ___ \ | |_) || | _ | | | | //
// \___/ |____/ |____//_/ \_\| .__/ |_|(_)|_| |_| //
// |_| //
// //
//////////////////////////////////////////////////////////////////////////////
#ifndef __USBAPI__
#define __USBAPI__
#if defined(USBCON)
#include "USBCore.h" /* make sure since I use its definitions here */
#ifdef DEBUG_CODE
#ifdef __cplusplus
extern "C"
{
#endif // __cplusplus
extern void error_print(const char *p1); // TEMPORARY
extern void error_print_(const char *p1); // TEMPORARY
extern void error_printH(unsigned long); // TEMPORARY
extern void error_printH_(unsigned long); // TEMPORARY
extern void error_printL(unsigned long); // TEMPORARY
extern void error_printL_(unsigned long); // TEMPORARY
extern void error_printP(const void * /*PROGMEM*/ p1); // TEMPORARY
extern void error_printP_(const void * /*PROGMEM*/ p1); // TEMPORARY
extern void DumpHex(void *pBuf, uint8_t nBytes);
#ifdef __cplusplus
}
#endif // __cplusplus
#else // DEBUG_CODE
#define error_print(p1)
#define error_print_(p1)
#define error_printH(X)
#define error_printH_(X)
#define error_printL(X)
#define error_printL_(X)
#define error_printP(p1)
#define error_printP_(p1)
#define DumpHex(X,Y)
#endif // DEBUG_CODE
//================================================================================
//================================================================================
// USB
class USBDevice_
{
public:
USBDevice_();
bool configured();
void attach();
void detach(); // Serial port goes down too...
void poll();
protected:
static XMegaEPDataStruct *GetEPData(); // necessary
};
extern USBDevice_ USBDevice;
//================================================================================
//================================================================================
// Serial over CDC (Serial1 is the physical port)
class Serial_ : public Stream
{
protected:
int peek_buffer;
public:
Serial_() { peek_buffer = -1; };
void begin(unsigned long);
void begin(unsigned long, uint8_t);
void end(void);
virtual int available(void);
virtual int peek(void);
virtual int read(void);
virtual void flush(void);
virtual size_t write(uint8_t);
virtual size_t write(const uint8_t*, size_t);
using Print::write; // pull in write(str) etc. from Print
operator bool();
};
extern Serial_ Serial; // NOTE: HardwareSerial.h defines the 1st port as 'Serial1' whenever USBCON defined
//================================================================================
//================================================================================
// Mouse
#define MOUSE_LEFT 1
#define MOUSE_RIGHT 2
#define MOUSE_MIDDLE 4
#define MOUSE_ALL (MOUSE_LEFT | MOUSE_RIGHT | MOUSE_MIDDLE)
class Mouse_
{
protected:
uint8_t _buttons;
void buttons(uint8_t b);
public:
Mouse_(void);
void begin(void);
void end(void);
void click(uint8_t b = MOUSE_LEFT);
void move(signed char x, signed char y, signed char wheel = 0);
void press(uint8_t b = MOUSE_LEFT); // press LEFT by default
void release(uint8_t b = MOUSE_LEFT); // release LEFT by default
bool isPressed(uint8_t b = MOUSE_LEFT); // check LEFT by default
};
extern Mouse_ Mouse;
//================================================================================
//================================================================================
// Keyboard
#define KEY_LEFT_CTRL 0x80
#define KEY_LEFT_SHIFT 0x81
#define KEY_LEFT_ALT 0x82
#define KEY_LEFT_GUI 0x83
#define KEY_RIGHT_CTRL 0x84
#define KEY_RIGHT_SHIFT 0x85
#define KEY_RIGHT_ALT 0x86
#define KEY_RIGHT_GUI 0x87
#define KEY_UP_ARROW 0xDA
#define KEY_DOWN_ARROW 0xD9
#define KEY_LEFT_ARROW 0xD8
#define KEY_RIGHT_ARROW 0xD7
#define KEY_BACKSPACE 0xB2
#define KEY_TAB 0xB3
#define KEY_RETURN 0xB0
#define KEY_ESC 0xB1
#define KEY_INSERT 0xD1
#define KEY_DELETE 0xD4
#define KEY_PAGE_UP 0xD3
#define KEY_PAGE_DOWN 0xD6
#define KEY_HOME 0xD2
#define KEY_END 0xD5
#define KEY_CAPS_LOCK 0xC1
#define KEY_F1 0xC2
#define KEY_F2 0xC3
#define KEY_F3 0xC4
#define KEY_F4 0xC5
#define KEY_F5 0xC6
#define KEY_F6 0xC7
#define KEY_F7 0xC8
#define KEY_F8 0xC9
#define KEY_F9 0xCA
#define KEY_F10 0xCB
#define KEY_F11 0xCC
#define KEY_F12 0xCD
// Low level key report: up to 6 keys and shift, ctrl etc at once
typedef struct
{
uint8_t modifiers;
uint8_t reserved;
uint8_t keys[6];
} KeyReport;
class Keyboard_ : public Print
{
protected:
KeyReport _keyReport;
void sendReport(KeyReport* keys);
public:
Keyboard_(void);
void begin(void);
void end(void);
virtual size_t write(uint8_t k);
virtual size_t press(uint8_t k);
virtual size_t release(uint8_t k);
virtual void releaseAll(void);
};
extern Keyboard_ Keyboard;
//================================================================================
//================================================================================
// Low level API
typedef struct
{
uint8_t bmRequestType;
uint8_t bRequest;
uint8_t wValueL;
uint8_t wValueH;
uint16_t wIndex;
uint16_t wLength;
} Setup;
//================================================================================
//================================================================================
// HID 'Driver'
int HID_GetNumInterfaces(void);
int HID_GetInterfaceDataLength(void);
int HID_SendInterfaceData(void);
bool HID_SendDeviceDescriptor(void);
int HID_GetDescriptor(int i); // handles the 'GET DESCRIPTOR' control packet
bool HID_Setup(Setup& setup); // handles a 'SETUP' control packet
void HID_SendReport(uint8_t id, const void* data, int len);
void HID_Reset(void); // called whenever I get a bus reset
//================================================================================
//================================================================================
// CDC 'Driver'
bool CDC_SendIAD(void);
int CDC_GetNumInterfaces(void);
int CDC_GetInterfaceDataLength(void);
int CDC_SendInterfaceData(void);
bool CDC_SendDeviceDescriptor(void);
int CDC_GetDescriptor(int i); // handles the 'GET DESCRIPTOR' control packet
bool CDC_Setup(Setup& setup); // handles a 'SETUP' control packet
void CDC_FrameReceived(void); // call when frame is received and EP is configured
void CDC_SendACM(void); // call when you need to send a packet on the interrupt EP
void CDC_Reset(void); // called whenever I get a bus reset
//================================================================================
//================================================================================
#define TRANSFER_PGM 0x80
#define TRANSFER_RELEASE 0x40
#define TRANSFER_TOGGLE_ON 0x20 /* assign this to pre-set the 'toggle' bit on - only works when send queue is empty */
#define TRANSFER_TOGGLE_OFF 0x10 /* assign this to pre-set the 'toggle' bit off - only works when send queue is empty */
// NOTE: USB_SendControl returns # of bytes sent, or 0x8000 if a ZLP is sent
// it will return 0 on error, such as the inability to allocate a buffer
// control packets send 64 bytes at a time, so the total size is limited
// by the number of available buffers.
int USB_SendControl(uint8_t flags, const void* d, int len);
#ifdef PROGMEM
int USB_SendControlP(uint8_t flags, const void * PROGMEM d, int len);
// called internally if you use TRANSFER_PGM flag; you can also call this directly
#endif // PROGMEM
uint16_t USB_Available(uint8_t ep); // returns # of bytes in the buffer on an OUT or CONTROL endpoint
uint16_t USB_SendQLength(uint8_t ep); // returns # of buffers in the send queue for an IN or CONTROL endpoint
bool USB_IsSendQFull(uint8_t ep); // this returns TRUE if there are too many outgoing buffers already (IN, CONTROL)
bool USB_IsStalled(uint8_t ep); // this tells me I'm 'stalled' (BULK IN, INTERRUPT, CONTROL)
int USB_Send(uint8_t ep, const void* data, // send endpoint data. bSendNow marks it "to send"
int len, uint8_t bSendNow);
int USB_Recv(uint8_t ep, void* data, // 'receive' data from endpoint receive queue. returns < 0 on error, or # of bytes
int len);
int USB_Recv(uint8_t ep); // 'receive' one byte of data from endpoint receive queue
void USB_Flush(uint8_t ep); // 'sends' all pending data by marking the buffers "to send"
uint16_t GetFrameNumber(void); // a debug API to obtain the latest USB frame number
uint8_t USB_GetEPType(uint8_t nEP); // another debug API to return endpoint type by index
#endif
#endif /* if defined(USBCON) */

File diff suppressed because it is too large Load Diff

View File

@@ -1,442 +0,0 @@
//////////////////////////////////////////////////////////////////////////////
// //
// _ _ ____ ____ ____ _ //
// | | | |/ ___| | __ ) / ___| ___ _ __ ___ | |__ //
// | | | |\___ \ | _ \ | | / _ \ | '__|/ _ \ | '_ \ //
// | |_| | ___) || |_) || |___| (_) || | | __/ _ | | | | //
// \___/ |____/ |____/ \____|\___/ |_| \___|(_)|_| |_| //
// //
// //
//////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2010, Peter Barrett
/*
** Permission to use, copy, modify, and/or distribute this software for
** any purpose with or without fee is hereby granted, provided that the
** above copyright notice and this permission notice appear in all copies.
**
** THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
** WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
** WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR
** BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
** OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
** WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
** ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
** SOFTWARE.
*/
#ifndef __USBCORE_H__
#define __USBCORE_H__
// USB implementation MUST have USB_VID and USB_PID defined - can be done in 'boards.txt'
#if defined(USBCON) /* TODO add others here, things that require VID and PID for USB */
#ifdef USB_VID
#if USB_VID==null
#error cannot work with NULL value for VID
#endif // USB_VID==null
#else
#error must define USB_VID
#endif // USB_VID
#ifdef USB_PID
#if USB_PID==null
#error cannot work with NULL value for PID
#endif // USB_PID==null
#else
#error must define USB_PID
#endif // USB_PID
#endif // defined(USBCON)
#define FAST_USB /* necessary for 'FULL' speed operation - this is 12Mbit, not 480Mbit USB 2 'HIGH' speed - 'LOW' may not work properly */
#ifndef _PLATFORM_H_TYPES_DEFINED_ /* TEMPORARY FIX, SEE Platform.h */
#define _PLATFORM_H_TYPES_DEFINED_
typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned long u32;
#endif // _PLATFORM_H_TYPES_DEFINED_
// Standard requests
#define GET_STATUS 0
#define CLEAR_FEATURE 1
#define SET_FEATURE 3
#define SET_ADDRESS 5
#define GET_DESCRIPTOR 6
#define SET_DESCRIPTOR 7
#define GET_CONFIGURATION 8
#define SET_CONFIGURATION 9
#define GET_INTERFACE 10
#define SET_INTERFACE 11
// bmRequestType
#define REQUEST_HOSTTODEVICE 0x00
#define REQUEST_DEVICETOHOST 0x80 /* device to host, i.e. 'in' - when not set, it's 'out' (host to device) */
#define REQUEST_DIRECTION 0x80
#define REQUEST_STANDARD 0x00
#define REQUEST_CLASS 0x20
#define REQUEST_VENDOR 0x40
#define REQUEST_TYPE 0x60
#define REQUEST_DEVICE 0x00
#define REQUEST_INTERFACE 0x01
#define REQUEST_ENDPOINT 0x02
#define REQUEST_OTHER 0x03
#define REQUEST_RECIPIENT 0x03
#define REQUEST_DEVICETOHOST_CLASS_INTERFACE (REQUEST_DEVICETOHOST + REQUEST_CLASS + REQUEST_INTERFACE)
#define REQUEST_HOSTTODEVICE_CLASS_INTERFACE (REQUEST_HOSTTODEVICE + REQUEST_CLASS + REQUEST_INTERFACE)
// Class requests
#define CDC_SET_LINE_CODING 0x20
#define CDC_GET_LINE_CODING 0x21
#define CDC_SET_CONTROL_LINE_STATE 0x22
#define MSC_RESET 0xFF
#define MSC_GET_MAX_LUN 0xFE
#define HID_GET_REPORT 0x01
#define HID_GET_IDLE 0x02
#define HID_GET_PROTOCOL 0x03
#define HID_SET_REPORT 0x09
#define HID_SET_IDLE 0x0A
#define HID_SET_PROTOCOL 0x0B
// Descriptors
#define USB_DEVICE_DESC_SIZE 18
#define USB_CONFIGUARTION_DESC_SIZE 9
#define USB_INTERFACE_DESC_SIZE 9
#define USB_ENDPOINT_DESC_SIZE 7
#define USB_DEVICE_DESCRIPTOR_TYPE 1
#define USB_CONFIGURATION_DESCRIPTOR_TYPE 2
#define USB_STRING_DESCRIPTOR_TYPE 3
#define USB_INTERFACE_DESCRIPTOR_TYPE 4
#define USB_ENDPOINT_DESCRIPTOR_TYPE 5
#define USB_DEVICE_QUALIFIER_TYPE 6
#define USB_OTHER_SPEED_CONFIGURATION_TYPE 7
#define USB_INTERFACE_POWER_TYPE 8
#define USB_OTG_TYPE 9
#define USB_DEVICE_DEBUG_TYPE 10
#define USB_INTERFACE_ASSOCIATION_TYPE 11 /* see InterfaceAssociationDescriptor_ecn.pdf */
// NOTE: for USB_INTERFACE_ASSOCIATION_TYPE respond with IADDescriptor
#define USB_DEVICE_CLASS_ZERO 0x00
#define USB_DEVICE_CLASS_COMMUNICATIONS 0x02
#define USB_DEVICE_CLASS_HUMAN_INTERFACE 0x03
#define USB_DEVICE_CLASS_STORAGE 0x08
#define USB_DEVICE_CLASS_VENDOR_SPECIFIC 0xFF
#define USB_CONFIG_POWERED_MASK 0x40
#define USB_CONFIG_BUS_POWERED 0x80
#define USB_CONFIG_SELF_POWERED 0xC0
#define USB_CONFIG_REMOTE_WAKEUP 0x20
// bMaxPower in Configuration Descriptor
#define USB_CONFIG_POWER_MA(mA) ((mA)/2)
// bEndpointAddress in Endpoint Descriptor
#define USB_ENDPOINT_DIRECTION_MASK 0x80
#define USB_ENDPOINT_OUT(addr) ((addr) | 0x00)
#define USB_ENDPOINT_IN(addr) ((addr) | 0x80)
#define USB_ENDPOINT_TYPE_MASK 0x03
#define USB_ENDPOINT_TYPE_CONTROL 0x00
#define USB_ENDPOINT_TYPE_ISOCHRONOUS 0x01
#define USB_ENDPOINT_TYPE_BULK 0x02
#define USB_ENDPOINT_TYPE_INTERRUPT 0x03
#define TOBYTES(x) ((x) & 0xFF),(((x) >> 8) & 0xFF)
#define CDC_V1_10 0x0110
#define CDC_COMMUNICATION_INTERFACE_CLASS 0x02
#define CDC_CALL_MANAGEMENT 0x01
#define CDC_ABSTRACT_CONTROL_MODEL 0x02
#define CDC_HEADER 0x00
#define CDC_ABSTRACT_CONTROL_MANAGEMENT 0x02
#define CDC_UNION 0x06
#define CDC_CS_INTERFACE 0x24
#define CDC_CS_ENDPOINT 0x25
#define CDC_DATA_INTERFACE_CLASS 0x0A
#define MSC_SUBCLASS_SCSI 0x06
#define MSC_PROTOCOL_BULK_ONLY 0x50
#define HID_HID_DESCRIPTOR_TYPE 0x21
#define HID_REPORT_DESCRIPTOR_TYPE 0x22
#define HID_PHYSICAL_DESCRIPTOR_TYPE 0x23
// CONTROL LINE STATE and SERIAL STATE - BIT VALUES (16-bits, LE)
// USED BY 'SET CONTROL LINE STATE' and 'SERIAL STATE' FOR CAM INTERRUPT 'IN'
#define CONTROL_LINE_STATE_DTR 0x01 /* data terminal ready [ok to send on IN] */
#define CONTROL_LINE_STATE_RTS 0x02 /* ready to send [has data ready for OUT] */
#define SERIAL_STATE_RX_CARRIER_DCD 0x01 /* receive carrier detect - on to allow receive */
#define SERIAL_STATE_TX_CARRIER_DSR 0x02 /* data set ready - inform host I have data */
#define SERIAL_STATE_BREAK_DETECT 0x04 /* 'break' detect */
#define SERIAL_STATE_RING_DETECT 0x08 /* 'ring' detect */
#define SERIAL_STATE_FRAMING_ERROR 0x10 /* framing error */
#define SERIAL_STATE_PARITY_ERROR 0x20 /* parity error */
#define SERIAL_STATE_OVERRUN 0x40 /* overrun input (data lost) */
// A1U series needs 16-byte alignment for endpoint structure
#if defined(__AVR_ATxmega64A1U__) || defined(__AVR_ATxmega128A1U__)
#define A1U_SERIES
#endif // A1U
// Device
typedef struct _device_descriptor_
{
u8 len; // 18
u8 dtype; // 1 USB_DEVICE_DESCRIPTOR_TYPE
u16 usbVersion; // 0x200
u8 deviceClass;
u8 deviceSubClass;
u8 deviceProtocol;
u8 packetSize0; // Packet 0
u16 idVendor;
u16 idProduct;
u16 deviceVersion; // 0x100
u8 iManufacturer;
u8 iProduct;
u8 iSerialNumber;
u8 bNumConfigurations;
} DeviceDescriptor;
// Config
typedef struct _config_descriptor_
{
u8 len; // 9
u8 dtype; // 2
u16 clen; // total length
u8 numInterfaces;
u8 config;
u8 iconfig;
u8 attributes;
u8 maxPower;
} ConfigDescriptor;
// String
// Interface
typedef struct _interface_descriptor_
{
u8 len; // 9
u8 dtype; // 4
u8 number;
u8 alternate;
u8 numEndpoints;
u8 interfaceClass;
u8 interfaceSubClass;
u8 protocol;
u8 iInterface;
} InterfaceDescriptor;
// Endpoint
typedef struct _endpoint_descriptor_
{
u8 len; // 7
u8 dtype; // 5
u8 addr;
u8 attr;
u16 packetSize;
u8 interval;
} EndpointDescriptor;
// Interface Association Descriptor
// Used to bind 2 interfaces together in CDC compostite device
typedef struct _iad_descriptor_
{
u8 len; // 8
u8 dtype; // 11
u8 firstInterface;
u8 interfaceCount;
u8 functionClass;
u8 funtionSubClass;
u8 functionProtocol;
u8 iInterface;
} IADDescriptor;
// CDC CS interface descriptor
typedef struct _cdccs_interface_descriptor_
{
u8 len; // 5
u8 dtype; // 0x24
u8 subtype;
u8 d0;
u8 d1;
} CDCCSInterfaceDescriptor;
typedef struct _cdccs_interface_descriptor4_
{
u8 len; // 4
u8 dtype; // 0x24
u8 subtype;
u8 d0;
} CDCCSInterfaceDescriptor4;
typedef struct _cm_functional_descriptor_
{
u8 len; // 5
u8 dtype; // 0x24
u8 subtype; // 1
u8 bmCapabilities;
u8 bDataInterface;
} CMFunctionalDescriptor;
typedef struct _acm_functional_descriptor_
{
u8 len;
u8 dtype; // 0x24
u8 subtype; // 1
u8 bmCapabilities;
} ACMFunctionalDescriptor;
typedef struct _cdc_descriptor_
{
// // IAD
// IADDescriptor iad; // for complex endpoints (apparently not critical)
// Control
InterfaceDescriptor cif; //
CDCCSInterfaceDescriptor header;
// CMFunctionalDescriptor callManagement; // Call Management
ACMFunctionalDescriptor controlManagement; // ACM
CDCCSInterfaceDescriptor functionalDescriptor; // CDC_UNION
EndpointDescriptor cifin;
// Data
InterfaceDescriptor dif;
EndpointDescriptor in;
EndpointDescriptor out;
} CDCDescriptor;
typedef struct _msc_descriptor_
{
InterfaceDescriptor msc;
EndpointDescriptor in;
EndpointDescriptor out;
} MSCDescriptor;
typedef struct _hid_desc_descriptor_
{
u8 len; // 9
u8 dtype; // 0x21
u8 addr;
u8 versionL; // 0x101
u8 versionH; // 0x101
u8 country;
u8 desctype; // 0x22 report
u8 descLenL;
u8 descLenH;
} HIDDescDescriptor;
typedef struct _hid_descriptor_
{
InterfaceDescriptor hid;
HIDDescDescriptor desc;
EndpointDescriptor in;
} HIDDescriptor;
// XMEGA STRUCTURES
#define MAXEP 5 /*15*/ /* 4 bit value, 0-15 - see 20.14.1 'CTRLA register' in AU manual */
// I assigned this to '5' because there are only 5 endpoints being used by THIS code.
// The 'mega' code could only have a total of 6 and 0 was always the 'control' endpoint
// and setting a 'smaller-than-maximum' value for XMEGA burns up less RAM.
// If this poses a problem I _could_ malloc the structures, but to be effective, it would
// have to require a reboot to change it, or you'd get major RAM fragmentation
//
// TODO: put MAXEP into pins_arduino.h and override if too small (or not defined already)
typedef union _xmega_fifo_entry_
{
struct
{
uint8_t h, l;
};
uint16_t heW; // high endian word
} XMegaFIFOEntry;
typedef struct _xmega_fifo_
{
XMegaFIFOEntry in;
XMegaFIFOEntry out;
} XMegaFIFO;
// see AU manual, pg 231 section 20.4
typedef struct _xmega_endpoint_descriptor_
{
volatile uint8_t status;
volatile uint8_t ctrl;
volatile uint16_t /*HLByteWord*/ cnt; // so, cnt.w is the 16-bit value, cnt.l and cnt.h the 8-bit low/high
// it is the 'data count' value. it may be zero.
// only bits 1:0 of cnt.h are valid. cnt.w should be 'and'd with 0x3ff
// the high bit of cnt.w and cnt.h is the 'AZLP' (auto zero length packet) bit
// see AU manual section 20.15.4
volatile uint16_t /*HLByteWord*/ dataptr; // pointer to data buffer. max packet length assigned to CTRL [1:0] or [2:0]
// see table 20-5 in AU manual for max packet length. may need 2 buffers "that long"
volatile uint16_t /*HLByteWord*/ auxdata; // used for multi-packet transfers
} XMegaEndpointDescriptor; // NOTE: 2 per channel (one 'out', one 'in') pointed by EPPTR
typedef struct _xmega_endpoint_channel_
{
XMegaEndpointDescriptor out;
XMegaEndpointDescriptor in;
} XMegaEndpointChannel
#ifdef A1U_SERIES
__attribute (( aligned (16) ));
#else // not an A1U series
__attribute__ (( aligned (2) /*, packed*/));
#endif // A1U or not
// also section 20.4 in AU manual
typedef struct _XMegaEPDataStruct_
{
#ifdef A1U_SERIES
#if ((MAXEP+1)%4) != 0 // A1U needs 16-byte boundary, not merely word-aligned
uint8_t padding[sizeof(XMegaFIFO) * (4 - ((MAXEP+1)%4))]; // this should 16-byte align 'endpoint' as required
#endif // needs padding
#endif // XMEGA A1U series
XMegaFIFO fifo[MAXEP + 1];
XMegaEndpointChannel endpoint[MAXEP + 1]; // point EPPTR to THIS (must be word boundary)
volatile uint16_t framenum; // 1 word frame number
} XMegaEPDataStruct /*__attribute__ ((packed))*/; // note: point EPPTR to &endpoint[0], word alignment needed
#ifdef DEBUG_CODE
uint16_t endpoint_data_pointer(void);
#define EP_DATA_STRUCT() ((XMegaEPDataStruct *)(endpoint_data_pointer() - (uint16_t)&(((XMegaEPDataStruct *)0)->endpoint[0])))
#endif // DEBUG_CODE
// this is the USB Device Descriptor
#define D_DEVICE(_class,_subClass,_proto,_packetSize0,_vid,_pid,_version,_im,_ip,_is,_configs) \
{ 18, 1, 0x200, _class,_subClass,_proto,_packetSize0,_vid,_pid,_version,_im,_ip,_is,_configs }
#define D_CONFIG(_totalLength,_interfaces) \
{ 9, 2, _totalLength,_interfaces, 1, 0, USB_CONFIG_BUS_POWERED, USB_CONFIG_POWER_MA(500) }
#define D_INTERFACE(_n,_numEndpoints,_class,_subClass,_protocol) \
{ 9, 4, _n, 0, _numEndpoints, _class,_subClass, _protocol, 0 }
#define D_ENDPOINT(_addr,_attr,_packetSize, _interval) \
{ 7, 5, _addr,_attr,_packetSize, _interval }
#define D_IAD(_firstInterface, _count, _class, _subClass, _protocol) \
{ 8, 11, _firstInterface, _count, _class, _subClass, _protocol, 0 }
#define D_HIDREPORT(_descriptorLength) \
{ 9, 0x21, 0x1, 0x1, 0, 1, 0x22, _descriptorLength, 0 }
#define D_CDCCS(_subtype,_d0,_d1) { 5, 0x24, _subtype, _d0, _d1 }
#define D_CDCCS4(_subtype,_d0) { 4, 0x24, _subtype, _d0 }
#endif

View File

@@ -1,83 +0,0 @@
//////////////////////////////////////////////////////////////////////////////
// //
// _ _ ____ ____ ____ _ //
// | | | |/ ___| | __ ) | _ \ ___ ___ ___ | |__ //
// | | | |\___ \ | _ \ | | | | / _ \/ __| / __| | '_ \ //
// | |_| | ___) || |_) || |_| || __/\__ \| (__ _ | | | | //
// \___/ |____/ |____/ |____/ \___||___/ \___|(_)|_| |_| //
// //
// //
//////////////////////////////////////////////////////////////////////////////
/* Copyright (c) 2011, Peter Barrett
**
** Permission to use, copy, modify, and/or distribute this software for
** any purpose with or without fee is hereby granted, provided that the
** above copyright notice and this permission notice appear in all copies.
**
** THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
** WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
** WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR
** BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
** OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
** WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
** ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
** SOFTWARE.
*/
// NOTE: don't define these here; define them in pins_arduino.h
//#define CDC_ENABLED
//#define HID_ENABLED
#ifdef CDC_ENABLED
#define CDC_INTERFACE_COUNT 2
#define CDC_ENDPOINT_COUNT 3
#else
#define CDC_INTERFACE_COUNT 0
#define CDC_ENPOINT_COUNT 0
#endif
#ifdef HID_ENABLED
#define HID_INTERFACE_COUNT 1
#define HID_ENPOINT_COUNT 1
#else
#define HID_INTERFACE_COUNT 0
#define HID_ENPOINT_COUNT 0
#endif
#define CDC_ACM_INTERFACE 0 // CDC ACM interface
#define CDC_DATA_INTERFACE 1 // CDC Data interface
#define CDC_FIRST_ENDPOINT 1
#define CDC_ENDPOINT_ACM (CDC_FIRST_ENDPOINT) // CDC First
#define CDC_ENDPOINT_OUT (CDC_FIRST_ENDPOINT+1)
#define CDC_ENDPOINT_IN (CDC_FIRST_ENDPOINT+2)
#define HID_INTERFACE (CDC_ACM_INTERFACE + CDC_INTERFACE_COUNT) // HID Interface
#define HID_FIRST_ENDPOINT (CDC_FIRST_ENDPOINT + CDC_ENPOINT_COUNT)
#define HID_ENDPOINT_INT (HID_FIRST_ENDPOINT)
#define INTERFACE_COUNT (MSC_INTERFACE + MSC_INTERFACE_COUNT)
#ifdef CDC_ENABLED
#define CDC_RX CDC_ENDPOINT_OUT
#define CDC_TX CDC_ENDPOINT_IN
#define CDC_ACM CDC_ENDPOINT_ACM
#endif
#ifdef HID_ENABLED
#define HID_TX HID_ENDPOINT_INT
#endif
// string indexes/indices for USB_STRING_DESCRIPTOR_TYPE
#define USB_STRING_INDEX_LANGUAGE 0 /* not actually a STRING though */
#define USB_STRING_INDEX_MANUFACTURER 1
#define USB_STRING_INDEX_PRODUCT 2
#define USB_STRING_INDEX_DESCRIPTION 3
#define USB_STRING_INDEX_VERSION 4
#define USB_STRING_INDEX_URL 5
#define USB_STRING_INDEX_SERIAL 6
#define USB_STRING_INDEX_CONFIG 7

View File

@@ -1,88 +0,0 @@
/*
* Udp.cpp: Library to send/receive UDP packets.
*
* NOTE: UDP is fast, but has some important limitations (thanks to Warren Gray for mentioning these)
* 1) UDP does not guarantee the order in which assembled UDP packets are received. This
* might not happen often in practice, but in larger network topologies, a UDP
* packet can be received out of sequence.
* 2) UDP does not guard against lost packets - so packets *can* disappear without the sender being
* aware of it. Again, this may not be a concern in practice on small local networks.
* For more information, see http://www.cafeaulait.org/course/week12/35.html
*
* MIT License:
* Copyright (c) 2008 Bjoern Hartmann
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* bjoern@cs.stanford.edu 12/30/2008
*/
#ifndef udp_h
#define udp_h
#include <Stream.h>
#include <IPAddress.h>
class UDP : public Stream {
public:
virtual uint8_t begin(uint16_t) =0; // initialize, start listening on specified port. Returns 1 if successful, 0 if there are no sockets available to use
virtual void stop() =0; // Finish with the UDP socket
// Sending UDP packets
// Start building up a packet to send to the remote host specific in ip and port
// Returns 1 if successful, 0 if there was a problem with the supplied IP address or port
virtual int beginPacket(IPAddress ip, uint16_t port) =0;
// Start building up a packet to send to the remote host specific in host and port
// Returns 1 if successful, 0 if there was a problem resolving the hostname or port
virtual int beginPacket(const char *host, uint16_t port) =0;
// Finish off this packet and send it
// Returns 1 if the packet was sent successfully, 0 if there was an error
virtual int endPacket() =0;
// Write a single byte into the packet
virtual size_t write(uint8_t) =0;
// Write size bytes from buffer into the packet
virtual size_t write(const uint8_t *buffer, size_t size) =0;
// Start processing the next available incoming packet
// Returns the size of the packet in bytes, or 0 if no packets are available
virtual int parsePacket() =0;
// Number of bytes remaining in the current packet
virtual int available() =0;
// Read a single byte from the current packet
virtual int read() =0;
// Read up to len bytes from the current packet and place them into buffer
// Returns the number of bytes read, or 0 if none are available
virtual int read(unsigned char* buffer, size_t len) =0;
// Read up to len characters from the current packet and place them into buffer
// Returns the number of characters read, or 0 if none are available
virtual int read(char* buffer, size_t len) =0;
// Return the next byte from the current packet without moving on to the next byte
virtual int peek() =0;
virtual void flush() =0; // Finish reading the current packet
// Return the IP address of the host who sent the current incoming packet
virtual IPAddress remoteIP() =0;
// Return the port of the host who sent the current incoming packet
virtual uint16_t remotePort() =0;
protected:
uint8_t* rawIPAddress(IPAddress& addr) { return addr.raw_address(); };
};
#endif

View File

@@ -1,168 +0,0 @@
/*
WCharacter.h - Character utility functions for Wiring & Arduino
Copyright (c) 2010 Hernando Barragan. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef Character_h
#define Character_h
#include <ctype.h>
// WCharacter.h prototypes
inline boolean isAlphaNumeric(int c) __attribute__((always_inline));
inline boolean isAlpha(int c) __attribute__((always_inline));
inline boolean isAscii(int c) __attribute__((always_inline));
inline boolean isWhitespace(int c) __attribute__((always_inline));
inline boolean isControl(int c) __attribute__((always_inline));
inline boolean isDigit(int c) __attribute__((always_inline));
inline boolean isGraph(int c) __attribute__((always_inline));
inline boolean isLowerCase(int c) __attribute__((always_inline));
inline boolean isPrintable(int c) __attribute__((always_inline));
inline boolean isPunct(int c) __attribute__((always_inline));
inline boolean isSpace(int c) __attribute__((always_inline));
inline boolean isUpperCase(int c) __attribute__((always_inline));
inline boolean isHexadecimalDigit(int c) __attribute__((always_inline));
inline int toAscii(int c) __attribute__((always_inline));
inline int toLowerCase(int c) __attribute__((always_inline));
inline int toUpperCase(int c)__attribute__((always_inline));
// Checks for an alphanumeric character.
// It is equivalent to (isalpha(c) || isdigit(c)).
inline boolean isAlphaNumeric(int c)
{
return ( isalnum(c) == 0 ? false : true);
}
// Checks for an alphabetic character.
// It is equivalent to (isupper(c) || islower(c)).
inline boolean isAlpha(int c)
{
return ( isalpha(c) == 0 ? false : true);
}
// Checks whether c is a 7-bit unsigned char value
// that fits into the ASCII character set.
inline boolean isAscii(int c)
{
return ( isascii (c) == 0 ? false : true);
}
// Checks for a blank character, that is, a space or a tab.
inline boolean isWhitespace(int c)
{
return ( isblank (c) == 0 ? false : true);
}
// Checks for a control character.
inline boolean isControl(int c)
{
return ( iscntrl (c) == 0 ? false : true);
}
// Checks for a digit (0 through 9).
inline boolean isDigit(int c)
{
return ( isdigit (c) == 0 ? false : true);
}
// Checks for any printable character except space.
inline boolean isGraph(int c)
{
return ( isgraph (c) == 0 ? false : true);
}
// Checks for a lower-case character.
inline boolean isLowerCase(int c)
{
return (islower (c) == 0 ? false : true);
}
// Checks for any printable character including space.
inline boolean isPrintable(int c)
{
return ( isprint (c) == 0 ? false : true);
}
// Checks for any printable character which is not a space
// or an alphanumeric character.
inline boolean isPunct(int c)
{
return ( ispunct (c) == 0 ? false : true);
}
// Checks for white-space characters. For the avr-libc library,
// these are: space, formfeed ('\f'), newline ('\n'), carriage
// return ('\r'), horizontal tab ('\t'), and vertical tab ('\v').
inline boolean isSpace(int c)
{
return ( isspace (c) == 0 ? false : true);
}
// Checks for an uppercase letter.
inline boolean isUpperCase(int c)
{
return ( isupper (c) == 0 ? false : true);
}
// Checks for a hexadecimal digits, i.e. one of 0 1 2 3 4 5 6 7
// 8 9 a b c d e f A B C D E F.
inline boolean isHexadecimalDigit(int c)
{
return ( isxdigit (c) == 0 ? false : true);
}
// Converts c to a 7-bit unsigned char value that fits into the
// ASCII character set, by clearing the high-order bits.
inline int toAscii(int c)
{
return toascii (c);
}
// Warning:
// Many people will be unhappy if you use this function.
// This function will convert accented letters into random
// characters.
// Converts the letter c to lower case, if possible.
inline int toLowerCase(int c)
{
return tolower (c);
}
// Converts the letter c to upper case, if possible.
inline int toUpperCase(int c)
{
return toupper (c);
}
#endif

View File

@@ -1,808 +0,0 @@
/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
Part of the Wiring project - http://wiring.uniandes.edu.co
Copyright (c) 2004-05 Hernando Barragan
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
Boston, MA 02111-1307 USA
Modified 24 November 2006 by David A. Mellis
Modified 1 August 2010 by Mark Sproul
Updated for 'xmega' core by bob frazier, S.F.T. Inc. - http://mrp3.com/
In some cases, the xmega updates make assumptions about the pin assignments.
See 'pins_arduino.h' for more detail.
*/
#include <inttypes.h>
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
#include <stdio.h>
#include "wiring_private.h"
// interrupts on the xmega are handled differently than the mega
// there are 2 interrupt vectors for each port. Typical xmega
// will use ports A, B, C, D, E, and R. The vectors for those
// are as follows:
//
// PORTn_INT0_vect
// - and -
// PORTn_INT1_vect
//
// where 'n' is A, B, C, D, E, or R
//
// Additional vectors are:
//
// OSC_XOSCF_vect (external oscillator failure, NMI)
//
// RTC_OVF_vect (real-time clock overflow)
// RTC_COMP_vect (real-time clock compare)
//
// TWIC_TWIS_vect (2-wire slave on port C)
// TWIC_TWIM_vect (2-wire master on port C)
// TWIE_TWIS_vect (2-wire slave on port E)
// TWIE_TWIM_vect (2-wire master on port E)
//
// timers - 'n' is C or D
// TCn0_OVF_vect (n timer 0 overflow)
// TCn1_OVF_vect (n timer 1 overflow)
// TCn2_LUNF_vect (n timer 2 low byte underflow)
// TCn2_HUNF_vect (n timer 2 high byte underflow)
// TCE0_OVF_vect (E timer 0 overflow)
// TCn0_ERR_vect (n timer 0 error)
// TCn1_ERR_vect (n timer 1 error)
// TCE0_ERR_vect (E timer 0 error)
// TCn0_CCA_vect (n timer 0 compare or capture A)
// TCn1_CCA_vect (n timer 1 compare or capture A)
// TCn2_LCMPA_vect (n timer 2 low-byte compare or capture A)
// TCE0_CCA_vect (E timer 0 compare or capture A)
// TCn0_CCB_vect (n timer 0 compare or capture B)
// TCn1_CCB_vect (n timer 1 compare or capture B)
// TCn2_LCMPB_vect (n timer 2 low-byte compare or capture B)
// TCE0_CCB_vect (E timer 0 compare or capture B)
// TCn0_CCC_vect (n timer 0 compare or capture C)
// TCn2_LCMPC_vect (n timer 2 low-byte compare or capture C)
// TCE0_CCC_vect (E timer 0 compare or capture C)
// TCn0_CCD_vect (n timer 0 compare or capture D)
// TCn2_LCMPD_vect (n timer 2 low-byte compare or capture D)
// TCE0_CCD_vect (E timer 0 compare or capture D)
//
// SPIn_INT_vect (SPI C or D)
//
// USARTn0_RXC_vect (USART 'n' [C or D] receive complete)
// USARTn0_DRE_vect (USART 'n' [C or D] data reg empty)
// USARTn0_TXC_vect (USART 'n' [C or D] transmit complete)
//
// NOTE: a 'USARTE' interrupt vector also exists, but isn't
// implemented on the D4 series
//
// ASYNC interrupts are only possible on pin 2 for each of the 5
// ports ('R' only has 2 pins, 0 and 1, so no async interrupt).
// Sleep modes typically need ASYNC interrupts to wake up.
// The interrupt will be handled for a particular port, and not for
// a particular interrupt. The 'attachInterrupt' function will default
// to pin 2 (asynchronous interrupt) unless otherwise specified in the
// 'mode' parameter.
// BOOTLOADER NOTES
//
// Bit 6 of the CTRL reg must be assigned to '0'. Bit 7 can be assigned
// to '1' to enable 'round robin' scheduling using the priority bits.
// Bits 0-2 (HILVLEN, MEDLVLEN, LOLVLEN) should also be assigned to '1'
// to allow all 3 interrupt levels to execute. ('D' manual 10.8.3 pg 102)
// The CTRL reg can be assigned to b10000111 to accomplish this. Bit 6
// needs to use the "configuration change protection" method to change it
// and may need to be assigned separately.
// interrupt mode - predefined values are LOW, CHANGE, RISING, FALLING, HIGH
// additional bits are 'or'd with mode
static volatile voidFuncPtr intFunc[EXTERNAL_NUM_INTERRUPTS];
static volatile uint8_t intPins[EXTERNAL_NUM_INTERRUPTS]; // added - store pins for this interrupt
// volatile static voidFuncPtr twiIntFunc;
// NOTE: I _HATE_ K&R style so I'll make it Allman style as I go along...
void attachInterrupt(uint8_t interruptNum, void (*userFunc)(void), int mode)
{
uint8_t iPinBits, iPriBits, iModeBits, iInv, iNum, iMask;
uint8_t oldSREG;
uint8_t intInfo;
PORT_t *port;
// for compatibility with newer IDE, 'interruptNum' can be encoded with pin information.
// if it is, then the pin info will be derived from pin info in 'mode' and 'interruptNum'
// pin info will be incorporated into it.
intInfo = ((interruptNum & 0xe0) >> 5); // is an int pin encoded here by digitalPinToInterrupt ?
interruptNum &= 0x1f; // so the rest of the code will work correctly
if(interruptNum >= EXTERNAL_NUM_INTERRUPTS)
{
return;
}
iPinBits = (uint8_t)((mode & INT_MODE_PIN_MASK) >> 8);
if(intInfo)
{
intInfo = ((intInfo + 2) & 7); // convert to actual pin number
iPinBits |= _BV(intInfo); // set respective bit in 'iPinBits'
}
if(!iPinBits)
{
if(interruptNum == PORTR_INT0
#ifdef PORTR_INT1
|| interruptNum == PORTR_INT1
#endif // PORTR_INT1
) // not valid for these
{
return; // do nothing (for now)
}
iPinBits = _BV(2); // set bit for pin 2 if none specified [i.e. 'default']
}
iPriBits = (mode & INT_MODE_PRI_MASK)
>> INT_MODE_PRI_SHIFT;
if(!iPriBits) // not assigned
{
iPriBits = 3; // for now, just use the highest priority
}
mode &= INT_MODE_MODE_MASK;
iInv = 0;
if(mode == LOW) // normally will be this, for backward hardware compatibility
{
iModeBits = PORT_ISC_LEVEL_gc; // b011, high level continuously generates events
}
else if(mode == HIGH) // these constants correspond to the mega's bit mask on ISC00,ISC10
{
iModeBits = PORT_ISC_LEVEL_gc; // b011, high level continuously generates events
iInv = 1; // invert input (so 'high level' becomes 'low level')
// NOTE: this was verified by experimentation. The documentation is misleading, suggesting
// that a LEVEL interrupt triggered on HIGH, not on LOW. But it triggers on LOW. So
// if you want HIGH, you must invert it. Not the other way around. Yeah.
}
else if(mode == CHANGE)
{
iModeBits = PORT_ISC_BOTHEDGES_gc; // BOTHEDGES - see table 11-6
}
else if(mode == RISING)
{
iModeBits = PORT_ISC_RISING_gc; // b001, RISING
}
else if(mode == FALLING)
{
iModeBits = PORT_ISC_FALLING_gc; // b010, FALLING
}
else
{
iModeBits = PORT_ISC_BOTHEDGES_gc; // BOTH (the default - note INTPUT_DISABLED (sic) won't buffer the input, so it's useless except for analog channels)
}
if(iInv)
{
iModeBits |= _BV(PORT_INVEN_bp); // set the 'inverted' bit
}
oldSREG = SREG; // store the interrupt flag basically
cli(); // disable interrupts for a bit
intFunc[interruptNum] = userFunc;
intPins[interruptNum] = iPinBits; // save what pins I used
// Enable the interrupt (smaller code to use if/else and pointer)
iNum = 0;
if(interruptNum == PORTA_INT0
#ifdef PORTA_INT1
|| interruptNum == PORTA_INT1
#endif // PORTA_INT1
)
{
port = &PORTA;
#ifdef PORTA_INT1
if(interruptNum == PORTA_INT1)
{
iNum = 1;
}
#endif // PORTA_INT1
}
#if NUM_ANALOG_PINS > 8 /* which means we have PORT B */
else if(interruptNum == PORTB_INT0
#ifdef PORTB_INT1
|| interruptNum == PORTB_INT1
#endif // PORTB_INT1
)
{
port = &PORTB;
#ifdef PORTB_INT1
if(interruptNum == PORTB_INT1)
{
iNum = 1;
}
#endif // PORTB_INT1
}
#endif // NUM_ANALOG_PINS > 8
else if(interruptNum == PORTC_INT0
#ifdef PORTC_INT1
|| interruptNum == PORTC_INT1
#endif // PORTC_INT1
)
{
port = &PORTC;
#ifdef PORTC_INT1
if(interruptNum == PORTC_INT1)
{
iNum = 1;
}
#endif // PORTC_INT1
}
else if(interruptNum == PORTD_INT0
#ifdef PORTD_INT1
|| interruptNum == PORTD_INT1
#endif // PORTD_INT1
)
{
port = &PORTD;
#ifdef PORTD_INT1
if(interruptNum == PORTD_INT1)
{
iNum = 1;
}
#endif // PORTC_INT1
}
#if NUM_DIGITAL_PINS > 18 /* which means we have PORT E */
else if(interruptNum == PORTE_INT0
#ifdef PORTE_INT1
|| interruptNum == PORTE_INT1
#endif // PORTE_INT1
)
{
port = &PORTE;
#ifdef PORTE_INT1
if(interruptNum == PORTE_INT1)
{
iNum = 1;
}
#endif // PORTE_INT1
}
#endif // NUM_DIGITAL_PINS > 18
else if(interruptNum == PORTR_INT0
#ifdef PORTR_INT1
|| interruptNum == PORTR_INT1
#endif // PORTR_INT1
)
{
port = &PORTR;
#ifdef PORTR_INT1
if(interruptNum == PORTR_INT1)
{
iNum = 1;
}
#endif // PORTR_INT1
}
else
{
return; // do nothing
}
// On certain processors there's only one interrupt, so it's called 'INTMASK'
// we test for this here
#ifndef PORTC_INT0MASK /* meaning there's only one int vector and not two */
if(!iNum)
{
// set interrupt mask for PORT A, int 0 vector
port->INTMASK |= iPinBits; // enable int zero for these pins
port->INTCTRL = (port->INTCTRL & ~(PORT_INTLVL_gm))
| (iPriBits & 3);
}
#else // INT0MASK and INT1MASK supported
if(!iNum)
{
// set interrupt mask for PORT A, int 0 vector
port->INT0MASK |= iPinBits; // enable int zero for these pins
port->INTCTRL = (port->INTCTRL & ~(PORT_INT0LVL_gm))
| (iPriBits & 3);
}
else // if(iNum == 1)
{
port->INT1MASK |= iPinBits; // enable int zero for these pins
port->INTCTRL = (port->INTCTRL & ~(PORT_INT1LVL_gm))
| ((iPriBits & 3) << PORT_INT1LVL_gp);
}
#endif // INT0MASK and INT1MASK supported
for(iNum=0, iMask = 1; iNum < 8; iNum++, iMask <<= 1)
{
register8_t *pCTRL = &(port->PIN0CTRL) + iNum; // treat PIN0CTRL through PIN7CTRL as an array
// set corresponding 'type' in the interrupt control regs for the individual bits
if(iPinBits & iMask) // is this bit set in 'iPinBits'?
{
// enable the interrupt pin's mode bits and assign the 'invert' flag as needed
*pCTRL = (*pCTRL & ~(PORT_ISC_gm | PORT_INVEN_bm))
| iModeBits;
}
}
SREG = oldSREG; // restore it, interrupts (probably) re-enabled
// NOTE that this may throw an interrupt right away
}
void detachInterrupt(uint8_t interruptNum)
{
uint8_t iPinBits, iNum, iMask;
uint8_t oldSREG;
PORT_t *port;
// NOTE: this function will turn OFF the 'invert' bit if it's set for a HIGH level interrupt
// and digitalRead _SHOULD_ be consistent before/after this call.
if(interruptNum >= EXTERNAL_NUM_INTERRUPTS)
{
return;
}
oldSREG = SREG; // keep track of interrupt flag state
cli(); // clear the interrupt flag
// grab 'pin bits' so I know what to flip around
iPinBits = intPins[interruptNum]; // what I used when I added it
intFunc[interruptNum] = 0;
intPins[interruptNum] = 0; // zero both of these
// disable the interrupt
// Enable the interrupt (smaller code to use if/else and pointer)
iNum = 0;
if(interruptNum == PORTA_INT0
#ifdef PORTA_INT1
|| interruptNum == PORTA_INT1
#endif // PORTA_INT1
)
{
port = &PORTA;
#ifdef PORTA_INT1
if(interruptNum == PORTA_INT1)
{
iNum = 1;
}
#endif // PORTA_INT1
}
#if NUM_ANALOG_PINS > 8 /* which means we have PORT B */
else if(interruptNum == PORTB_INT0
#ifdef PORTB_INT1
|| interruptNum == PORTB_INT1
#endif // PORTB_INT1
)
{
port = &PORTB;
#ifdef PORTB_INT1
if(interruptNum == PORTB_INT1)
{
iNum = 1;
}
#endif // PORTB_INT1
}
#endif // NUM_ANALOG_PINS > 8
else if(interruptNum == PORTC_INT0
#ifdef PORTC_INT1
|| interruptNum == PORTC_INT1
#endif // PORTC_INT1
)
{
port = &PORTC;
#ifdef PORTC_INT1
if(interruptNum == PORTC_INT1)
{
iNum = 1;
}
#endif // PORTC_INT1
}
else if(interruptNum == PORTD_INT0
#ifdef PORTD_INT1
|| interruptNum == PORTD_INT1
#endif // PORTD_INT1
)
{
port = &PORTD;
#ifdef PORTD_INT1
if(interruptNum == PORTD_INT1)
{
iNum = 1;
}
#endif // PORTD_INT1
}
#if NUM_DIGITAL_PINS > 18 /* which means we have PORT E */
else if(interruptNum == PORTE_INT0
#ifdef PORTE_INT1
|| interruptNum == PORTE_INT1
#endif // PORTE_INT1
)
{
port = &PORTE;
#ifdef PORTE_INT1
if(interruptNum == PORTE_INT1)
{
iNum = 1;
}
#endif // PORTE_INT1
}
#endif // NUM_DIGITAL_PINS > 18
else if(interruptNum == PORTR_INT0
#ifdef PORTR_INT1
|| interruptNum == PORTR_INT1
#endif // PORTR_INT1
)
{
port = &PORTR;
#ifdef PORTR_INT1
if(interruptNum == PORTR_INT1)
{
iNum = 1;
}
#endif // PORTR_INT1
}
else
{
return; // do nothing
}
// On certain processors there's only one interrupt, so it's called 'INTMASK'
// we test for this here
#ifndef PORTC_INT0MASK /* meaning there's only one int vector and not two */
if(!iNum)
{
// set interrupt mask for PORT A, int 0 vector
port->INTMASK = 0; // disable interrupts - TODO, read this instead of 'iPinBits' ?
port->INTCTRL &= ~(PORT_INTLVL_gm); // set interrupt control to 'OFF'
port->INTFLAGS = _BV(0); // clear the int flag
#else // INT0MASK and INT1MASK supported
if(!iNum)
{
// set interrupt mask for PORT A, int 0 vector
port->INT0MASK = 0; // disable interrupts - TODO, read this instead of 'iPinBits' ?
port->INTCTRL &= ~(PORT_INT0LVL_gm); // set interrupt control to 'OFF'
port->INTFLAGS = _BV(0); // clear the int 0 flag
}
else // if(iNum == 1)
{
#endif // INT0MASK and INT1MASK supported
// if this matches a CTS port, I do _NOT_ want to disable interrupts
#if defined(SERIAL_0_CTS_ENABLED) && defined(SERIAL_1_CTS_ENABLED)
if(SERIAL_0_CTS_PORT == port)
{
#ifndef PORTC_INT0MASK /* meaning there's only one int vector and not two */
if(SERIAL_1_CTS_PORT == port)
{
port->INTMASK = SERIAL_0_CTS_PIN | SERIAL_1_CTS_PIN; // disable interrupts but leave BOTH enabled
}
else
{
port->INTMASK = SERIAL_0_CTS_PIN; // disable interrupts but leave THIS one enabled
}
port->INTCTRL |= PORT_INTLVL_gm; // max priority when I do this
#else // INT0MASK and INT1MASK supported
if(SERIAL_1_CTS_PORT == port)
{
port->INT1MASK = SERIAL_0_CTS_PIN | SERIAL_1_CTS_PIN; // disable interrupts but leave BOTH enabled
}
else
{
port->INT1MASK = SERIAL_0_CTS_PIN; // disable interrupts but leave THIS one enabled
}
port->INTCTRL |= PORT_INT1LVL_gm; // max priority when I do this
#endif // INT0MASK and INT1MASK supported
}
else if(SERIAL_1_CTS_PORT == port)
{
#ifndef PORTC_INT0MASK /* meaning there's only one int vector and not two */
port->INTMASK = SERIAL_1_CTS_PIN; // disable interrupts but leave THIS one enabled
port->INTCTRL |= PORT_INTLVL_gm; // max priority when I do this
#else // INT0MASK and INT1MASK supported
port->INT1MASK = SERIAL_1_CTS_PIN; // disable interrupts but leave THIS one enabled
port->INTCTRL |= PORT_INT1LVL_gm; // max priority when I do this
#endif // INT0MASK and INT1MASK supported
}
#elif defined(SERIAL_0_CTS_ENABLED)
if(SERIAL_0_CTS_PORT == port)
{
#ifndef PORTC_INT0MASK /* meaning there's only one int vector and not two */
port->INTMASK = SERIAL_0_CTS_PIN; // disable interrupts but leave THIS one enabled
port->INTCTRL |= PORT_INTLVL_gm; // max priority when I do this
#else // INT0MASK and INT1MASK supported
port->INT1MASK = SERIAL_0_CTS_PIN; // disable interrupts but leave THIS one enabled
port->INTCTRL |= PORT_INT1LVL_gm; // max priority when I do this
#endif // INT0MASK and INT1MASK supported
}
#elif defined(SERIAL_1_CTS_ENABLED)
if(SERIAL_1_CTS_PORT == port)
{
#ifndef PORTC_INT0MASK /* meaning there's only one int vector and not two */
port->INTMASK = SERIAL_1_CTS_PIN; // disable interrupts but leave THIS one enabled
port->INTCTRL |= PORT_INTLVL_gm; // max priority when I do this
#else // INT0MASK and INT1MASK supported
port->INT1MASK = SERIAL_1_CTS_PIN; // disable interrupts but leave THIS one enabled
port->INTCTRL |= PORT_INT1LVL_gm; // max priority when I do this
#endif // INT0MASK and INT1MASK supported
}
#endif // SERIAL_0/1_CTS_ENABLED
#if defined(SERIAL_0_CTS_ENABLED) || defined(SERIAL_1_CTS_ENABLED)
else
#endif // SERIAL_0/1_CTS_ENABLED
{
#ifndef PORTC_INT0MASK /* meaning there's only one int vector and not two */
port->INTMASK = 0; // disable interrupts - TODO, read this instead of 'iPinBits' ?
port->INTCTRL &= ~(PORT_INTLVL_gm); // set interrupt control to 'OFF'
#else // INT0MASK and INT1MASK supported
port->INT1MASK = 0; // disable interrupts - TODO, read this instead of 'iPinBits' ?
port->INTCTRL &= ~(PORT_INT1LVL_gm); // set interrupt control to 'OFF'
#endif // INT0MASK and INT1MASK supported
}
#ifndef PORTC_INT0MASK /* meaning there's only one int vector and not two */
port->INTFLAGS = _BV(0); // clear the int 0 flag
#else // INT0MASK and INT1MASK supported
port->INTFLAGS = _BV(1); // clear the int 1 flag
#endif // INT0MASK and INT1MASK supported
}
for(iNum=0, iMask = 1; iNum < 8; iNum++, iMask <<= 1)
{
register8_t *pCTRL = &(port->PIN0CTRL) + iNum; // treat PIN0CTRL through PIN7CTRL as an array
// set corresponding 'type' in the interrupt control regs for the individual bits
if(iPinBits & iMask) // is this bit set in 'iPinBits'?
{
*pCTRL &= ~(PORT_ISC_gm | PORT_INVEN_bm); // turn off invert flag and reset to 'BOTH' (the default)
}
}
SREG = oldSREG; // restore it, interrupts (probably) re-enabled
}
#ifndef PORTC_INT0MASK /* meaning there's only one int vector and not two */
ISR(PORTA_INT_vect)
#else // INT0MASK and INT1MASK supported
ISR(PORTA_INT0_vect)
#endif // INT0MASK and INT1MASK supported
{
if(intFunc[PORTA_INT0])
intFunc[PORTA_INT0]();
#ifdef PORTC_INT0MASK // INT0MASK and INT1MASK supported
}
ISR(PORTA_INT1_vect)
{
if(intFunc[PORTA_INT1])
intFunc[PORTA_INT1]();
#endif // INT0MASK and INT1MASK supported
#if defined(SERIAL_0_CTS_ENABLED)
if(SERIAL_0_CTS_PORT == &(PORTA)) // this should compile as a constant expression
{
serial_0_cts_callback();
}
#endif // SERIAL_0_CTS_ENABLED
#ifdef SERIAL_1_CTS_ENABLED
if(SERIAL_1_CTS_PORT == &(PORTA))
{
serial_1_cts_callback();
}
#endif // SERIAL_1_CTS_ENABLED
}
#if NUM_ANALOG_PINS > 8 /* which means we have PORT B */
ISR(PORTB_INT0_vect)
{
if(intFunc[PORTB_INT0])
intFunc[PORTB_INT0]();
}
ISR(PORTB_INT1_vect)
{
if(intFunc[PORTB_INT1])
intFunc[PORTB_INT1]();
#if defined(SERIAL_0_CTS_ENABLED)
if(SERIAL_0_CTS_PORT == &(PORTB)) // this should compile as a constant expression
{
serial_0_cts_callback();
}
#endif // SERIAL_0_CTS_ENABLED
#ifdef SERIAL_1_CTS_ENABLED
if(SERIAL_1_CTS_PORT == &(PORTB))
{
serial_1_cts_callback();
}
#endif // SERIAL_1_CTS_ENABLED
}
#endif // NUM_ANALOG_PINS > 8
#ifndef PORTC_INT0MASK /* meaning there's only one int vector and not two */
ISR(PORTC_INT_vect)
#else // INT0MASK and INT1MASK supported
ISR(PORTC_INT0_vect)
#endif // INT0MASK and INT1MASK supported
{
if(intFunc[PORTC_INT0])
intFunc[PORTC_INT0]();
#ifdef PORTC_INT0MASK // INT0MASK and INT1MASK supported
}
ISR(PORTC_INT1_vect)
{
if(intFunc[PORTC_INT1])
intFunc[PORTC_INT1]();
#endif // INT0MASK and INT1MASK supported
#if defined(SERIAL_0_CTS_ENABLED)
if(SERIAL_0_CTS_PORT == &(PORTC)) // this should compile as a constant expression
{
serial_0_cts_callback();
}
#endif // SERIAL_0_CTS_ENABLED
#ifdef SERIAL_1_CTS_ENABLED
if(SERIAL_1_CTS_PORT == &(PORTC))
{
serial_1_cts_callback();
}
#endif // SERIAL_1_CTS_ENABLED
}
#ifndef PORTC_INT0MASK /* meaning there's only one int vector and not two */
ISR(PORTD_INT_vect)
#else // INT0MASK and INT1MASK supported
ISR(PORTD_INT0_vect)
#endif // INT0MASK and INT1MASK supported
{
if(intFunc[PORTD_INT0])
intFunc[PORTD_INT0]();
#ifdef PORTC_INT0MASK // INT0MASK and INT1MASK supported
}
ISR(PORTD_INT1_vect)
{
if(intFunc[PORTD_INT1])
intFunc[PORTD_INT1]();
#endif // INT0MASK and INT1MASK supported
#if defined(SERIAL_0_CTS_ENABLED)
if(SERIAL_0_CTS_PORT == &(PORTD)) // this should compile as a constant expression
{
serial_0_cts_callback();
}
#endif // SERIAL_0_CTS_ENABLED
#ifdef SERIAL_1_CTS_ENABLED
if(SERIAL_1_CTS_PORT == &(PORTD))
{
serial_1_cts_callback();
}
#endif // SERIAL_1_CTS_ENABLED
}
#if NUM_DIGITAL_PINS > 18 /* which means we have PORT E */
ISR(PORTE_INT0_vect)
{
if(intFunc[PORTE_INT0])
intFunc[PORTE_INT0]();
}
ISR(PORTE_INT1_vect)
{
if(intFunc[PORTE_INT1])
intFunc[PORTE_INT1]();
#if defined(SERIAL_0_CTS_ENABLED)
if(SERIAL_0_CTS_PORT == &(PORTE)) // this should compile as a constant expression
{
serial_0_cts_callback();
}
#endif // SERIAL_0_CTS_ENABLED
#ifdef SERIAL_1_CTS_ENABLED
if(SERIAL_1_CTS_PORT == &(PORTE))
{
serial_1_cts_callback();
}
#endif // SERIAL_1_CTS_ENABLED
}
#endif // NUM_DIGITAL_PINS > 18
// TODO: ISRs for PORTF, PORTH, PORTJ, PORTK, PORTQ
#ifndef PORTC_INT0MASK /* meaning there's only one int vector and not two */
ISR(PORTR_INT_vect)
#else // INT0MASK and INT1MASK supported
ISR(PORTR_INT0_vect)
#endif // INT0MASK and INT1MASK supported
{
if(intFunc[PORTR_INT0])
intFunc[PORTR_INT0]();
#ifdef PORTC_INT0MASK // INT0MASK and INT1MASK supported
}
ISR(PORTR_INT1_vect)
{
if(intFunc[PORTR_INT1])
intFunc[PORTR_INT1]();
#endif // INT0MASK and INT1MASK supported
#if defined(SERIAL_0_CTS_ENABLED)
if(SERIAL_0_CTS_PORT == &(PORTR)) // this should compile as a constant expression
{
serial_0_cts_callback();
}
#endif // SERIAL_0_CTS_ENABLED
#ifdef SERIAL_1_CTS_ENABLED
if(SERIAL_1_CTS_PORT == &(PORTR))
{
serial_1_cts_callback();
}
#endif // SERIAL_1_CTS_ENABLED
}

View File

@@ -1,60 +0,0 @@
/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
Part of the Wiring project - http://wiring.org.co
Copyright (c) 2004-06 Hernando Barragan
Modified 13 August 2006, David A. Mellis for Arduino - http://www.arduino.cc/
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
Boston, MA 02111-1307 USA
$Id$
*/
extern "C" {
#include "stdlib.h"
}
void randomSeed(unsigned int seed)
{
if (seed != 0) {
srandom(seed);
}
}
long random(long howbig)
{
if (howbig == 0) {
return 0;
}
return random() % howbig;
}
long random(long howsmall, long howbig)
{
if (howsmall >= howbig) {
return howsmall;
}
long diff = howbig - howsmall;
return random(diff) + howsmall;
}
long map(long x, long in_min, long in_max, long out_min, long out_max)
{
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
unsigned int makeWord(unsigned int w) { return w; }
unsigned int makeWord(unsigned char h, unsigned char l) { return (h << 8) | l; }

View File

@@ -1,744 +0,0 @@
/*
WString.cpp - String library for Wiring & Arduino
...mostly rewritten by Paul Stoffregen...
Copyright (c) 2009-10 Hernando Barragan. All rights reserved.
Copyright 2011, Paul Stoffregen, paul@pjrc.com
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "WString.h"
/*********************************************/
/* Constructors */
/*********************************************/
String::String(const char *cstr)
{
init();
if (cstr) copy(cstr, strlen(cstr));
}
String::String(const String &value)
{
init();
*this = value;
}
String::String(const __FlashStringHelper *pstr)
{
init();
*this = pstr;
}
#ifdef __GXX_EXPERIMENTAL_CXX0X__
String::String(String &&rval)
{
init();
move(rval);
}
String::String(StringSumHelper &&rval)
{
init();
move(rval);
}
#endif
String::String(char c)
{
init();
char buf[2];
buf[0] = c;
buf[1] = 0;
*this = buf;
}
String::String(unsigned char value, unsigned char base)
{
init();
char buf[1 + 8 * sizeof(unsigned char)];
utoa(value, buf, base);
*this = buf;
}
String::String(int value, unsigned char base)
{
init();
char buf[2 + 8 * sizeof(int)];
itoa(value, buf, base);
*this = buf;
}
String::String(unsigned int value, unsigned char base)
{
init();
char buf[1 + 8 * sizeof(unsigned int)];
utoa(value, buf, base);
*this = buf;
}
String::String(long value, unsigned char base)
{
init();
char buf[2 + 8 * sizeof(long)];
ltoa(value, buf, base);
*this = buf;
}
String::String(unsigned long value, unsigned char base)
{
init();
char buf[1 + 8 * sizeof(unsigned long)];
ultoa(value, buf, base);
*this = buf;
}
String::String(float value, unsigned char decimalPlaces)
{
init();
char buf[33];
*this = dtostrf(value, (decimalPlaces + 2), decimalPlaces, buf);
}
String::String(double value, unsigned char decimalPlaces)
{
init();
char buf[33];
*this = dtostrf(value, (decimalPlaces + 2), decimalPlaces, buf);
}
String::~String()
{
free(buffer);
}
/*********************************************/
/* Memory Management */
/*********************************************/
inline void String::init(void)
{
buffer = NULL;
capacity = 0;
len = 0;
}
void String::invalidate(void)
{
if (buffer) free(buffer);
buffer = NULL;
capacity = len = 0;
}
unsigned char String::reserve(unsigned int size)
{
if (buffer && capacity >= size) return 1;
if (changeBuffer(size)) {
if (len == 0) buffer[0] = 0;
return 1;
}
return 0;
}
unsigned char String::changeBuffer(unsigned int maxStrLen)
{
char *newbuffer = (char *)realloc(buffer, maxStrLen + 1);
if (newbuffer) {
buffer = newbuffer;
capacity = maxStrLen;
return 1;
}
return 0;
}
/*********************************************/
/* Copy and Move */
/*********************************************/
String & String::copy(const char *cstr, unsigned int length)
{
if (!reserve(length)) {
invalidate();
return *this;
}
len = length;
strcpy(buffer, cstr);
return *this;
}
String & String::copy(const __FlashStringHelper *pstr, unsigned int length)
{
if (!reserve(length)) {
invalidate();
return *this;
}
len = length;
strcpy_P(buffer, (PGM_P)pstr);
return *this;
}
#ifdef __GXX_EXPERIMENTAL_CXX0X__
void String::move(String &rhs)
{
if (buffer) {
if (capacity >= rhs.len) {
strcpy(buffer, rhs.buffer);
len = rhs.len;
rhs.len = 0;
return;
} else {
free(buffer);
}
}
buffer = rhs.buffer;
capacity = rhs.capacity;
len = rhs.len;
rhs.buffer = NULL;
rhs.capacity = 0;
rhs.len = 0;
}
#endif
String & String::operator = (const String &rhs)
{
if (this == &rhs) return *this;
if (rhs.buffer) copy(rhs.buffer, rhs.len);
else invalidate();
return *this;
}
#ifdef __GXX_EXPERIMENTAL_CXX0X__
String & String::operator = (String &&rval)
{
if (this != &rval) move(rval);
return *this;
}
String & String::operator = (StringSumHelper &&rval)
{
if (this != &rval) move(rval);
return *this;
}
#endif
String & String::operator = (const char *cstr)
{
if (cstr) copy(cstr, strlen(cstr));
else invalidate();
return *this;
}
String & String::operator = (const __FlashStringHelper *pstr)
{
if (pstr) copy(pstr, strlen_P((PGM_P)pstr));
else invalidate();
return *this;
}
/*********************************************/
/* concat */
/*********************************************/
unsigned char String::concat(const String &s)
{
return concat(s.buffer, s.len);
}
unsigned char String::concat(const char *cstr, unsigned int length)
{
unsigned int newlen = len + length;
if (!cstr) return 0;
if (length == 0) return 1;
if (!reserve(newlen)) return 0;
strcpy(buffer + len, cstr);
len = newlen;
return 1;
}
unsigned char String::concat(const char *cstr)
{
if (!cstr) return 0;
return concat(cstr, strlen(cstr));
}
unsigned char String::concat(char c)
{
char buf[2];
buf[0] = c;
buf[1] = 0;
return concat(buf, 1);
}
unsigned char String::concat(unsigned char num)
{
char buf[1 + 3 * sizeof(unsigned char)];
itoa(num, buf, 10);
return concat(buf, strlen(buf));
}
unsigned char String::concat(int num)
{
char buf[2 + 3 * sizeof(int)];
itoa(num, buf, 10);
return concat(buf, strlen(buf));
}
unsigned char String::concat(unsigned int num)
{
char buf[1 + 3 * sizeof(unsigned int)];
utoa(num, buf, 10);
return concat(buf, strlen(buf));
}
unsigned char String::concat(long num)
{
char buf[2 + 3 * sizeof(long)];
ltoa(num, buf, 10);
return concat(buf, strlen(buf));
}
unsigned char String::concat(unsigned long num)
{
char buf[1 + 3 * sizeof(unsigned long)];
ultoa(num, buf, 10);
return concat(buf, strlen(buf));
}
unsigned char String::concat(float num)
{
char buf[20];
char* string = dtostrf(num, 4, 2, buf);
return concat(string, strlen(string));
}
unsigned char String::concat(double num)
{
char buf[20];
char* string = dtostrf(num, 4, 2, buf);
return concat(string, strlen(string));
}
unsigned char String::concat(const __FlashStringHelper * str)
{
if (!str) return 0;
int length = strlen_P((const char *) str);
if (length == 0) return 1;
unsigned int newlen = len + length;
if (!reserve(newlen)) return 0;
strcpy_P(buffer + len, (const char *) str);
len = newlen;
return 1;
}
/*********************************************/
/* Concatenate */
/*********************************************/
StringSumHelper & operator + (const StringSumHelper &lhs, const String &rhs)
{
StringSumHelper &a = const_cast<StringSumHelper&>(lhs);
if (!a.concat(rhs.buffer, rhs.len)) a.invalidate();
return a;
}
StringSumHelper & operator + (const StringSumHelper &lhs, const char *cstr)
{
StringSumHelper &a = const_cast<StringSumHelper&>(lhs);
if (!cstr || !a.concat(cstr, strlen(cstr))) a.invalidate();
return a;
}
StringSumHelper & operator + (const StringSumHelper &lhs, char c)
{
StringSumHelper &a = const_cast<StringSumHelper&>(lhs);
if (!a.concat(c)) a.invalidate();
return a;
}
StringSumHelper & operator + (const StringSumHelper &lhs, unsigned char num)
{
StringSumHelper &a = const_cast<StringSumHelper&>(lhs);
if (!a.concat(num)) a.invalidate();
return a;
}
StringSumHelper & operator + (const StringSumHelper &lhs, int num)
{
StringSumHelper &a = const_cast<StringSumHelper&>(lhs);
if (!a.concat(num)) a.invalidate();
return a;
}
StringSumHelper & operator + (const StringSumHelper &lhs, unsigned int num)
{
StringSumHelper &a = const_cast<StringSumHelper&>(lhs);
if (!a.concat(num)) a.invalidate();
return a;
}
StringSumHelper & operator + (const StringSumHelper &lhs, long num)
{
StringSumHelper &a = const_cast<StringSumHelper&>(lhs);
if (!a.concat(num)) a.invalidate();
return a;
}
StringSumHelper & operator + (const StringSumHelper &lhs, unsigned long num)
{
StringSumHelper &a = const_cast<StringSumHelper&>(lhs);
if (!a.concat(num)) a.invalidate();
return a;
}
StringSumHelper & operator + (const StringSumHelper &lhs, float num)
{
StringSumHelper &a = const_cast<StringSumHelper&>(lhs);
if (!a.concat(num)) a.invalidate();
return a;
}
StringSumHelper & operator + (const StringSumHelper &lhs, double num)
{
StringSumHelper &a = const_cast<StringSumHelper&>(lhs);
if (!a.concat(num)) a.invalidate();
return a;
}
StringSumHelper & operator + (const StringSumHelper &lhs, const __FlashStringHelper *rhs)
{
StringSumHelper &a = const_cast<StringSumHelper&>(lhs);
if (!a.concat(rhs)) a.invalidate();
return a;
}
/*********************************************/
/* Comparison */
/*********************************************/
int String::compareTo(const String &s) const
{
if (!buffer || !s.buffer) {
if (s.buffer && s.len > 0) return 0 - *(unsigned char *)s.buffer;
if (buffer && len > 0) return *(unsigned char *)buffer;
return 0;
}
return strcmp(buffer, s.buffer);
}
unsigned char String::equals(const String &s2) const
{
return (len == s2.len && compareTo(s2) == 0);
}
unsigned char String::equals(const char *cstr) const
{
if (len == 0) return (cstr == NULL || *cstr == 0);
if (cstr == NULL) return buffer[0] == 0;
return strcmp(buffer, cstr) == 0;
}
unsigned char String::operator<(const String &rhs) const
{
return compareTo(rhs) < 0;
}
unsigned char String::operator>(const String &rhs) const
{
return compareTo(rhs) > 0;
}
unsigned char String::operator<=(const String &rhs) const
{
return compareTo(rhs) <= 0;
}
unsigned char String::operator>=(const String &rhs) const
{
return compareTo(rhs) >= 0;
}
unsigned char String::equalsIgnoreCase( const String &s2 ) const
{
if (this == &s2) return 1;
if (len != s2.len) return 0;
if (len == 0) return 1;
const char *p1 = buffer;
const char *p2 = s2.buffer;
while (*p1) {
if (tolower(*p1++) != tolower(*p2++)) return 0;
}
return 1;
}
unsigned char String::startsWith( const String &s2 ) const
{
if (len < s2.len) return 0;
return startsWith(s2, 0);
}
unsigned char String::startsWith( const String &s2, unsigned int offset ) const
{
if (offset > len - s2.len || !buffer || !s2.buffer) return 0;
return strncmp( &buffer[offset], s2.buffer, s2.len ) == 0;
}
unsigned char String::endsWith( const String &s2 ) const
{
if ( len < s2.len || !buffer || !s2.buffer) return 0;
return strcmp(&buffer[len - s2.len], s2.buffer) == 0;
}
/*********************************************/
/* Character Access */
/*********************************************/
char String::charAt(unsigned int loc) const
{
return operator[](loc);
}
void String::setCharAt(unsigned int loc, char c)
{
if (loc < len) buffer[loc] = c;
}
char & String::operator[](unsigned int index)
{
static char dummy_writable_char;
if (index >= len || !buffer) {
dummy_writable_char = 0;
return dummy_writable_char;
}
return buffer[index];
}
char String::operator[]( unsigned int index ) const
{
if (index >= len || !buffer) return 0;
return buffer[index];
}
void String::getBytes(unsigned char *buf, unsigned int bufsize, unsigned int index) const
{
if (!bufsize || !buf) return;
if (index >= len) {
buf[0] = 0;
return;
}
unsigned int n = bufsize - 1;
if (n > len - index) n = len - index;
strncpy((char *)buf, buffer + index, n);
buf[n] = 0;
}
/*********************************************/
/* Search */
/*********************************************/
int String::indexOf(char c) const
{
return indexOf(c, 0);
}
int String::indexOf( char ch, unsigned int fromIndex ) const
{
if (fromIndex >= len) return -1;
const char* temp = strchr(buffer + fromIndex, ch);
if (temp == NULL) return -1;
return temp - buffer;
}
int String::indexOf(const String &s2) const
{
return indexOf(s2, 0);
}
int String::indexOf(const String &s2, unsigned int fromIndex) const
{
if (fromIndex >= len) return -1;
const char *found = strstr(buffer + fromIndex, s2.buffer);
if (found == NULL) return -1;
return found - buffer;
}
int String::lastIndexOf( char theChar ) const
{
return lastIndexOf(theChar, len - 1);
}
int String::lastIndexOf(char ch, unsigned int fromIndex) const
{
if (fromIndex >= len) return -1;
char tempchar = buffer[fromIndex + 1];
buffer[fromIndex + 1] = '\0';
char* temp = strrchr( buffer, ch );
buffer[fromIndex + 1] = tempchar;
if (temp == NULL) return -1;
return temp - buffer;
}
int String::lastIndexOf(const String &s2) const
{
return lastIndexOf(s2, len - s2.len);
}
int String::lastIndexOf(const String &s2, unsigned int fromIndex) const
{
if (s2.len == 0 || len == 0 || s2.len > len) return -1;
if (fromIndex >= len) fromIndex = len - 1;
int found = -1;
for (char *p = buffer; p <= buffer + fromIndex; p++) {
p = strstr(p, s2.buffer);
if (!p) break;
if ((unsigned int)(p - buffer) <= fromIndex) found = p - buffer;
}
return found;
}
String String::substring(unsigned int left, unsigned int right) const
{
if (left > right) {
unsigned int temp = right;
right = left;
left = temp;
}
String out;
if (left > len) return out;
if (right > len) right = len;
char temp = buffer[right]; // save the replaced character
buffer[right] = '\0';
out = buffer + left; // pointer arithmetic
buffer[right] = temp; //restore character
return out;
}
/*********************************************/
/* Modification */
/*********************************************/
void String::replace(char find, char replace)
{
if (!buffer) return;
for (char *p = buffer; *p; p++) {
if (*p == find) *p = replace;
}
}
void String::replace(const String& find, const String& replace)
{
if (len == 0 || find.len == 0) return;
int diff = replace.len - find.len;
char *readFrom = buffer;
char *foundAt;
if (diff == 0) {
while ((foundAt = strstr(readFrom, find.buffer)) != NULL) {
memcpy(foundAt, replace.buffer, replace.len);
readFrom = foundAt + replace.len;
}
} else if (diff < 0) {
char *writeTo = buffer;
while ((foundAt = strstr(readFrom, find.buffer)) != NULL) {
unsigned int n = foundAt - readFrom;
memcpy(writeTo, readFrom, n);
writeTo += n;
memcpy(writeTo, replace.buffer, replace.len);
writeTo += replace.len;
readFrom = foundAt + find.len;
len += diff;
}
strcpy(writeTo, readFrom);
} else {
unsigned int size = len; // compute size needed for result
while ((foundAt = strstr(readFrom, find.buffer)) != NULL) {
readFrom = foundAt + find.len;
size += diff;
}
if (size == len) return;
if (size > capacity && !changeBuffer(size)) return; // XXX: tell user!
int index = len - 1;
while (index >= 0 && (index = lastIndexOf(find, index)) >= 0) {
readFrom = buffer + index + find.len;
memmove(readFrom + diff, readFrom, len - (readFrom - buffer));
len += diff;
buffer[len] = 0;
memcpy(buffer + index, replace.buffer, replace.len);
index--;
}
}
}
void String::remove(unsigned int index){
if (index >= len) { return; }
int count = len - index;
remove(index, count);
}
void String::remove(unsigned int index, unsigned int count){
if (index >= len) { return; }
if (count <= 0) { return; }
if (index + count > len) { count = len - index; }
char *writeTo = buffer + index;
len = len - count;
strncpy(writeTo, buffer + index + count,len - index);
buffer[len] = 0;
}
void String::toLowerCase(void)
{
if (!buffer) return;
for (char *p = buffer; *p; p++) {
*p = tolower(*p);
}
}
void String::toUpperCase(void)
{
if (!buffer) return;
for (char *p = buffer; *p; p++) {
*p = toupper(*p);
}
}
void String::trim(void)
{
if (!buffer || len == 0) return;
char *begin = buffer;
while (isspace(*begin)) begin++;
char *end = buffer + len - 1;
while (isspace(*end) && end >= begin) end--;
len = end + 1 - begin;
if (begin > buffer) memcpy(buffer, begin, len);
buffer[len] = 0;
}
/*********************************************/
/* Parsing / Conversion */
/*********************************************/
long String::toInt(void) const
{
if (buffer) return atol(buffer);
return 0;
}
float String::toFloat(void) const
{
if (buffer) return float(atof(buffer));
return 0;
}

View File

@@ -1,224 +0,0 @@
/*
WString.h - String library for Wiring & Arduino
...mostly rewritten by Paul Stoffregen...
Copyright (c) 2009-10 Hernando Barragan. All right reserved.
Copyright 2011, Paul Stoffregen, paul@pjrc.com
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef String_class_h
#define String_class_h
#ifdef __cplusplus
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <avr/pgmspace.h>
// When compiling programs with this class, the following gcc parameters
// dramatically increase performance and memory (RAM) efficiency, typically
// with little or no increase in code size.
// -felide-constructors
// -std=c++0x
class __FlashStringHelper;
#define F(string_literal) (reinterpret_cast<const __FlashStringHelper *>(PSTR(string_literal)))
// An inherited class for holding the result of a concatenation. These
// result objects are assumed to be writable by subsequent concatenations.
class StringSumHelper;
// The string class
class String
{
// use a function pointer to allow for "if (s)" without the
// complications of an operator bool(). for more information, see:
// http://www.artima.com/cppsource/safebool.html
typedef void (String::*StringIfHelperType)() const;
void StringIfHelper() const {}
public:
// constructors
// creates a copy of the initial value.
// if the initial value is null or invalid, or if memory allocation
// fails, the string will be marked as invalid (i.e. "if (s)" will
// be false).
String(const char *cstr = "");
String(const String &str);
String(const __FlashStringHelper *str);
#ifdef __GXX_EXPERIMENTAL_CXX0X__
String(String &&rval);
String(StringSumHelper &&rval);
#endif
explicit String(char c);
explicit String(unsigned char, unsigned char base=10);
explicit String(int, unsigned char base=10);
explicit String(unsigned int, unsigned char base=10);
explicit String(long, unsigned char base=10);
explicit String(unsigned long, unsigned char base=10);
explicit String(float, unsigned char decimalPlaces=2);
explicit String(double, unsigned char decimalPlaces=2);
~String(void);
// memory management
// return true on success, false on failure (in which case, the string
// is left unchanged). reserve(0), if successful, will validate an
// invalid string (i.e., "if (s)" will be true afterwards)
unsigned char reserve(unsigned int size);
inline unsigned int length(void) const {return len;}
// creates a copy of the assigned value. if the value is null or
// invalid, or if the memory allocation fails, the string will be
// marked as invalid ("if (s)" will be false).
String & operator = (const String &rhs);
String & operator = (const char *cstr);
String & operator = (const __FlashStringHelper *str);
#ifdef __GXX_EXPERIMENTAL_CXX0X__
String & operator = (String &&rval);
String & operator = (StringSumHelper &&rval);
#endif
// concatenate (works w/ built-in types)
// returns true on success, false on failure (in which case, the string
// is left unchanged). if the argument is null or invalid, the
// concatenation is considered unsucessful.
unsigned char concat(const String &str);
unsigned char concat(const char *cstr);
unsigned char concat(char c);
unsigned char concat(unsigned char c);
unsigned char concat(int num);
unsigned char concat(unsigned int num);
unsigned char concat(long num);
unsigned char concat(unsigned long num);
unsigned char concat(float num);
unsigned char concat(double num);
unsigned char concat(const __FlashStringHelper * str);
// if there's not enough memory for the concatenated value, the string
// will be left unchanged (but this isn't signalled in any way)
String & operator += (const String &rhs) {concat(rhs); return (*this);}
String & operator += (const char *cstr) {concat(cstr); return (*this);}
String & operator += (char c) {concat(c); return (*this);}
String & operator += (unsigned char num) {concat(num); return (*this);}
String & operator += (int num) {concat(num); return (*this);}
String & operator += (unsigned int num) {concat(num); return (*this);}
String & operator += (long num) {concat(num); return (*this);}
String & operator += (unsigned long num) {concat(num); return (*this);}
String & operator += (float num) {concat(num); return (*this);}
String & operator += (double num) {concat(num); return (*this);}
String & operator += (const __FlashStringHelper *str){concat(str); return (*this);}
friend StringSumHelper & operator + (const StringSumHelper &lhs, const String &rhs);
friend StringSumHelper & operator + (const StringSumHelper &lhs, const char *cstr);
friend StringSumHelper & operator + (const StringSumHelper &lhs, char c);
friend StringSumHelper & operator + (const StringSumHelper &lhs, unsigned char num);
friend StringSumHelper & operator + (const StringSumHelper &lhs, int num);
friend StringSumHelper & operator + (const StringSumHelper &lhs, unsigned int num);
friend StringSumHelper & operator + (const StringSumHelper &lhs, long num);
friend StringSumHelper & operator + (const StringSumHelper &lhs, unsigned long num);
friend StringSumHelper & operator + (const StringSumHelper &lhs, float num);
friend StringSumHelper & operator + (const StringSumHelper &lhs, double num);
friend StringSumHelper & operator + (const StringSumHelper &lhs, const __FlashStringHelper *rhs);
// comparison (only works w/ Strings and "strings")
operator StringIfHelperType() const { return buffer ? &String::StringIfHelper : 0; }
int compareTo(const String &s) const;
unsigned char equals(const String &s) const;
unsigned char equals(const char *cstr) const;
unsigned char operator == (const String &rhs) const {return equals(rhs);}
unsigned char operator == (const char *cstr) const {return equals(cstr);}
unsigned char operator != (const String &rhs) const {return !equals(rhs);}
unsigned char operator != (const char *cstr) const {return !equals(cstr);}
unsigned char operator < (const String &rhs) const;
unsigned char operator > (const String &rhs) const;
unsigned char operator <= (const String &rhs) const;
unsigned char operator >= (const String &rhs) const;
unsigned char equalsIgnoreCase(const String &s) const;
unsigned char startsWith( const String &prefix) const;
unsigned char startsWith(const String &prefix, unsigned int offset) const;
unsigned char endsWith(const String &suffix) const;
// character acccess
char charAt(unsigned int index) const;
void setCharAt(unsigned int index, char c);
char operator [] (unsigned int index) const;
char& operator [] (unsigned int index);
void getBytes(unsigned char *buf, unsigned int bufsize, unsigned int index=0) const;
void toCharArray(char *buf, unsigned int bufsize, unsigned int index=0) const
{getBytes((unsigned char *)buf, bufsize, index);}
const char * c_str() const { return buffer; }
// search
int indexOf( char ch ) const;
int indexOf( char ch, unsigned int fromIndex ) const;
int indexOf( const String &str ) const;
int indexOf( const String &str, unsigned int fromIndex ) const;
int lastIndexOf( char ch ) const;
int lastIndexOf( char ch, unsigned int fromIndex ) const;
int lastIndexOf( const String &str ) const;
int lastIndexOf( const String &str, unsigned int fromIndex ) const;
String substring( unsigned int beginIndex ) const { return substring(beginIndex, len); };
String substring( unsigned int beginIndex, unsigned int endIndex ) const;
// modification
void replace(char find, char replace);
void replace(const String& find, const String& replace);
void remove(unsigned int index);
void remove(unsigned int index, unsigned int count);
void toLowerCase(void);
void toUpperCase(void);
void trim(void);
// parsing/conversion
long toInt(void) const;
float toFloat(void) const;
protected:
char *buffer; // the actual char array
unsigned int capacity; // the array length minus one (for the '\0')
unsigned int len; // the String length (not counting the '\0')
protected:
void init(void);
void invalidate(void);
unsigned char changeBuffer(unsigned int maxStrLen);
unsigned char concat(const char *cstr, unsigned int length);
// copy and move
String & copy(const char *cstr, unsigned int length);
String & copy(const __FlashStringHelper *pstr, unsigned int length);
#ifdef __GXX_EXPERIMENTAL_CXX0X__
void move(String &rhs);
#endif
};
class StringSumHelper : public String
{
public:
StringSumHelper(const String &s) : String(s) {}
StringSumHelper(const char *p) : String(p) {}
StringSumHelper(char c) : String(c) {}
StringSumHelper(unsigned char num) : String(num) {}
StringSumHelper(int num) : String(num) {}
StringSumHelper(unsigned int num) : String(num) {}
StringSumHelper(long num) : String(num) {}
StringSumHelper(unsigned long num) : String(num) {}
StringSumHelper(float num) : String(num) {}
StringSumHelper(double num) : String(num) {}
};
#endif // __cplusplus
#endif // String_class_h

View File

@@ -1,267 +0,0 @@
/* Copyright (c) 2002, 2004, 2010 Joerg Wunsch
Copyright (c) 2010 Gerben van den Broeke
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* 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.
* Neither the name of the copyright holders nor the names of
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 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.
*/
/* $Id: malloc.c 2149 2010-06-09 20:45:37Z joerg_wunsch $ */
#include <stdlib.h>
#include "sectionname.h"
#include "stdlib_private.h"
#include <avr/io.h>
/*
* Exported interface:
*
* When extending the data segment, the allocator will not try to go
* beyond the current stack limit, decreased by __malloc_margin bytes.
* Thus, all possible stack frames of interrupt routines that could
* interrupt the current function, plus all further nested function
* calls must not require more stack space, or they'll risk to collide
* with the data segment.
*/
/* May be changed by the user only before the first malloc() call. */
size_t __malloc_margin = 128;
char *__malloc_heap_start = &__heap_start;
char *__malloc_heap_end = &__heap_end;
char *__brkval;
struct __freelist *__flp;
ATTRIBUTE_CLIB_SECTION
void *
malloc(size_t len)
{
struct __freelist *fp1, *fp2, *sfp1=NULL, *sfp2=NULL; // BBB - added '=NULL' for sfp1, sfp2 as they were warned as being uninitialized
char *cp;
size_t s, avail;
/*
* Our minimum chunk size is the size of a pointer (plus the
* size of the "sz" field, but we don't need to account for
* this), otherwise we could not possibly fit a freelist entry
* into the chunk later.
*/
if (len < sizeof(struct __freelist) - sizeof(size_t))
len = sizeof(struct __freelist) - sizeof(size_t);
/*
* First, walk the free list and try finding a chunk that
* would match exactly. If we found one, we are done. While
* walking, note down the smallest chunk we found that would
* still fit the request -- we need it for step 2.
*
*/
for (s = 0, fp1 = __flp, fp2 = 0;
fp1;
fp2 = fp1, fp1 = fp1->nx) {
if (fp1->sz < len)
continue;
if (fp1->sz == len) {
/*
* Found it. Disconnect the chunk from the
* freelist, and return it.
*/
if (fp2)
fp2->nx = fp1->nx;
else
__flp = fp1->nx;
return &(fp1->nx);
}
else {
if (s == 0 || fp1->sz < s) {
/* this is the smallest chunk found so far */
s = fp1->sz;
sfp1 = fp1;
sfp2 = fp2;
}
}
}
/*
* Step 2: If we found a chunk on the freelist that would fit
* (but was too large), look it up again and use it, since it
* is our closest match now. Since the freelist entry needs
* to be split into two entries then, watch out that the
* difference between the requested size and the size of the
* chunk found is large enough for another freelist entry; if
* not, just enlarge the request size to what we have found,
* and use the entire chunk.
*/
if (s) {
if (s - len < sizeof(struct __freelist)) {
/* Disconnect it from freelist and return it. */
if (sfp2)
sfp2->nx = sfp1->nx;
else
__flp = sfp1->nx;
return &(sfp1->nx);
}
/*
* Split them up. Note that we leave the first part
* as the new (smaller) freelist entry, and return the
* upper portion to the caller. This saves us the
* work to fix up the freelist chain; we just need to
* fixup the size of the current entry, and note down
* the size of the new chunk before returning it to
* the caller.
*/
cp = (char *)sfp1;
s -= len;
cp += s;
sfp2 = (struct __freelist *)cp;
sfp2->sz = len;
sfp1->sz = s - sizeof(size_t);
return &(sfp2->nx);
}
/*
* Step 3: If the request could not be satisfied from a
* freelist entry, just prepare a new chunk. This means we
* need to obtain more memory first. The largest address just
* not allocated so far is remembered in the brkval variable.
* Under Unix, the "break value" was the end of the data
* segment as dynamically requested from the operating system.
* Since we don't have an operating system, just make sure
* that we don't collide with the stack.
*/
if (__brkval == 0)
__brkval = __malloc_heap_start;
cp = __malloc_heap_end;
if (cp == 0)
cp = STACK_POINTER() - __malloc_margin;
if (cp <= __brkval)
/*
* Memory exhausted.
*/
return 0;
avail = cp - __brkval;
/*
* Both tests below are needed to catch the case len >= 0xfffe.
*/
if (avail >= len && avail >= len + sizeof(size_t)) {
fp1 = (struct __freelist *)__brkval;
__brkval += len + sizeof(size_t);
fp1->sz = len;
return &(fp1->nx);
}
/*
* Step 4: There's no help, just fail. :-/
*/
return 0;
}
ATTRIBUTE_CLIB_SECTION
void
free(void *p)
{
struct __freelist *fp1, *fp2, *fpnew;
char *cp1, *cp2, *cpnew;
/* ISO C says free(NULL) must be a no-op */
if (p == 0)
return;
cpnew = p;
cpnew -= sizeof(size_t);
fpnew = (struct __freelist *)cpnew;
fpnew->nx = 0;
/*
* Trivial case first: if there's no freelist yet, our entry
* will be the only one on it. If this is the last entry, we
* can reduce __brkval instead.
*/
if (__flp == 0) {
if ((char *)p + fpnew->sz == __brkval)
__brkval = cpnew;
else
__flp = fpnew;
return;
}
/*
* Now, find the position where our new entry belongs onto the
* freelist. Try to aggregate the chunk with adjacent chunks
* if possible.
*/
for (fp1 = __flp, fp2 = 0;
fp1;
fp2 = fp1, fp1 = fp1->nx) {
if (fp1 < fpnew)
continue;
cp1 = (char *)fp1;
fpnew->nx = fp1;
if ((char *)&(fpnew->nx) + fpnew->sz == cp1) {
/* upper chunk adjacent, assimilate it */
fpnew->sz += fp1->sz + sizeof(size_t);
fpnew->nx = fp1->nx;
}
if (fp2 == 0) {
/* new head of freelist */
__flp = fpnew;
return;
}
break;
}
/*
* Note that we get here either if we hit the "break" above,
* or if we fell off the end of the loop. The latter means
* we've got a new topmost chunk. Either way, try aggregating
* with the lower chunk if possible.
*/
fp2->nx = fpnew;
cp2 = (char *)&(fp2->nx);
if (cp2 + fp2->sz == cpnew) {
/* lower junk adjacent, merge */
fp2->sz += fpnew->sz + sizeof(size_t);
fp2->nx = fpnew->nx;
}
/*
* If there's a new topmost chunk, lower __brkval instead.
*/
for (fp1 = __flp, fp2 = 0;
fp1->nx != 0;
fp2 = fp1, fp1 = fp1->nx)
/* advance to entry just before end of list */;
cp2 = (char *)&(fp1->nx);
if (cp2 + fp1->sz == __brkval) {
if (fp2 == NULL)
/* Freelist is empty now. */
__flp = NULL;
else
fp2->nx = NULL;
__brkval = cp2 - sizeof(size_t);
}
}

View File

@@ -1,150 +0,0 @@
/* Copyright (c) 2004, 2010 Joerg Wunsch
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* 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.
* Neither the name of the copyright holders nor the names of
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 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.
*/
/* $Id: realloc.c 2127 2010-06-07 14:49:37Z joerg_wunsch $ */
#include <stdlib.h>
#include <string.h>
#include "sectionname.h"
#include "stdlib_private.h"
#include <avr/io.h>
ATTRIBUTE_CLIB_SECTION
void *
realloc(void *ptr, size_t len)
{
struct __freelist *fp1, *fp2, *fp3, *ofp3;
char *cp, *cp1;
void *memp;
size_t s, incr;
/* Trivial case, required by C standard. */
if (ptr == 0)
return malloc(len);
cp1 = (char *)ptr;
cp1 -= sizeof(size_t);
fp1 = (struct __freelist *)cp1;
cp = (char *)ptr + len; /* new next pointer */
if (cp < cp1)
/* Pointer wrapped across top of RAM, fail. */
return 0;
/*
* See whether we are growing or shrinking. When shrinking,
* we split off a chunk for the released portion, and call
* free() on it. Therefore, we can only shrink if the new
* size is at least sizeof(struct __freelist) smaller than the
* previous size.
*/
if (len <= fp1->sz) {
/* The first test catches a possible unsigned int
* rollover condition. */
if (fp1->sz <= sizeof(struct __freelist) ||
len > fp1->sz - sizeof(struct __freelist))
return ptr;
fp2 = (struct __freelist *)cp;
fp2->sz = fp1->sz - len - sizeof(size_t);
fp1->sz = len;
free(&(fp2->nx));
return ptr;
}
/*
* If we get here, we are growing. First, see whether there
* is space in the free list on top of our current chunk.
*/
incr = len - fp1->sz;
cp = (char *)ptr + fp1->sz;
fp2 = (struct __freelist *)cp;
for (s = 0, ofp3 = 0, fp3 = __flp;
fp3;
ofp3 = fp3, fp3 = fp3->nx) {
if (fp3 == fp2 && fp3->sz + sizeof(size_t) >= incr) {
/* found something that fits */
if (fp3->sz + sizeof(size_t) - incr > sizeof(struct __freelist)) {
/* split off a new freelist entry */
cp = (char *)ptr + len;
fp2 = (struct __freelist *)cp;
fp2->nx = fp3->nx;
fp2->sz = fp3->sz - incr;
fp1->sz = len;
} else {
/* it just fits, so use it entirely */
fp1->sz += fp3->sz + sizeof(size_t);
fp2 = fp3->nx;
}
if (ofp3)
ofp3->nx = fp2;
else
__flp = fp2;
return ptr;
}
/*
* Find the largest chunk on the freelist while
* walking it.
*/
if (fp3->sz > s)
s = fp3->sz;
}
/*
* If we are the topmost chunk in memory, and there was no
* large enough chunk on the freelist that could be re-used
* (by a call to malloc() below), quickly extend the
* allocation area if possible, without need to copy the old
* data.
*/
if (__brkval == (char *)ptr + fp1->sz && len > s) {
cp1 = __malloc_heap_end;
cp = (char *)ptr + len;
if (cp1 == 0)
cp1 = STACK_POINTER() - __malloc_margin;
if (cp < cp1) {
__brkval = cp;
fp1->sz = len;
return ptr;
}
/* If that failed, we are out of luck. */
return 0;
}
/*
* Call malloc() for a new chunk, then copy over the data, and
* release the old region.
*/
if ((memp = malloc(len)) == 0)
return 0;
memcpy(memp, ptr, fp1->sz);
free(ptr);
return memp;
}

View File

@@ -1,49 +0,0 @@
/* Copyright (c) 2009 Atmel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* 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.
* Neither the name of the copyright holders nor the names of
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 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 __SECTIONNAME_H__
#define __SECTIONNAME_H__
/* Put all avr-libc functions in a common, unique sub-section name under .text. */
#define CLIB_SECTION .text.avr-libc
#define MLIB_SECTION .text.avr-libc.fplib
#define STR(x) _STR(x)
#define _STR(x) #x
#define ATTRIBUTE_CLIB_SECTION __attribute__ ((section (STR(CLIB_SECTION))))
#define ATTRIBUTE_MLIB_SECTION __attribute__ ((section (STR(MLIB_SECTION))))
#define ASSEMBLY_CLIB_SECTION .section CLIB_SECTION, "ax", @progbits
#define ASSEMBLY_MLIB_SECTION .section MLIB_SECTION, "ax", @progbits
#endif

View File

@@ -1,58 +0,0 @@
/* Copyright (c) 2004, Joerg Wunsch
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* 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.
* Neither the name of the copyright holders nor the names of
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 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.
*/
/* $Id: stdlib_private.h 1657 2008-03-24 17:11:08Z arcanum $ */
#include <inttypes.h>
#include <stdlib.h>
#include <avr/io.h>
#if !defined(__DOXYGEN__)
struct __freelist {
size_t sz;
struct __freelist *nx;
};
#endif
extern char *__brkval; /* first location not yet allocated */
extern struct __freelist *__flp; /* freelist pointer (head of freelist) */
extern size_t __malloc_margin; /* user-changeable before the first malloc() */
extern char *__malloc_heap_start;
extern char *__malloc_heap_end;
extern char __heap_start;
extern char __heap_end;
/* Needed for definition of AVR_STACK_POINTER_REG. */
#include <avr/io.h>
#define STACK_POINTER() ((char *)AVR_STACK_POINTER_REG)

View File

@@ -1,534 +0,0 @@
/*
binary.h - Definitions for binary constants
Copyright (c) 2006 David A. Mellis. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef Binary_h
#define Binary_h
#define B0 0
#define B00 0
#define B000 0
#define B0000 0
#define B00000 0
#define B000000 0
#define B0000000 0
#define B00000000 0
#define B1 1
#define B01 1
#define B001 1
#define B0001 1
#define B00001 1
#define B000001 1
#define B0000001 1
#define B00000001 1
#define B10 2
#define B010 2
#define B0010 2
#define B00010 2
#define B000010 2
#define B0000010 2
#define B00000010 2
#define B11 3
#define B011 3
#define B0011 3
#define B00011 3
#define B000011 3
#define B0000011 3
#define B00000011 3
#define B100 4
#define B0100 4
#define B00100 4
#define B000100 4
#define B0000100 4
#define B00000100 4
#define B101 5
#define B0101 5
#define B00101 5
#define B000101 5
#define B0000101 5
#define B00000101 5
#define B110 6
#define B0110 6
#define B00110 6
#define B000110 6
#define B0000110 6
#define B00000110 6
#define B111 7
#define B0111 7
#define B00111 7
#define B000111 7
#define B0000111 7
#define B00000111 7
#define B1000 8
#define B01000 8
#define B001000 8
#define B0001000 8
#define B00001000 8
#define B1001 9
#define B01001 9
#define B001001 9
#define B0001001 9
#define B00001001 9
#define B1010 10
#define B01010 10
#define B001010 10
#define B0001010 10
#define B00001010 10
#define B1011 11
#define B01011 11
#define B001011 11
#define B0001011 11
#define B00001011 11
#define B1100 12
#define B01100 12
#define B001100 12
#define B0001100 12
#define B00001100 12
#define B1101 13
#define B01101 13
#define B001101 13
#define B0001101 13
#define B00001101 13
#define B1110 14
#define B01110 14
#define B001110 14
#define B0001110 14
#define B00001110 14
#define B1111 15
#define B01111 15
#define B001111 15
#define B0001111 15
#define B00001111 15
#define B10000 16
#define B010000 16
#define B0010000 16
#define B00010000 16
#define B10001 17
#define B010001 17
#define B0010001 17
#define B00010001 17
#define B10010 18
#define B010010 18
#define B0010010 18
#define B00010010 18
#define B10011 19
#define B010011 19
#define B0010011 19
#define B00010011 19
#define B10100 20
#define B010100 20
#define B0010100 20
#define B00010100 20
#define B10101 21
#define B010101 21
#define B0010101 21
#define B00010101 21
#define B10110 22
#define B010110 22
#define B0010110 22
#define B00010110 22
#define B10111 23
#define B010111 23
#define B0010111 23
#define B00010111 23
#define B11000 24
#define B011000 24
#define B0011000 24
#define B00011000 24
#define B11001 25
#define B011001 25
#define B0011001 25
#define B00011001 25
#define B11010 26
#define B011010 26
#define B0011010 26
#define B00011010 26
#define B11011 27
#define B011011 27
#define B0011011 27
#define B00011011 27
#define B11100 28
#define B011100 28
#define B0011100 28
#define B00011100 28
#define B11101 29
#define B011101 29
#define B0011101 29
#define B00011101 29
#define B11110 30
#define B011110 30
#define B0011110 30
#define B00011110 30
#define B11111 31
#define B011111 31
#define B0011111 31
#define B00011111 31
#define B100000 32
#define B0100000 32
#define B00100000 32
#define B100001 33
#define B0100001 33
#define B00100001 33
#define B100010 34
#define B0100010 34
#define B00100010 34
#define B100011 35
#define B0100011 35
#define B00100011 35
#define B100100 36
#define B0100100 36
#define B00100100 36
#define B100101 37
#define B0100101 37
#define B00100101 37
#define B100110 38
#define B0100110 38
#define B00100110 38
#define B100111 39
#define B0100111 39
#define B00100111 39
#define B101000 40
#define B0101000 40
#define B00101000 40
#define B101001 41
#define B0101001 41
#define B00101001 41
#define B101010 42
#define B0101010 42
#define B00101010 42
#define B101011 43
#define B0101011 43
#define B00101011 43
#define B101100 44
#define B0101100 44
#define B00101100 44
#define B101101 45
#define B0101101 45
#define B00101101 45
#define B101110 46
#define B0101110 46
#define B00101110 46
#define B101111 47
#define B0101111 47
#define B00101111 47
#define B110000 48
#define B0110000 48
#define B00110000 48
#define B110001 49
#define B0110001 49
#define B00110001 49
#define B110010 50
#define B0110010 50
#define B00110010 50
#define B110011 51
#define B0110011 51
#define B00110011 51
#define B110100 52
#define B0110100 52
#define B00110100 52
#define B110101 53
#define B0110101 53
#define B00110101 53
#define B110110 54
#define B0110110 54
#define B00110110 54
#define B110111 55
#define B0110111 55
#define B00110111 55
#define B111000 56
#define B0111000 56
#define B00111000 56
#define B111001 57
#define B0111001 57
#define B00111001 57
#define B111010 58
#define B0111010 58
#define B00111010 58
#define B111011 59
#define B0111011 59
#define B00111011 59
#define B111100 60
#define B0111100 60
#define B00111100 60
#define B111101 61
#define B0111101 61
#define B00111101 61
#define B111110 62
#define B0111110 62
#define B00111110 62
#define B111111 63
#define B0111111 63
#define B00111111 63
#define B1000000 64
#define B01000000 64
#define B1000001 65
#define B01000001 65
#define B1000010 66
#define B01000010 66
#define B1000011 67
#define B01000011 67
#define B1000100 68
#define B01000100 68
#define B1000101 69
#define B01000101 69
#define B1000110 70
#define B01000110 70
#define B1000111 71
#define B01000111 71
#define B1001000 72
#define B01001000 72
#define B1001001 73
#define B01001001 73
#define B1001010 74
#define B01001010 74
#define B1001011 75
#define B01001011 75
#define B1001100 76
#define B01001100 76
#define B1001101 77
#define B01001101 77
#define B1001110 78
#define B01001110 78
#define B1001111 79
#define B01001111 79
#define B1010000 80
#define B01010000 80
#define B1010001 81
#define B01010001 81
#define B1010010 82
#define B01010010 82
#define B1010011 83
#define B01010011 83
#define B1010100 84
#define B01010100 84
#define B1010101 85
#define B01010101 85
#define B1010110 86
#define B01010110 86
#define B1010111 87
#define B01010111 87
#define B1011000 88
#define B01011000 88
#define B1011001 89
#define B01011001 89
#define B1011010 90
#define B01011010 90
#define B1011011 91
#define B01011011 91
#define B1011100 92
#define B01011100 92
#define B1011101 93
#define B01011101 93
#define B1011110 94
#define B01011110 94
#define B1011111 95
#define B01011111 95
#define B1100000 96
#define B01100000 96
#define B1100001 97
#define B01100001 97
#define B1100010 98
#define B01100010 98
#define B1100011 99
#define B01100011 99
#define B1100100 100
#define B01100100 100
#define B1100101 101
#define B01100101 101
#define B1100110 102
#define B01100110 102
#define B1100111 103
#define B01100111 103
#define B1101000 104
#define B01101000 104
#define B1101001 105
#define B01101001 105
#define B1101010 106
#define B01101010 106
#define B1101011 107
#define B01101011 107
#define B1101100 108
#define B01101100 108
#define B1101101 109
#define B01101101 109
#define B1101110 110
#define B01101110 110
#define B1101111 111
#define B01101111 111
#define B1110000 112
#define B01110000 112
#define B1110001 113
#define B01110001 113
#define B1110010 114
#define B01110010 114
#define B1110011 115
#define B01110011 115
#define B1110100 116
#define B01110100 116
#define B1110101 117
#define B01110101 117
#define B1110110 118
#define B01110110 118
#define B1110111 119
#define B01110111 119
#define B1111000 120
#define B01111000 120
#define B1111001 121
#define B01111001 121
#define B1111010 122
#define B01111010 122
#define B1111011 123
#define B01111011 123
#define B1111100 124
#define B01111100 124
#define B1111101 125
#define B01111101 125
#define B1111110 126
#define B01111110 126
#define B1111111 127
#define B01111111 127
#define B10000000 128
#define B10000001 129
#define B10000010 130
#define B10000011 131
#define B10000100 132
#define B10000101 133
#define B10000110 134
#define B10000111 135
#define B10001000 136
#define B10001001 137
#define B10001010 138
#define B10001011 139
#define B10001100 140
#define B10001101 141
#define B10001110 142
#define B10001111 143
#define B10010000 144
#define B10010001 145
#define B10010010 146
#define B10010011 147
#define B10010100 148
#define B10010101 149
#define B10010110 150
#define B10010111 151
#define B10011000 152
#define B10011001 153
#define B10011010 154
#define B10011011 155
#define B10011100 156
#define B10011101 157
#define B10011110 158
#define B10011111 159
#define B10100000 160
#define B10100001 161
#define B10100010 162
#define B10100011 163
#define B10100100 164
#define B10100101 165
#define B10100110 166
#define B10100111 167
#define B10101000 168
#define B10101001 169
#define B10101010 170
#define B10101011 171
#define B10101100 172
#define B10101101 173
#define B10101110 174
#define B10101111 175
#define B10110000 176
#define B10110001 177
#define B10110010 178
#define B10110011 179
#define B10110100 180
#define B10110101 181
#define B10110110 182
#define B10110111 183
#define B10111000 184
#define B10111001 185
#define B10111010 186
#define B10111011 187
#define B10111100 188
#define B10111101 189
#define B10111110 190
#define B10111111 191
#define B11000000 192
#define B11000001 193
#define B11000010 194
#define B11000011 195
#define B11000100 196
#define B11000101 197
#define B11000110 198
#define B11000111 199
#define B11001000 200
#define B11001001 201
#define B11001010 202
#define B11001011 203
#define B11001100 204
#define B11001101 205
#define B11001110 206
#define B11001111 207
#define B11010000 208
#define B11010001 209
#define B11010010 210
#define B11010011 211
#define B11010100 212
#define B11010101 213
#define B11010110 214
#define B11010111 215
#define B11011000 216
#define B11011001 217
#define B11011010 218
#define B11011011 219
#define B11011100 220
#define B11011101 221
#define B11011110 222
#define B11011111 223
#define B11100000 224
#define B11100001 225
#define B11100010 226
#define B11100011 227
#define B11100100 228
#define B11100101 229
#define B11100110 230
#define B11100111 231
#define B11101000 232
#define B11101001 233
#define B11101010 234
#define B11101011 235
#define B11101100 236
#define B11101101 237
#define B11101110 238
#define B11101111 239
#define B11110000 240
#define B11110001 241
#define B11110010 242
#define B11110011 243
#define B11110100 244
#define B11110101 245
#define B11110110 246
#define B11110111 247
#define B11111000 248
#define B11111001 249
#define B11111010 250
#define B11111011 251
#define B11111100 252
#define B11111101 253
#define B11111110 254
#define B11111111 255
#endif

View File

@@ -1,68 +0,0 @@
/*
main.cpp - Main loop for Arduino sketches
Copyright (c) 2005-2013 Arduino Team. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
//#include <Arduino.h> Platform.h includes Arduino.h
#include <Platform.h> /* to make sure that Arduino.h is included, as well as pins_arduino.h and other things */
#ifdef EIND
// if I have an EIND register, I want it pre-loaded with the correct value
// for info on THIS thing, see http://gcc.gnu.org/onlinedocs/gcc/AVR-Options.html
// in essence, 'init3' section functions run just before 'main()'
// must prototype it to get all of the attributes
static void __attribute__((section(".init3"),naked,used,no_instrument_function)) init3_set_eind (void);
void init3_set_eind (void)
{
__asm volatile ("ldi r24,pm_hh8(__trampolines_start)\n\t"
"out %i0,r24" :: "n" (&EIND) : "r24","memory");
}
#endif // EIND
//Declared weak in Arduino.h to allow user redefinitions.
int atexit(void (*func)()) { return 0; }
// Weak empty variant initialization function.
// May be redefined by variant files.
void initVariant() __attribute__((weak));
void initVariant() { }
int main(void)
{
init();
initVariant();
// TEMPORARY - moved [so I can debug it]
//#if defined(USBCON)
// USBDevice.attach();
//#endif
setup();
for (;;) {
loop();
if (serialEventRun) serialEventRun();
}
return 0;
}

View File

@@ -1,28 +0,0 @@
#include <new.h>
void * operator new(size_t size)
{
return malloc(size);
}
void * operator new[](size_t size)
{
return malloc(size);
}
void operator delete(void * ptr)
{
free(ptr);
}
void operator delete[](void * ptr)
{
free(ptr);
}
int __cxa_guard_acquire(__guard *g) {return !*(char *)(g);};
void __cxa_guard_release (__guard *g) {*(char *)g = 1;};
void __cxa_guard_abort (__guard *) {};
void __cxa_pure_virtual(void) {};

View File

@@ -1,24 +0,0 @@
/* Header to define new/delete operators as they aren't provided by avr-gcc by default
Taken from http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=59453
*/
#ifndef NEW_H
#define NEW_H
#include <stdlib.h>
void * operator new(size_t size);
void * operator new[](size_t size);
void operator delete(void * ptr);
void operator delete[](void * ptr);
__extension__ typedef int __guard __attribute__((mode (__DI__)));
extern "C" int __cxa_guard_acquire(__guard *);
extern "C" void __cxa_guard_release (__guard *);
extern "C" void __cxa_guard_abort (__guard *);
extern "C" void __cxa_pure_virtual(void);
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -1,859 +0,0 @@
/*
wiring_analog.c - analog input and output
Part of Arduino - http://www.arduino.cc/
Copyright (c) 2005-2006 David A. Mellis
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
Boston, MA 02111-1307 USA
Modified 28 September 2010 by Mark Sproul
Updated for 'xmega' core by bob frazier, S.F.T. Inc. - http://mrp3.com/
In some cases, the xmega updates make assumptions about the pin assignments.
See 'pins_arduino.h' for more detail.
*/
#include "wiring_private.h"
#include "pins_arduino.h"
//#define DEBUG_CODE
#ifdef DEBUG_CODE
extern void DebugOutL(unsigned long lVal);
extern void DebugOutP(const void * PROGMEM pStr);
#endif // DEBUG_CODE
#ifndef ADCA_SAMPCTRL
#define ADCA_SAMPCTRL _SFR_MEM8(0x0208) /* missing from header for some reason, struct defines it as reserved_0x08 */
#endif // ADCA_SAMPCTRL
uint8_t analog_reference, muxctrl_muxneg; // = ADC_REFSEL2_bp;// the default analog reference is Vcc / 2 (now assigned in adc_setup)
// NOTE: On the A-series processors with more than a handful of inputs,
// it is NOT possible to use 'diff input with gain' on MORE than
// A0-A7. On later processors (like D series) it _IS_ possible.
// Because of this, the 'hack' that allows rail-rail measurements
// is no longer possible on PB0-PB7. PA0-PA7 will still work.
// IF PA0 or PB0 is used as VRef (see 28.16.3 in AU manual) via 'REFCTRL'
// then you can read all 15 remaining values with whatever VRef you want.
// adc_setup() - call this from init() and whenever you wake up from sleep mode
void adc_setup(void)
{
// calibration is a 16-bit register - CAL0 + (CAL1 << 8)
ADCA_CAL = (uint16_t)readCalibrationData((uint8_t)(uint16_t)&PRODSIGNATURES_ADCACAL0)
| (((uint16_t)readCalibrationData((uint8_t)(uint16_t)&PRODSIGNATURES_ADCACAL1)) << 8);
// must make sure power reduction register enables the ADC
PR_PRPA &= ~PR_ADC_bm; // clear this bit to enable the ADC clock
// assign clock prescaler for 100khz, and clear the interrupt bit
// also make sure the 'interrupt enable' is OFF
ADCA_EVCTRL = 0; // no triggering events (sect 22.14.4)
ADCA_PRESCALER = ADC_PRESCALER_DIV256_gc; // 100khz, approximately, for 32Mhz clock
ADCA_CTRLA = _BV(ADC_ENABLE_bp); // enables the ADC
ADCA_CTRLB = _BV(6) | _BV(4); // medium current limit, signed mode [temporary]
// _BV(6) | _BV(5); // section 22.14.2, 'HIGH' current limit, no apparent bit value constants in iox64d4.h
// NOTE: all other bits are zero - no 'freerun', 12-bit right-justified unsigned mode
analog_reference = 1; // which is NONE of the possibilities
ADCA_REFCTRL = 0; // pre-assign zero to this, as I'll OR bits into it
#ifdef USE_AREF
analogReference(USE_AREF);
#else // everything else - NOTE: do I want to do this different for 'A' series?
analogReference(analogReference_VCCDIV2);
#endif // USE_AREF
// TODO: is this actually a RESERVED functionality?
ADCA_SAMPCTRL = 24; // sect 22.14.8 - this value + 1 is # of "half cycles" used for sampling
// in this case, it's 25 "half cycles" at 100khz, or appx 8khz (125uS)
// adjust this for 'best accuracy' without taking for-freaking-evar
// also make sure the sample rate is lower than the 'HIGH LIMIT' max rate (see 22.14.2)
// set up the channel (no offset calc at this time - later do an offset calc)
ADCA_CH0_SCAN = 0; // disable scan
ADCA_CH0_INTCTRL = 0; // no interrupts, flag on complete sect 22.15.3
// clear interrupt flag (probably not needed)
ADCA_INTFLAGS = _BV(ADC_CH0IF_bp); // write a 1 to the interrupt bit (which clears it - 22.14.6)
analogRead(0); // do a single conversion so that everything stabilizes
// these are taken care of at the beginning of the function, as a 16-bit register assignment to ADCA_CAL
// ADCA.CALL = readCalibrationData(&PRODSIGNATURES_ADCACAL0);
// ADCA.CALH = readCalibrationData(&PRODSIGNATURES_ADCACAL1);
}
// see _analogReference_ enum
static uint8_t normal_adca_ch0_ctrl_bits(void) // also assigns 'muxctrl_muxneg'
{
#if defined (__AVR_ATxmega8E5__) || defined (__AVR_ATxmega16E5__) || defined (__AVR_ATxmega32E5__)
// NOTE: the E5 has a significant difference in how it handles 'DIFF WITH GAIN'
// ADC_CH_INPUTMODE_DIFFWGAINL_gc uses A0-A3, GND, and internal GND (not same as D and earlier)
// ADC_CH_INPUTMODE_DIFFWGAINH_gc uses A4-A7 and GND (see E manual table 24-16,17 pg 366-7) (similar to D and earlier)
if(analog_reference == analogReference_VCCDIV2)
{
return ADC_CH_INPUTMODE_DIFFWGAINH_gc | ADC_CH_GAIN_DIV2_gc; // gain of 1/2 for VCC/2
}
else
{
return ADC_CH_INPUTMODE_DIFFWGAINH_gc | ADC_CH_GAIN_1X_gc;
}
#else // everything NOT an 'E' series
if(analog_reference == analogReference_VCCDIV2)
{
// NOTE: On the A-series processors with more than a handful of inputs,
// it is NOT possible to use 'diff input with gain' on MORE than
// A0-A7. On later processors (like D series) it _IS_ possible.
// Because of this, the 'hack' that allows rail-rail measurements
// is no longer possible on PB0-PB7. PA0-PA7 will still work.
// IF PA0 or PB0 is used as VRef (see 28.16.3 in AU manual) via 'REFCTRL'
// then you can read all 15 remaining values with whatever VRef you want.
return ADC_CH_INPUTMODE_DIFFWGAIN_gc | ADC_CH_GAIN_DIV2_gc; // gain of 1/2 for VCC/2
}
else
{
// NOTE: this one uses a different 'muxneg' (see below, 'analogReference()')
return ADC_CH_INPUTMODE_DIFF_gc | ADC_CH_GAIN_1X_gc;
}
#endif // E series or not
}
void analogReference(uint8_t bMode)
{
if((bMode & ADC_REFSEL_gm) != bMode)
{
bMode &= ADC_REFSEL_gm;
}
if(bMode != analog_reference)
{
analog_reference = bMode;
// changes to this must be reflected in ADCA_REFCTRL and ADCA_CH0_MUXCTRL
// when I read a specific pin. I assign the 'muxneg' bits according muxctrl_muxneg
ADCA_REFCTRL = (ADCA_REFCTRL & ~(ADC_REFSEL_gm))
| analog_reference // section 22.14.3, or 28.16.3 in 'AU' manual
| ADC_BANDGAP_bm; // enable 'bandgap' i.e. 1V reference
// NOTE: all other ADCA_REFCTRL bits are zero (like tempref) - section 22.14.3
// ASSIGNING ADCA_CH0_CTRL and muxctrl_muxneg
ADCA_CH0_CTRL = normal_adca_ch0_ctrl_bits();
// assign 'muxneg' according to what teh analog reference is
#if defined (__AVR_ATxmega8E5__) || (__AVR_ATxmega16E5__) || defined (__AVR_ATxmega32E5__)
muxctrl_muxneg = 7; /* bits 111 which is GND for MUXNEG - see E manual 24.15.2 */
#else // everything NOT an 'E' series
if(analog_reference == analogReference_VCCDIV2)
{
// analog delta WITH GAIN always uses this
muxctrl_muxneg = 7; /* bits 111 which is GND for MUXNEG - see D manual 22.15.2, A manual 28.17.2 */
}
else
{
// analog delta WITHOUT GAIN uses THIS
muxctrl_muxneg = 5; /* bits 101 which is GND for MUXNEG - see D manual 22.15.2, A manual 28.17.2 */
}
#endif // E series or not
}
}
// For 100% atmega compatibility, analogRead will return a value of 0-1023
// for input voltages of 0 to Vcc (assuming AVCC is connected to VCC, etc.)
// by using a gain of 1/2, a comparison of Vcc/2, and signed conversion
int analogRead(uint8_t pin)
{
short iRval;
// this is pure XMEGA code
if(pin >= A0)
{
if(pin >= (NUM_ANALOG_INPUTS + A0)) // pin number too high?
{
return 0; // not a valid analog input
}
#ifdef analogInputToAnalogPin
pin = analogInputToAnalogPin(pin);
#else // analogInputToAnalogPin
pin -= A0; // this works when PA0-PA7 and PB0-PBn are in sequence for A0-An
#endif // analogInputToAnalogPin
}
else
{
// NOTE: for pins less than 'A0', assume it's referring to the analog index (0 to NUM_ANALOG_INPUTS-1)
if(pin >= NUM_ANALOG_INPUTS)
{
return 0; // not a valid analog input
}
#ifdef analogInputToAnalogPin
pin = analogInputToAnalogPin(pin + A0); // calc pin number (might not have 0 mapped to A0)
#endif // analogInputToAnalogPin
}
// ANALOG REFERENCE - in some cases I can map one of the analog inputs
// as an analog reference. For now, assume it's Vcc/2.
// NOTE: On the A-series processors with more than a handful of inputs,
// it is NOT possible to use 'diff input with gain' on MORE than
// A0-A7. On later processors (like D series) it _IS_ possible.
// Because of this, the 'hack' that allows rail-rail measurements
// is no longer possible on PB0-PB7. PA0-PA7 will still work.
// IF PA0 or PB0 is used as VRef (see 28.16.3 in AU manual) via 'REFCTRL'
// then you can read all 15 remaining values with whatever VRef you want.
ADCA_CH0_SCAN = 0; // disable scan
ADCA_CH0_MUXCTRL = (pin << ADC_CH_MUXPOS_gp) // sect 22.15.2 in 'D' manual, 28.17.2 in 'A' manual, 24.15.2 in 'E' manual
| muxctrl_muxneg; // typically, GND is the 'other input' (change via 'analogReference()')
ADCA_CH0_INTCTRL = 0; // no interrupts, flag on complete sect 22.15.3
#ifdef ADC_CH_IF_bm /* iox16e5.h and iox32e5.h - probably the ATMel Studio version */
ADCA_CH0_INTFLAGS = ADC_CH_IF_bm; // write a 1 to the interrupt bit (which clears it - 22.15.4)
#else // everyone else
ADCA_CH0_INTFLAGS = ADC_CH_CHIF_bm; // write a 1 to the interrupt bit (which clears it - 22.15.4)
#endif // ADC_CH_IF_bm
// NOTE: this will clear any re-assigned gain bits, etc.
// (if you want to preserve those, need to call 'analogReadDeltaWithGain()')
ADCA_CH0_CTRL = normal_adca_ch0_ctrl_bits()
| ADC_CH_START_bm; // conversion start (bit will clear itself I think)
#ifdef ADC_CH_IF_bm /* iox16e5.h and iox32e5.h - probably the ATMel Studio version */
while(!(ADCA_CH0_INTFLAGS & ADC_CH_IF_bm)) { }
#else // everyone else
while(!(ADCA_CH0_INTFLAGS & ADC_CH_CHIF_bm)) { }
#endif // ADC_CH_IF_bm
iRval = ADCA_CH0_RES;
if(iRval < 0) // backward compatibility
{
return 0;
}
return iRval / 2; // -1023 to 1023 but clipped at zero (so 0 to 1023 only)
}
// THIS function returns a full 12-bit signed integer value (no scaling)
int analogReadDeltaWithGain(uint8_t pin, uint8_t negpin, uint8_t gain)
{
short iRval;
uint8_t mode;
// this is pure XMEGA code
// NOTE: On the A-series processors with more than a handful of inputs,
// it is NOT possible to use 'diff input with gain' on MORE than
// A0-A7. On later processors (like D series) it _IS_ possible.
// TODO: check for A0-A7 for 'pin' for A series?
if(pin >= A0)
{
if(pin >= (NUM_ANALOG_INPUTS + A0)) // pin number too high?
{
return 0; // not a valid analog input
}
#ifdef analogInputToAnalogPin
pin = analogInputToAnalogPin(pin);
#else // analogInputToAnalogPin
pin -= A0; // this works when PA0-PA7 and PB0-PBn are in sequence for A0-An
#endif // analogInputToAnalogPin
}
else
{
// NOTE: for pins less than 'A0', assume it's referring to the analog index (0 to NUM_ANALOG_INPUTS-1)
if(pin >= NUM_ANALOG_INPUTS)
{
return 0; // not a valid analog input
}
#ifdef analogInputToAnalogPin
pin = analogInputToAnalogPin(pin + A0); // calc pin number (might not have 0 mapped to A0)
#endif // analogInputToAnalogPin
}
#if defined (__AVR_ATxmega8E5__) || defined (__AVR_ATxmega16E5__) || defined (__AVR_ATxmega32E5__)
// NOTE: the E5 has a significant difference in how it handles 'DIFF WITH GAIN'
// ADC_CH_INPUTMODE_DIFFWGAINL_gc uses A0-A3, GND, and internal GND (not same as D and earlier)
// ADC_CH_INPUTMODE_DIFFWGAINH_gc uses A4-A7 and GND (see E manual table 24-16,17 pg 366-7) (similar to D and earlier)
if(negpin != ANALOG_READ_DELTA_USE_GND)
{
if(negpin >= A0)
{
#ifdef analogInputToAnalogPin
negpin = analogInputToAnalogPin(negpin);
#else // analogInputToAnalogPin
negpin -= A0; // this works when PA0-PA7 and PB0-PBn are in sequence for A0-An
#endif // analogInputToAnalogPin
}
else
{
if(negpin >= NUM_ANALOG_INPUTS)
{
return 0; // not a valid analog input
}
#ifdef analogInputToAnalogPin
negpin = analogInputToAnalogPin(negpin + A0); // calc pin number (might not have 0 mapped to A0)
#endif // analogInputToAnalogPin
}
if(negpin >= 0 && negpin <= 3)
{
mode = ADC_CH_INPUTMODE_DIFFWGAINL_gc;
}
else if(negpin > 7)
{
return 0; // dis-allowed combination
}
else
{
mode = ADC_CH_INPUTMODE_DIFFWGAINH_gc;
negpin -= 4; // so that it's 0-3
}
}
else
{
mode = ADC_CH_INPUTMODE_DIFFWGAINL_gc; // see 24.15.2 section on 'MUXNEG' when using INTERNAL GND or PAD GND
}
#else // NOT an 'E5'
mode = ADC_CH_INPUTMODE_DIFFWGAIN_gc;
// now for the negative pin, which will depend on a number of things
if(negpin != ANALOG_READ_DELTA_USE_GND)
{
if(negpin >= A0)
{
#ifdef analogInputToAnalogPin
negpin = analogInputToAnalogPin(negpin);
#else // analogInputToAnalogPin
negpin -= A0; // this works when PA0-PA7 and PB0-PBn are in sequence for A0-An
#endif // analogInputToAnalogPin
}
else
{
if(negpin >= NUM_ANALOG_INPUTS)
{
return 0; // not a valid analog input
}
#ifdef analogInputToAnalogPin
negpin = analogInputToAnalogPin(negpin + A0); // calc pin number (might not have 0 mapped to A0)
#endif // analogInputToAnalogPin
}
if(negpin >= 0 && negpin <= 3 && gain != ADC_CH_GAIN_1X_gc) // allow this *IF* gain is 1X
{
return 0; // dis-allowed combination
}
else if(negpin >= 0 && negpin <= 3)
{
mode = ADC_CH_INPUTMODE_DIFF_gc; // just 'diff' mode, with 1X gain, for A0 to A3
}
else if(negpin > 7)
{
return 0; // dis-allowed combination
}
else
{
negpin -= 4; // so that it's 0-3
}
}
#endif // 'E' series, or not
ADCA_CH0_SCAN = 0; // disable scan
// NOTE: assume 'CONVMODE' (CTRLB) is set to 'Signed'
if(negpin == ANALOG_READ_DELTA_USE_GND)
{
#if defined (__AVR_ATxmega8E5__) || (__AVR_ATxmega16E5__) || defined (__AVR_ATxmega32E5__)
ADCA_CH0_MUXCTRL = (pin << ADC_CH_MUXPOS_gp) // sect 22.15.2 in 'D' manual, 28.17.2 in 'A' manual, 24.15.2 in 'E' manual
| 7; /* bits 111 which is GND for MUXNEG - see E manual 24.15.2 */
#else // everything NOT an 'E' series
if(mode == ADC_CH_INPUTMODE_DIFFWGAIN_gc)
{
ADCA_CH0_MUXCTRL = (pin << ADC_CH_MUXPOS_gp) // sect 22.15.2 in 'D' manual, 28.17.2 in 'A' manual, 24.15.2 in 'E' manual
| 7; /* bits 111 which is GND for MUXNEG - see D manual 22.15.2, A manual 28.17.2 */
}
else
{
ADCA_CH0_MUXCTRL = (pin << ADC_CH_MUXPOS_gp) // sect 22.15.2 in 'D' manual, 28.17.2 in 'A' manual, 24.15.2 in 'E' manual
| 5; /* bits 101 which is GND for MUXNEG - see D manual 22.15.2, A manual 28.17.2 */
}
#endif // E series or not
}
else
{
ADCA_CH0_MUXCTRL = (pin << ADC_CH_MUXPOS_gp) // sect 22.15.2 in 'D' manual, 28.17.2 in 'A' manual, 24.15.2 in 'E' manual
| negpin; // DIFF or 'DIFF WITH GAIN' uses this
}
ADCA_CH0_INTCTRL = 0; // no interrupts, flag on complete sect 22.15.3
#ifdef ADC_CH_IF_bm /* iox16e5.h and iox32e5.h - probably the ATMel Studio version */
ADCA_CH0_INTFLAGS = ADC_CH_IF_bm; // write a 1 to the interrupt bit (which clears it - 22.15.4)
#else // everyone else
ADCA_CH0_INTFLAGS = ADC_CH_CHIF_bm; // write a 1 to the interrupt bit (which clears it - 22.15.4)
#endif // ADC_CH_IF_bm
if(negpin == ANALOG_READ_DELTA_USE_GND)
{
// NOTE: On the A-series processors with more than a handful of inputs,
// it is NOT possible to use 'diff input with gain' on MORE than
// A0-A7. On later processors (like D series) it _IS_ possible.
ADCA_CH0_CTRL = mode // ADC_CH_INPUTMODE_DIFFWGAIN_gc
| (gain & ADC_CH_GAIN_gm)
| ADC_CH_START_bm; // conversion start (bit will clear itself I think)
}
else
{
ADCA_CH0_CTRL = mode // ADC_CH_INPUTMODE_DIFFWGAIN_gc
| (gain & ADC_CH_GAIN_gm)
| ADC_CH_START_bm; // conversion start (bit will clear itself I think)
}
#ifdef ADC_CH_IF_bm /* iox16e5.h and iox32e5.h - probably the ATMel Studio version */
while(!(ADCA_CH0_INTFLAGS & ADC_CH_IF_bm)) { }
#else // everyone else
while(!(ADCA_CH0_INTFLAGS & ADC_CH_CHIF_bm)) { }
#endif // ADC_CH_IF_bm
iRval = ADCA_CH0_RES;
// TODO: scaling and clipping if needed, else +/- 2047
return iRval;
}
// Right now, PWM output only works on the pins with hardware support.
// These are defined in the appropriate pins_arduino.h file. For the
// rest of the pins, we default to digital output with a 1 or 0
#ifdef TCC4
static void DoAnalogWriteForPort(TC4_t *port, uint8_t bit, uint8_t val);
#elif defined(TCC2)
static void DoAnalogWriteForPort(TC2_t *port, uint8_t bit, uint8_t val);
#else // TCC0
static void DoAnalogWriteForPort(TC0_t *port, uint8_t bit, uint8_t val);
#endif // TCC4, TCC2, TCC0
// NOTE: for the xxE5, only 3, 4, 8, 9 seem to work properly with the default configuration
// that would be PORTD pins 4 and 5, and PORTC pins 2 and 3. PORTC pins 0 and 1
// are mapped to the TWI pins SDA and SCL. As such, PORTD pins 4 and 5, and PORTC pins 0-3
// will be allowed. Others will not. PORTD pins 6 and 7 are 'erratic' at best.
void analogWrite(uint8_t pin, int val)
{
// We need to make sure the PWM output is enabled for those pins
// that support it, as we turn it off when digitally reading or
// writing with them. Also, make sure the pin is in output mode
// for consistenty with Wiring, which doesn't require a pinMode
// call for the analog output pins.
// NOTE: period registers all contain zeros, which is the MAXIMUM period of 0-255
#ifdef TCC4 /* 'E' series and later that have TCC4 */
uint8_t mode;
#endif // TCC4
uint8_t bit = digitalPinToBitMask(pin);
pinMode(pin, OUTPUT); // forces 'totem pole' - TODO allow for something different?
// note 'val' is a SIGNED INTEGER. deal with 'out of range' values accordingly
if (val <= 0)
{
digitalWrite(pin, LOW);
}
else if (val >= 255)
{
digitalWrite(pin, HIGH);
}
else
{
// NOTE: according to the docs, 16-bit registers MUST be accessed
// low byte first, then high byte, before the actual value
// is transferred to the register. THIS code will.
// see A1U manual sect. 3.11 (and others as well)
switch(digitalPinToTimer(pin))
{
#ifdef TCC4 /* 'E' series and later that have TCC4 */
case TIMERC4:
#ifdef DEBUG_CODE
DebugOutP(PSTR("TIMERC4 "));
DebugOutL(bit);
DebugOutP(PSTR(","));
DebugOutL(val);
DebugOutP(PSTR("\r\n"));
#endif // DEBUG_CODE
DoAnalogWriteForPort(&TCC4, bit, val); // TODO: smaller if inlined here?
break;
case TIMERD5:
// THIS code is unique to the E5, most likely, so it's inlined
if(bit == 1 || bit == 16) // TODO: either bit? not sure if I can re-map these to 0-3
{
*((volatile uint16_t *)&(TCD5_CCA)) = (TCD5_CCA & 0xff00) | (val & 0xff);
mode = (TCD5_CTRLE & ~TC5_LCCAMODE_gm) | TC5_LCCAMODE0_bm;
}
else if(bit == 2 || bit == 32)
{
*((volatile uint16_t *)&(TCD5_CCB)) = (TCD5_CCB & 0xff00) | (val & 0xff);
mode = (TCD5_CTRLE & ~TC5_LCCBMODE_gm) | TC5_LCCBMODE0_bm;
}
else if(bit == 4 || bit == 64)
{
*((volatile uint16_t *)&(TCD5_CCA)) = (TCD5_CCA & 0xff) | ((val << 8) & 0xff00);
mode = (TCD5_CTRLF & ~TC5_HCCAMODE_gm) | TC5_HCCAMODE0_bm;
}
else if(bit == 8 || bit == 128)
{
*((volatile uint16_t *)&(TCD5_CCB)) = (TCD5_CCB & 0xff) | ((val << 8) & 0xff00);
mode = (TCD5_CTRLF & ~TC5_HCCBMODE_gm) | TC5_HCCBMODE0_bm;
}
else
{
break;
}
#ifdef DEBUG_CODE
DebugOutP(PSTR("TIMERD5 "));
DebugOutL(bit);
DebugOutP(PSTR(","));
DebugOutL(val);
DebugOutP(PSTR(","));
DebugOutL(TCD5_CCA);
DebugOutP(PSTR(","));
DebugOutL(TCD5_CCB);
DebugOutP(PSTR(","));
DebugOutL(mode);
DebugOutP(PSTR("\r\n"));
#endif // DEBUG_CODE
if(bit == 1 || bit == 2 || bit == 16 || bit == 32)
{
*((volatile uint8_t *)&(TCD5_CTRLE)) = mode;
#ifdef DEBUG_CODE
DebugOutP(PSTR("E!\r\n"));
#endif // DEBUG_CODE
}
else
{
*((volatile uint8_t *)&(TCD5_CTRLF)) = mode;
#ifdef DEBUG_CODE
DebugOutP(PSTR("F!\r\n"));
#endif // DEBUG_CODE
}
break;
#else // everything else NOT an 'E' series
case TIMERD2:
#ifndef TCD2
DoAnalogWriteForPort(&TCD0, bit, val);
#else // TCD2 defined
DoAnalogWriteForPort(&TCD2, bit, val);
#endif // TCD2 defined
break;
case TIMERC2:
#ifndef TCC2
DoAnalogWriteForPort(&TCC0, bit, val);
#else // TCC2 defined
DoAnalogWriteForPort(&TCC2, bit, val);
#endif // TCC2 defined
break;
#if NUM_DIGITAL_PINS > 22 /* meaning there is a PORT E available with 8 pins */
case TIMERE2: // TIMER 'E2' for 8-bits
#ifndef TCE2
DoAnalogWriteForPort(&TCE0, bit, val);
#else // TCE2 defined
DoAnalogWriteForPort(&TCE2, bit, val);
#endif // TCE2 defined
break;
#if NUM_DIGITAL_PINS > 30 /* meaning there is a PORT F available */
case TIMERF2:
#ifndef TCF2
DoAnalogWriteForPort(&TCF0, bit, val);
#else // TCF2 defined
DoAnalogWriteForPort(&TCF2, bit, val);
#endif // TCF2 defined
break;
#endif // NUM_DIGITAL_PINS > 30
#elif NUM_DIGITAL_PINS > 18 /* meaning there is a PORT E available but with only 4 pins */
case TIMERE0:
// timer E0 counts UP, but a value of 0 would still generate a '0' output because
// the output STARTS at a 1, and flips to 0 when the CTR reaches the CC register
// Similarly, a value of 255 would generate a '1'. see section 12.8.3 in the 'D' manual
if(bit == 1)
{
TCE0_CCA = val; // NOTE: these are 16-bit registers (but I'm in 8-bit mode so it's fine)
}
else if(bit == 2)
{
TCE0_CCB = val;
}
else if(bit == 4)
{
TCE0_CCC = val;
}
else if(bit == 8)
{
TCE0_CCD = val;
}
// this is a reminder that the low nybble should be assigned the correct value for single-slope PWM mode
// TCE0_CTRLB = TC_WGMODE_SS_gc; // single-slope PWM. NOTE: this counts UP, whereas the other timers count DOWN
TCE0_CTRLB |= (bit << 4); // enables output (0-3 only, but that's all PORT E has anyway)
// note that the 'enable' bits are in CTRLB and in upper nybble
break;
#endif // NUM_DIGITAL_PINS >= 18, 24
#endif // TCC4 check
case NOT_ON_TIMER:
default:
if (val < 128)
{
digitalWrite(pin, LOW);
}
else
{
digitalWrite(pin, HIGH);
}
}
}
}
#ifdef TCC4
void DoAnalogWriteForPort(TC4_t *port, uint8_t bit, uint8_t val)
{
uint8_t modeE, modeF;
modeE = port->CTRLE;
modeF = port->CTRLF;
if(bit == 1)
{
port->CCA = (port->CCA & 0xff00) | (val & 0xff);
modeE = (modeE & ~TC4_LCCAMODE_gm) | TC45_LCCAMODE_COMP_gc;
}
else if(bit == 2)
{
port->CCB = (port->CCB & 0xff00) | (val & 0xff);
modeE = (modeE & ~TC4_LCCBMODE_gm) | TC45_LCCBMODE_COMP_gc;
}
else if(bit == 4)
{
port->CCC = (port->CCC & 0xff00) | (val & 0xff);
modeE = (modeE & ~TC4_LCCCMODE_gm) | TC45_LCCCMODE_COMP_gc;
}
else if(bit == 8)
{
port->CCD = (port->CCD & 0xff00) | (val & 0xff);
modeE = (modeE & ~TC4_LCCDMODE_gm) | TC45_LCCDMODE_COMP_gc;
}
else if(bit == 16)
{
port->CCA = (port->CCA & 0xff) | ((val << 8) & 0xff00);
modeF = (modeF & ~TC4_HCCAMODE_gm) | TC45_HCCAMODE_COMP_gc;
}
else if(bit == 32)
{
port->CCB = (port->CCB & 0xff) | ((val << 8) & 0xff00);
modeF = (modeF & ~TC4_HCCBMODE_gm) | TC45_HCCBMODE_COMP_gc;
}
else if(bit == 64)
{
port->CCC = (port->CCC & 0xff) | ((val << 8) & 0xff00);
modeF = (modeF & ~TC4_HCCCMODE_gm) | TC45_HCCCMODE_COMP_gc;
}
else if(bit == 128)
{
port->CCD = (port->CCD & 0xff) | ((val << 8) & 0xff00);
modeF = (modeF & ~TC4_HCCDMODE_gm) | TC45_HCCDMODE_COMP_gc;
}
else
{
return;
}
port->CTRLE = modeE;
port->CTRLF = modeF;
// if(bit <= 8)
// {
// port->CTRLE = mode;
// }
// else
// {
// port->CTRLF = mode;
// }
}
#elif defined(TCC2)
void DoAnalogWriteForPort(TC2_t *port, uint8_t bit, uint8_t val)
{
// NOTE: timers C2 and D2 count DOWN, always. However, the output starts at zero
// and flips to 1 when CTR reaches the CMP value. So a value of 255 would be
// '1' and 0 would be '0', as is expected. See 'D' manual 13.6.2
if(bit == 1)
{
port->LCMPA = val;
}
else if(bit == 2)
{
port->LCMPB = val;
}
else if(bit == 4)
{
port->LCMPC = val;
}
else if(bit == 8)
{
port->LCMPD = val;
}
else if(bit == 16)
{
port->HCMPA = val;
}
else if(bit == 32)
{
port->HCMPB = val;
}
else if(bit == 64)
{
port->HCMPC = val;
}
else if(bit == 128)
{
port->HCMPD = val;
}
// this is a reminder that the low nybble should be assigned the correct value for single-slope PWM mode
// port->CTRLB = TC45_WGMODE_SINGLESLOPE_gc;
port->CTRLB |= bit; // enables output
}
#else // TCC0
void DoAnalogWriteForPort(TC0_t *port, uint8_t bit, uint8_t val)
{
// NOTE: timers C2 and D2 count DOWN, always. However, the output starts at zero
// and flips to 1 when CTR reaches the CMP value. So a value of 255 would be
// '1' and 0 would be '0', as is expected. See 'D' manual 13.6.2
if(bit == 1)
{
port->CCA = (port->CCA & 0xff00) | (val & 0xff);
}
else if(bit == 2)
{
port->CCB = (port->CCB & 0xff00) | (val & 0xff);
}
else if(bit == 4)
{
port->CCC = (port->CCC & 0xff00) | (val & 0xff);
}
else if(bit == 8)
{
port->CCD = (port->CCD & 0xff00) | (val & 0xff);
}
else if(bit == 16)
{
port->CCA = (port->CCA & 0xff) | ((val << 8) & 0xff00);
}
else if(bit == 32)
{
port->CCB = (port->CCB & 0xff) | ((val << 8) & 0xff00);
}
else if(bit == 64)
{
port->CCC = (port->CCC & 0xff) | ((val << 8) & 0xff00);
}
else if(bit == 128)
{
port->CCD = (port->CCD & 0xff) | ((val << 8) & 0xff00);
}
// this is a reminder that the low nybble should be assigned the correct value for single-slope PWM mode
// port->CTRLB = TC45_WGMODE_SINGLESLOPE_gc;
port->CTRLB |= bit; // enables output
}
#endif // TCC4, TCC2, TCC0

View File

@@ -1,428 +0,0 @@
/*
wiring_digital.c - digital input and output functions
Part of Arduino - http://www.arduino.cc/
Copyright (c) 2005-2006 David A. Mellis
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
Boston, MA 02111-1307 USA
Modified 28 September 2010 by Mark Sproul
Updated for 'xmega' core by bob frazier, S.F.T. Inc. - http://mrp3.com/
In some cases, the xmega updates make assumptions about the pin assignments.
See 'pins_arduino.h' for more detail.
*/
#define ARDUINO_MAIN
#include "wiring_private.h"
#include "pins_arduino.h"
void pinMode(uint8_t pin, uint8_t mode)
{
uint8_t bit = digitalPinToBitMask(pin);
uint8_t port = digitalPinToPort(pin);
uint8_t sense = mode & INPUT_SENSE_MASK;
uint8_t invert = mode & INPUT_OUTPUT_INVERT;
volatile uint8_t *reg, /* *out,*/ *ctrl;
mode &= INPUT_OUTPUT_MASK; // remove 'sense' bits
if (port == NOT_A_PIN)
{
return;
}
reg = portModeRegister(port); // D manual section 11.12.1
if(sense == INPUT_SENSE_DISABLED && reg != &PORTR_DIR) // 'DISABLED'
{
sense = PORT_ISC_INPUT_DISABLE_gc; // bit values for 'INTPUT_DISABLED' (sic)
}
else if(sense == INPUT_SENSE_RISING)
{
sense = PORT_ISC_RISING_gc; // rising
}
else if(sense == INPUT_SENSE_FALLING)
{
sense = PORT_ISC_FALLING_gc; // falling
}
else if(sense == INPUT_SENSE_LEVEL)
{
sense = PORT_ISC_LEVEL_gc; // LOW level (except events, which use HIGH level)
}
else // if(sense == INPUT_SENSE_BOTH) all others including 'DEFAULT'
{
sense = PORT_ISC_BOTHEDGES_gc; // 'both rising and falling'
}
if(invert) // inverted bit value
{
sense |= _BV(PORT_INVEN_bp); // see 11.12.15 in D manual - 'invert' bit
}
// JWS: can I let the optimizer do this?
// reg = portModeRegister(port); // D manual section 11.12.1 (MOVED upwards, BBB)
// out = portOutputRegister(port); // D manual section 11.12.5 (not used - BBB)
ctrl = pinControlRegister(pin); // D manual section 11.12.15
uint8_t oldSREG = SREG;
cli(); // clear interrupt flag until I'm done assigning pin stuff
if (mode == INPUT)
{
*ctrl = sense | PORT_OPC_TOTEM_gc;
*reg &= ~bit;
}
else if (mode == INPUT_PULLUP)
{
*ctrl = sense | PORT_OPC_PULLUP_gc; // input pullup
*reg &= ~bit;
}
else if (mode == INPUT_AND_PULLUP)
{
*ctrl = sense | PORT_OPC_WIREDANDPULL_gc; // wired 'and' (open drain) with pullup
*reg &= ~bit;
}
else if (mode == INPUT_PULLDOWN)
{
*ctrl = sense | PORT_OPC_PULLDOWN_gc; // input pullDOWN
*reg &= ~bit;
}
else if (mode == INPUT_OR_PULLDOWN)
{
*ctrl = sense | PORT_OPC_WIREDORPULL_gc; // wired 'or' (open drain) with pulldown
*reg &= ~bit;
}
else if (mode == INPUT_BUS_KEEPER)
{
*ctrl = sense | PORT_OPC_BUSKEEPER_gc; // bus keeper
*reg &= ~bit;
}
else if (mode == OUTPUT_OR)
{
*ctrl = sense | PORT_OPC_WIREDOR_gc; // wired 'or' (open drain)
*reg |= bit;
}
else if (mode == OUTPUT_AND)
{
*ctrl = sense | PORT_OPC_WIREDAND_gc; // wired 'and' (open drain)
*reg |= bit;
}
else if (mode == OUTPUT_OR_PULLDOWN)
{
*ctrl = sense | PORT_OPC_WIREDORPULL_gc; // wired 'or' (open drain) with pulldown
*reg |= bit;
}
else if (mode == OUTPUT_AND_PULLUP)
{
*ctrl = sense | PORT_OPC_WIREDANDPULL_gc; // wired 'and' (open drain) with pullup
*reg |= bit;
}
else // if(mode == OUTPUT) assume OUTPUT without open drain and/or nor pullup/down
{
*ctrl = sense | PORT_OPC_TOTEM_gc; // 'totem pole' (the default)
*reg |= bit;
}
SREG = oldSREG;
}
// Forcing this inline keeps the callers from having to push their own stuff
// on the stack. It is a good performance win and only takes 1 more byte per
// user than calling. (It will take more bytes on the 168.)
//
// But shouldn't this be moved into pinMode? Seems silly to check and do on
// each digitalread or write.
//
// Mark Sproul:
// - Removed inline. Save 170 bytes on atmega1280
// - changed to a switch statment; added 32 bytes but much easier to read and maintain.
// - Added more #ifdefs, now compiles for atmega645
//
//static inline void turnOffPWM(uint8_t timer) __attribute__ ((always_inline));
//static inline void turnOffPWM(uint8_t timer)
// BBB - added 'bit' parameter for xmega - it's a bit MASK, not a bit number
// use the result from digitalPinToBitMask(pin) for 'bit'
static void turnOffPWM(uint8_t timer, uint8_t bit)
{
#ifdef TCC4 /* 'E' series and later that have TCC4 */
register uint8_t mode;
#endif // TCC4
switch (timer)
{
#ifdef TCC4 /* 'E' series and later that have TCC4 */
case TIMERC4:
if(bit == 1)
{
mode = (TCC4_CTRLE & ~TC4_LCCAMODE_gm);
}
else if(bit == 2)
{
mode = (TCC4_CTRLE & ~TC4_LCCBMODE_gm);
}
else if(bit == 4)
{
mode = (TCC4_CTRLE & ~TC4_LCCCMODE_gm);
}
else if(bit == 8)
{
mode = (TCC4_CTRLE & ~TC4_LCCDMODE_gm);
}
else if(bit == 16)
{
mode = (TCC4_CTRLF & ~TC4_HCCAMODE_gm);
}
else if(bit == 32)
{
mode = (TCC4_CTRLF & ~TC4_HCCBMODE_gm);
}
else if(bit == 64)
{
mode = (TCC4_CTRLF & ~TC4_HCCCMODE_gm);
}
else if(bit == 128)
{
mode = (TCC4_CTRLF & ~TC4_HCCDMODE_gm);
}
else
{
break;
}
if(bit <= 8)
{
TCC4_CTRLE = mode;
}
else
{
TCC4_CTRLF = mode;
}
break;
case TIMERD5:
if(bit == 1 || bit == 16)
{
mode = (TCD5_CTRLE & ~TC5_LCCAMODE_gm);
}
else if(bit == 2 || bit == 32)
{
mode = (TCD5_CTRLE & ~TC5_LCCBMODE_gm);
}
else if(bit == 4 || bit == 64)
{
mode = (TCD5_CTRLF & ~TC5_HCCAMODE_gm);
}
else if(bit == 8 || bit == 128)
{
mode = (TCD5_CTRLF & ~TC5_HCCBMODE_gm);
}
else
{
break;
}
// TODO: check to see if it was enabled AND the bit was configured properly for PWM
// AND was properly mapped (L vs H, REMAP register?)
if(bit == 1 || bit == 2 || bit == 16 || bit == 32)
{
TCD5_CTRLE = mode;
}
else
{
TCD5_CTRLF = mode;
}
break;
#else // everything else NOT an 'E' series
#ifndef TCC2 /* A1 series does not define this and I need TC0 */
case TIMERD2:
TCD0_CTRLB &= ~bit; // DISables PWM output
break;
case TIMERC2:
TCC0_CTRLB &= ~bit; // DISables PWM output
break;
#if NUM_DIGITAL_PINS > 22 /* which means we have PORT E but with 8 pins, not 4 */
case TIMERE2:
TCE0_CTRLB &= ~bit; // DISables PWM output
break;
#if NUM_DIGITAL_PINS > 30 /* which means we have PORT F */
case TIMERF2:
TCF0_CTRLB &= ~bit; // DISables PWM output
break;
#endif // NUM_DIGITAL_PINS > 30
#elif NUM_DIGITAL_PINS > 18 /* which means we have PORT E but only with 4 pins */
case TIMERE0:
TCE0_CTRLB &= ~(bit << 4); // DISables PWM output
// note that the 'enable' bits are in CTRLB and in upper nybble
break;
#endif // NUM_DIGITAL_PINS > 18, 22
#else // TCC2
case TIMERD2:
TCD2_CTRLB &= ~bit; // DISables PWM output
break;
case TIMERC2:
TCC2_CTRLB &= ~bit; // DISables PWM output
break;
#if NUM_DIGITAL_PINS > 22 /* which means we have PORT E but with 8 pins, not 4 */
case TIMERE2:
TCE2_CTRLB &= ~bit; // DISables PWM output
break;
#if NUM_DIGITAL_PINS > 30 /* which means we have PORT F */
case TIMERF2:
TCF2_CTRLB &= ~bit; // DISables PWM output
break;
#endif // NUM_DIGITAL_PINS > 30
#elif NUM_DIGITAL_PINS > 18 /* which means we have PORT E but only with 4 pins */
// TODO: 64d4 has 4 pins on PORT E. 128A1 has 8 pins on PORT E. determine which to use?
case TIMERE0:
TCE0_CTRLB &= ~(bit << 4); // DISables PWM output
// note that the 'enable' bits are in CTRLB and in upper nybble
break;
#endif // NUM_DIGITAL_PINS > 18, 22
#endif // TCC2
#endif // TCC4
}
}
void digitalWrite(uint8_t pin, uint8_t val)
{
uint8_t timer = digitalPinToTimer(pin);
uint8_t bit = digitalPinToBitMask(pin);
uint8_t port = digitalPinToPort(pin);
volatile uint8_t *out, *ctrl;
if (port == NOT_A_PIN)
{
return;
}
ctrl = pinControlRegister(pin); // D manual section 11.12.15
if(*ctrl & _BV(PORT_INVEN_bp)) // inverted
{
val = !val; // invert the value (so it's consistent with the pin)
}
// If the pin that support PWM output, we need to turn it off
// before doing a digital write.
// TODO: move this feature to pinMode() like it should be
// or set a flag to be used with analogWrite()
// (for now it's probably faster just to call it)
if (timer != NOT_ON_TIMER)
{
turnOffPWM(timer, bit);
}
out = portOutputRegister(port);
uint8_t oldSREG = SREG;
cli();
if (val == LOW)
{
*out &= ~bit;
}
else
{
*out |= bit;
}
SREG = oldSREG;
}
int digitalRead(uint8_t pin)
{
uint8_t timer = digitalPinToTimer(pin);
uint8_t bit = digitalPinToBitMask(pin);
uint8_t port = digitalPinToPort(pin);
volatile uint8_t *ctrl;
uint8_t bSet;
if (port == NOT_A_PIN)
{
return LOW;
}
// If the pin that support PWM output, we need to turn it off
// before getting a digital reading.
// TODO: move this feature to pinMode() like it should be
// or set a flag to be used with analogWrite()
// (for now it's probably faster just to call it)
if (timer != NOT_ON_TIMER)
{
turnOffPWM(timer, bit);
}
bSet = (*portInputRegister(port) & bit) ? true : false;
// if the 'invert' flag is on, I invert the digital value
// this is so that the result of 'digitalRead' and 'digitalWrite'
// are ALWAYS consistent with the actual pin level. Inversion is
// needed for proper interrupt control. So for the best consistency,
// the invert flag will only (really) be needed for LEVEL interrupts.
ctrl = pinControlRegister(pin); // D manual section 11.12.15
if(*ctrl & _BV(PORT_INVEN_bp)) // inverted
{
bSet = !bSet;
}
return bSet ? HIGH : LOW;
}

View File

@@ -1,125 +0,0 @@
/*
wiring_private.h - Internal header file.
Part of Arduino - http://www.arduino.cc/
Copyright (c) 2005-2006 David A. Mellis
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
Boston, MA 02111-1307 USA
$Id: wiring.h 239 2007-01-12 17:58:39Z mellis $
*/
#ifndef WiringPrivate_h
#define WiringPrivate_h
#include <avr/io.h>
#include <avr/interrupt.h>
#include <stdio.h>
#include <stdarg.h>
#include "Arduino.h"
// things that need to be defined in order for the code to compile
// definitions for ADC-related product signature row entries
#ifndef PRODSIGNATURES_ADCACAL0 /* _MOST_ headers don't define this properly - see ATMel Studio headers */
#define PRODSIGNATURES_ADCACAL0 _SFR_MEM8(0x0020)
#endif // PRODSIGNATURES_ADCACAL0
#ifndef PRODSIGNATURES_ADCACAL1 /* _MOST_ headers don't define this properly - see ATMel Studio headers */
#define PRODSIGNATURES_ADCACAL1 _SFR_MEM8(0x0021)
#endif // PRODSIGNATURES_ADCACAL1
#ifndef PRODSIGNATURES_ADCBCAL0 /* _MOST_ headers don't define this properly - see ATMel Studio headers */
#define PRODSIGNATURES_ADCBCAL0 _SFR_MEM8(0x0024)
#endif // PRODSIGNATURES_ADCBCAL0
#ifndef PRODSIGNATURES_ADCBCAL1 /* _MOST_ headers don't define this properly - see ATMel Studio headers */
#define PRODSIGNATURES_ADCBCAL1 _SFR_MEM8(0x0025)
#endif // PRODSIGNATURES_ADCBCAL1
// definitions for USB-related product signature row entries
#ifndef PRODSIGNATURES_USBCAL0 /* _MOST_ headers don't define this properly - see ATMel Studio headers */
#define PRODSIGNATURES_USBCAL0 _SFR_MEM8(0x001a)
#endif // PRODSIGNATURES_USBCAL0
#ifndef PRODSIGNATURES_USBCAL1 /* _MOST_ headers don't define this properly - see ATMel Studio headers */
#define PRODSIGNATURES_USBCAL1 _SFR_MEM8(0x001b)
#endif // PRODSIGNATURES_USBCAL1
#ifndef PRODSIGNATURES_USBRCOSC /* _MOST_ headers don't define this properly - see ATMel Studio headers */
#define PRODSIGNATURES_USBRCOSC _SFR_MEM8(0x001c)
#endif // PRODSIGNATURES_USBRCOSC
#ifndef PRODSIGNATURES_USBRCOSCA /* _MOST_ headers don't define this properly - see ATMel Studio headers */
#define PRODSIGNATURES_USBRCOSCA _SFR_MEM8(0x001d)
#endif // PRODSIGNATURES_USBRCOSCA
#ifndef ADCA_CH0_SCAN /* A1 headers don't define this properly */
#define ADCA_CH0_SCAN _SFR_MEM8(0x0226)
#define ADC_REFSEL_INTVCC2_gc (0x04<<4)
#define ADC_CH_GAIN_DIV2_gc (0x07<<2)
#endif // ADCA_CH0_SCAN
#ifndef ADC_REFSEL2_bm /* A1 headers don't define this properly, but A1U headers do [and others] */
#define ADC_REFSEL2_bm (1<<6) /* Reference Selection bit 2 mask. */
#define ADC_REFSEL2_bp 6 /* Reference Selection bit 2 position. */
#endif // ADC_REFSEL2_bm
#ifndef PORT_USART0_bm
#define PORT_USART0_bm 0x10 /* Usart0 bit mask for port remap register. */
#endif // PORT_USART0_bm
#ifdef __cplusplus
extern "C"{
#endif
#ifndef cbi
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#endif
#ifndef sbi
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
#endif
// NOTE: xmega is SO different that these need to be in pins_arduino.h
// some xmegas have 2 per port, others 1 per port, and the # of ports vary greatly
//#define EXTERNAL_INT_0 0
//#define EXTERNAL_INT_1 1
//#define EXTERNAL_INT_2 2
//#define EXTERNAL_INT_3 3
//#define EXTERNAL_INT_4 4
//#define EXTERNAL_INT_5 5
//#define EXTERNAL_INT_6 6
//#define EXTERNAL_INT_7 7
// CPU-specific definitions go into the 'pins_arduino.h' files anyway
//
//#if defined(SOME_CPU)
//#define EXTERNAL_NUM_INTERRUPTS 8
//#endif
typedef void (*voidFuncPtr)(void);
#ifdef __cplusplus
} // extern "C"
#endif
#endif

View File

@@ -1,69 +0,0 @@
/*
wiring_pulse.c - pulseIn() function
Part of Arduino - http://www.arduino.cc/
Copyright (c) 2005-2006 David A. Mellis
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
Boston, MA 02111-1307 USA
$Id: wiring.c 248 2007-02-03 15:36:30Z mellis $
*/
#include "wiring_private.h"
#include "pins_arduino.h"
/* Measures the length (in microseconds) of a pulse on the pin; state is HIGH
* or LOW, the type of pulse to measure. Works on pulses from 2-3 microseconds
* to 3 minutes in length, but must be called at least a few dozen microseconds
* before the start of the pulse. */
unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout)
{
// cache the port and bit of the pin in order to speed up the
// pulse width measuring loop and achieve finer resolution. calling
// digitalRead() instead yields much coarser resolution.
uint8_t bit = digitalPinToBitMask(pin);
uint8_t port = digitalPinToPort(pin);
uint8_t stateMask = (state ? bit : 0);
unsigned long width = 0; // keep initialization out of time critical area
// convert the timeout from microseconds to a number of times through
// the initial loop; it takes 16 clock cycles per iteration.
unsigned long numloops = 0;
unsigned long maxloops = microsecondsToClockCycles(timeout) / 16;
// wait for any previous pulse to end
while ((*portInputRegister(port) & bit) == stateMask)
if (numloops++ == maxloops)
return 0;
// wait for the pulse to start
while ((*portInputRegister(port) & bit) != stateMask)
if (numloops++ == maxloops)
return 0;
// wait for the pulse to stop
while ((*portInputRegister(port) & bit) == stateMask) {
if (numloops++ == maxloops)
return 0;
width++;
}
// convert the reading to microseconds. The loop has been determined
// to be 20 clock cycles long and have about 16 clocks between the edge
// and the start of the loop. There will be some error introduced by
// the interrupt handlers.
return clockCyclesToMicroseconds(width * 21 + 16);
}

View File

@@ -1,55 +0,0 @@
/*
wiring_shift.c - shiftOut() function
Part of Arduino - http://www.arduino.cc/
Copyright (c) 2005-2006 David A. Mellis
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
Boston, MA 02111-1307 USA
$Id: wiring.c 248 2007-02-03 15:36:30Z mellis $
*/
#include "wiring_private.h"
uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder) {
uint8_t value = 0;
uint8_t i;
for (i = 0; i < 8; ++i) {
digitalWrite(clockPin, HIGH);
if (bitOrder == LSBFIRST)
value |= digitalRead(dataPin) << i;
else
value |= digitalRead(dataPin) << (7 - i);
digitalWrite(clockPin, LOW);
}
return value;
}
void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val)
{
uint8_t i;
for (i = 0; i < 8; i++) {
if (bitOrder == LSBFIRST)
digitalWrite(dataPin, !!(val & (1 << i)));
else
digitalWrite(dataPin, !!(val & (1 << (7 - i))));
digitalWrite(clockPin, HIGH);
digitalWrite(clockPin, LOW);
}
}

View File

@@ -1,8 +0,0 @@
## Override some platform.txt settings to create a .bin instead of a .hex file
## The two lines below can be uncommented to have the compiler create a .bin file instead of a .hex file
#compiler.elf2hex.flags=-O binary -R .eeprom
#recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin"
## Make a .bin version of the .hex file
## The line below can be uncommented to have a .bin file made as well as the .hex file
#recipe.hooks.objcopy.postobjcopy.00.pattern.windows="{compiler.path}{compiler.objcopy.cmd}" -I ihex "{build.path}/{build.project_name}.hex" -O binary "{build.path}/{build.project_name}.bin"

View File

@@ -1,139 +0,0 @@
#
# Customized for the Atmega328p and OrangeRX (XMEGA) multi 4-in-1 boards.
# Both are AVR boards but need different compiler and upload flags and parameters.
#
# For more info:
# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification
name=Multi 4-in-1 AVR
version=1.0.2
compiler.warning_flags=-w
compiler.warning_flags.none=-w
compiler.warning_flags.default=
compiler.warning_flags.more=-Wall
compiler.warning_flags.all=-Wall -Wextra
# Default "compiler.path" is correct, change only if you want to override the initial value
compiler.path={runtime.tools.avr-gcc.path}/bin/
compiler.c.cmd=avr-gcc
compiler.c.flags={board.compiler.c.flags}
compiler.c.elf.flags={compiler.warning_flags} {board.compiler.c.elf.flags}
compiler.c.elf.cmd=avr-gcc
compiler.S.flags={board.compiler.S.flags}
compiler.cpp.cmd=avr-g++
compiler.cpp.flags=-c -g -Os {compiler.warning_flags} -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -flto
compiler.ar.cmd=avr-gcc-ar
compiler.ar.flags=rcs
compiler.objcopy.cmd=avr-objcopy
compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0
compiler.elf2hex.flags=-O ihex -R .eeprom
compiler.elf2hex.cmd=avr-objcopy
compiler.ldflags=
compiler.size.cmd=avr-size
# This can be overridden in boards.txt
build.extra_flags=
# These can be overridden in platform.local.txt
compiler.c.extra_flags=
compiler.c.elf.extra_flags=
compiler.S.extra_flags=
compiler.cpp.extra_flags=
compiler.ar.extra_flags=
compiler.objcopy.eep.extra_flags=
compiler.elf2hex.extra_flags=
# AVR compile patterns
# --------------------
## Compile c files
recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"
## Compile c++ files
recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"
## Compile S files
recipe.S.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.S.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"
## Create archives
# archive_file_path is needed for backwards compatibility with IDE 1.6.5 or older, IDE 1.6.6 or newer overrides this value
archive_file_path={build.path}/{archive_file}
recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}"
## Combine gc-sections, archives, and objects
recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {compiler.c.elf.flags} -mmcu={build.mcu} {compiler.c.elf.extra_flags} -o "{build.path}/{build.project_name}.elf" {object_files} "{build.path}/{archive_file}" "-L{build.path}" -lm
## Create output files (.eep and .hex)
recipe.objcopy.eep.pattern="{compiler.path}{compiler.objcopy.cmd}" {compiler.objcopy.eep.flags} {compiler.objcopy.eep.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.eep"
recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex"
## Save hex
recipe.output.tmp_file={build.project_name}.hex
recipe.output.save_file={board.recipe.output.save_file}
## Compute size
recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf"
recipe.size.regex=^(?:\.text|\.data|\.bootloader)\s+([0-9]+).*
recipe.size.regex.data=^(?:\.data|\.bss|\.noinit)\s+([0-9]+).*
recipe.size.regex.eeprom=^(?:\.eeprom)\s+([0-9]+).*
## Preprocessor
preproc.includes.flags=-w -x c++ -M -MG -MP
recipe.preproc.includes="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} {preproc.includes.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {includes} "{source_file}"
preproc.macros.flags=-w -x c++ -E -CC
recipe.preproc.macros="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} {preproc.macros.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{preprocessed_file_path}"
## Post objcopy recipes
# Make a copy of the compiled binary with the version number in the file name
recipe.hooks.objcopy.postobjcopy.01.pattern.windows="{runtime.platform.path}/tools/win/do_version.bat" "{build.path}" "{build.project_name}" "{build.source.path}" {build.board}
recipe.hooks.objcopy.postobjcopy.01.pattern.linux="{runtime.platform.path}/tools/linux/do_version" "{build.path}" "{build.project_name}" "{build.source.path}" {build.board}
recipe.hooks.objcopy.postobjcopy.01.pattern.linux64="{runtime.platform.path}/tools/linux64/do_version" "{build.path}" "{build.project_name}" "{build.source.path}" {build.board}
recipe.hooks.objcopy.postobjcopy.01.pattern.macosx="{runtime.platform.path}/tools/macosx/do_version" "{build.path}" "{build.project_name}" "{build.source.path}" {build.board}
## Post savehex (export compiled binary) recipes
# If we're exporting the hex file, rename it with the version number
recipe.hooks.savehex.postsavehex.01.pattern.windows="{runtime.platform.path}/tools/win/do_version.bat" "{build.path}" "{build.project_name}" "{build.source.path}" {build.board} EXPORT
recipe.hooks.savehex.postsavehex.01.pattern.linux="{runtime.platform.path}/tools/linux/do_version" "{build.path}" "{build.project_name}" "{build.source.path}" {build.board} EXPORT
recipe.hooks.savehex.postsavehex.01.pattern.linux64="{runtime.platform.path}/tools/linux64/do_version" "{build.path}" "{build.project_name}" "{build.source.path}" {build.board} EXPORT
recipe.hooks.savehex.postsavehex.01.pattern.macosx="{runtime.platform.path}/tools/macosx/do_version" "{build.path}" "{build.project_name}" "{build.source.path}" {build.board} EXPORT
# AVR Uploader/Programmers tools
# ------------------------------
tools.avrdude.path={runtime.tools.avrdude.path}
tools.avrdude.cmd.path={path}/bin/avrdude
tools.avrdude.config.path={board.tools.avrdude.config.path}
tools.avrdude.upload.params.verbose=-v
tools.avrdude.upload.params.quiet=-q -q
# tools.avrdude.upload.verify is needed for backwards compatibility with IDE 1.6.8 or older, IDE 1.6.9 or newer overrides this value
tools.avrdude.upload.verify=
tools.avrdude.upload.params.noverify=-V
tools.avrdude.upload.pattern="{cmd.path}" "-C{config.path}" {upload.verbose} {upload.verify} -p{build.mcu} -c{upload.protocol} "-P{serial.port}" -b{upload.speed} -D "-Uflash:w:{build.path}/{build.project_name}.hex:i"
tools.avrdude.program.params.verbose=-v
tools.avrdude.program.params.quiet=-q -q
# tools.avrdude.program.verify is needed for backwards compatibility with IDE 1.6.8 or older, IDE 1.6.9 or newer overrides this value
tools.avrdude.program.verify=
tools.avrdude.program.params.noverify=-V
tools.avrdude.program.pattern="{cmd.path}" "-C{config.path}" {program.verbose} {program.verify} -p{build.mcu} -c{protocol} {program.extra_params} "-Uflash:w:{build.path}/{build.project_name}.hex:i"
tools.avrdude.erase.params.verbose=-v
tools.avrdude.erase.params.quiet=-q -q
tools.avrdude.erase.pattern={board.tools.avrdude.erase.pattern}
tools.avrdude.bootloader.params.verbose=-v
tools.avrdude.bootloader.params.quiet=-q -q
tools.avrdude.bootloader.pattern={board.tools.avrdude.bootloader.pattern}
tools.avrdude_remote.upload.pattern=/usr/bin/run-avrdude /tmp/sketch.hex {upload.verbose} -p{build.mcu}
# USB Default Flags
# Default blank usb manufacturer will be filled in at compile time
# - from numeric vendor ID, set to Unknown otherwise
build.usb_manufacturer="Unknown"
build.usb_flags=-DUSB_VID={build.vid} -DUSB_PID={build.pid} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}'

View File

@@ -1,71 +0,0 @@
#!/bin/bash
BUILD_PATH=$1
PROJECT_NAME=$2
SKETCH_PATH=$3
MULTI_BOARD=$4
EXPORT_FLAG=$5
IFS== read MULTI_BOARD BOARD_VERSION <<< "$MULTI_BOARD"
case "$MULTI_BOARD" in
MULTI_NO_BOOT)
MULTI_TYPE=avr
;;
MULTI_FLASH_FROM_TX)
MULTI_TYPE=avr
;;
MULTI_STM32_NO_BOOT)
MULTI_TYPE=stm
;;
MULTI_STM32_FLASH_FROM_TX)
MULTI_TYPE=stm
;;
MULTI_ORANGERX)
MULTI_TYPE=orx
;;
esac
#echo "Build Path: $BUILD_PATH"
#echo "Sketch Path: $SKETCH_PATH"
#echo "Project Name: $PROJECT_NAME"
#echo "Multi Board: $MULTI_BOARD"
#echo "Multi Board Type: $MULTI_TYPE"
if [ -e "$BUILD_PATH/sketch/Multiprotocol.h" ]; then
MAJOR_VERSION=$(grep "VERSION_MAJOR" "$BUILD_PATH/sketch/Multiprotocol.h" | awk -v N=3 '{print $N}')
MINOR_VERSION=$(grep "VERSION_MINOR" "$BUILD_PATH/sketch/Multiprotocol.h" | awk -v N=3 '{print $N}')
REVISION_VERSION=$(grep "VERSION_REVISION" "$BUILD_PATH/sketch/Multiprotocol.h" | awk -v N=3 '{print $N}')
PATCH_VERSION=$(grep "VERSION_PATCH" "$BUILD_PATH/sketch/Multiprotocol.h" | awk -v N=3 '{print $N}')
MULTI_VERSION=$MAJOR_VERSION.$MINOR_VERSION.$REVISION_VERSION.$PATCH_VERSION
else
MULTI_VERSION=
fi
if [ -e "$BUILD_PATH/$PROJECT_NAME.hex" ]; then
cp "$BUILD_PATH/$PROJECT_NAME.hex" "$BUILD_PATH/multi-$MULTI_TYPE-$MULTI_VERSION.hex"
fi
if [ -e "$BUILD_PATH/$PROJECT_NAME.bin" ]; then
cp "$BUILD_PATH/$PROJECT_NAME.bin" "$BUILD_PATH/multi-$MULTI_TYPE-$MULTI_VERSION.bin"
fi
if [ $# -eq 5 ]; then
if [ $EXPORT_FLAG == "EXPORT" ]; then
if [ -e "$BUILD_PATH/$PROJECT_NAME.hex" ]; then
cp "$BUILD_PATH/$PROJECT_NAME.hex" "$SKETCH_PATH/multi-$MULTI_TYPE-$MULTI_VERSION.hex"
fi
if [ -e "$BUILD_PATH/$PROJECT_NAME.bin" ]; then
cp "$BUILD_PATH/$PROJECT_NAME.bin" "$SKETCH_PATH/multi-$MULTI_TYPE-$MULTI_VERSION.bin"
fi
if [ -e "$SKETCH_PATH/multi-$MULTI_TYPE.hex" ]; then
rm "$SKETCH_PATH/multi-$MULTI_TYPE.hex"
fi
if [ -e "$SKETCH_PATH/multi-$MULTI_TYPE.bin" ]; then
rm "$SKETCH_PATH/multi-$MULTI_TYPE.bin"
fi
fi
fi

View File

@@ -1,71 +0,0 @@
#!/bin/bash
BUILD_PATH=$1
PROJECT_NAME=$2
SKETCH_PATH=$3
MULTI_BOARD=$4
EXPORT_FLAG=$5
IFS== read MULTI_BOARD BOARD_VERSION <<< "$MULTI_BOARD"
case "$MULTI_BOARD" in
MULTI_NO_BOOT)
MULTI_TYPE=avr
;;
MULTI_FLASH_FROM_TX)
MULTI_TYPE=avr
;;
MULTI_STM32_NO_BOOT)
MULTI_TYPE=stm
;;
MULTI_STM32_FLASH_FROM_TX)
MULTI_TYPE=stm
;;
MULTI_ORANGERX)
MULTI_TYPE=orx
;;
esac
#echo "Build Path: $BUILD_PATH"
#echo "Sketch Path: $SKETCH_PATH"
#echo "Project Name: $PROJECT_NAME"
#echo "Multi Board: $MULTI_BOARD"
#echo "Multi Board Type: $MULTI_TYPE"
if [ -e "$BUILD_PATH/sketch/Multiprotocol.h" ]; then
MAJOR_VERSION=$(grep "VERSION_MAJOR" "$BUILD_PATH/sketch/Multiprotocol.h" | awk -v N=3 '{print $N}')
MINOR_VERSION=$(grep "VERSION_MINOR" "$BUILD_PATH/sketch/Multiprotocol.h" | awk -v N=3 '{print $N}')
REVISION_VERSION=$(grep "VERSION_REVISION" "$BUILD_PATH/sketch/Multiprotocol.h" | awk -v N=3 '{print $N}')
PATCH_VERSION=$(grep "VERSION_PATCH" "$BUILD_PATH/sketch/Multiprotocol.h" | awk -v N=3 '{print $N}')
MULTI_VERSION=$MAJOR_VERSION.$MINOR_VERSION.$REVISION_VERSION.$PATCH_VERSION
else
MULTI_VERSION=
fi
if [ -e "$BUILD_PATH/$PROJECT_NAME.hex" ]; then
cp "$BUILD_PATH/$PROJECT_NAME.hex" "$BUILD_PATH/multi-$MULTI_TYPE-$MULTI_VERSION.hex"
fi
if [ -e "$BUILD_PATH/$PROJECT_NAME.bin" ]; then
cp "$BUILD_PATH/$PROJECT_NAME.bin" "$BUILD_PATH/multi-$MULTI_TYPE-$MULTI_VERSION.bin"
fi
if [ $# -eq 5 ]; then
if [ $EXPORT_FLAG == "EXPORT" ]; then
if [ -e "$BUILD_PATH/$PROJECT_NAME.hex" ]; then
cp "$BUILD_PATH/$PROJECT_NAME.hex" "$SKETCH_PATH/multi-$MULTI_TYPE-$MULTI_VERSION.hex"
fi
if [ -e "$BUILD_PATH/$PROJECT_NAME.bin" ]; then
cp "$BUILD_PATH/$PROJECT_NAME.bin" "$SKETCH_PATH/multi-$MULTI_TYPE-$MULTI_VERSION.bin"
fi
if [ -e "$SKETCH_PATH/multi-$MULTI_TYPE.hex" ]; then
rm "$SKETCH_PATH/multi-$MULTI_TYPE.hex"
fi
if [ -e "$SKETCH_PATH/multi-$MULTI_TYPE.bin" ]; then
rm "$SKETCH_PATH/multi-$MULTI_TYPE.bin"
fi
fi
fi

View File

@@ -1,71 +0,0 @@
#!/bin/bash
BUILD_PATH=$1
PROJECT_NAME=$2
SKETCH_PATH=$3
MULTI_BOARD=$4
EXPORT_FLAG=$5
IFS== read MULTI_BOARD BOARD_VERSION <<< "$MULTI_BOARD"
case "$MULTI_BOARD" in
MULTI_NO_BOOT)
MULTI_TYPE=avr
;;
MULTI_FLASH_FROM_TX)
MULTI_TYPE=avr
;;
MULTI_STM32_NO_BOOT)
MULTI_TYPE=stm
;;
MULTI_STM32_FLASH_FROM_TX)
MULTI_TYPE=stm
;;
MULTI_ORANGERX)
MULTI_TYPE=orx
;;
esac
#echo "Build Path: $BUILD_PATH"
#echo "Sketch Path: $SKETCH_PATH"
#echo "Project Name: $PROJECT_NAME"
#echo "Multi Board: $MULTI_BOARD"
#echo "Multi Board Type: $MULTI_TYPE"
if [ -e "$BUILD_PATH/sketch/Multiprotocol.h" ]; then
MAJOR_VERSION=$(grep "VERSION_MAJOR" "$BUILD_PATH/sketch/Multiprotocol.h" | awk -v N=3 '{print $N}')
MINOR_VERSION=$(grep "VERSION_MINOR" "$BUILD_PATH/sketch/Multiprotocol.h" | awk -v N=3 '{print $N}')
REVISION_VERSION=$(grep "VERSION_REVISION" "$BUILD_PATH/sketch/Multiprotocol.h" | awk -v N=3 '{print $N}')
PATCH_VERSION=$(grep "VERSION_PATCH" "$BUILD_PATH/sketch/Multiprotocol.h" | awk -v N=3 '{print $N}')
MULTI_VERSION=$MAJOR_VERSION.$MINOR_VERSION.$REVISION_VERSION.$PATCH_VERSION
else
MULTI_VERSION=
fi
if [ -e "$BUILD_PATH/$PROJECT_NAME.hex" ]; then
cp "$BUILD_PATH/$PROJECT_NAME.hex" "$BUILD_PATH/multi-$MULTI_TYPE-$MULTI_VERSION.hex"
fi
if [ -e "$BUILD_PATH/$PROJECT_NAME.bin" ]; then
cp "$BUILD_PATH/$PROJECT_NAME.bin" "$BUILD_PATH/multi-$MULTI_TYPE-$MULTI_VERSION.bin"
fi
if [ $# -eq 5 ]; then
if [ $EXPORT_FLAG == "EXPORT" ]; then
if [ -e "$BUILD_PATH/$PROJECT_NAME.hex" ]; then
cp "$BUILD_PATH/$PROJECT_NAME.hex" "$SKETCH_PATH/multi-$MULTI_TYPE-$MULTI_VERSION.hex"
fi
if [ -e "$BUILD_PATH/$PROJECT_NAME.bin" ]; then
cp "$BUILD_PATH/$PROJECT_NAME.bin" "$SKETCH_PATH/multi-$MULTI_TYPE-$MULTI_VERSION.bin"
fi
if [ -e "$SKETCH_PATH/multi-$MULTI_TYPE.hex" ]; then
rm "$SKETCH_PATH/multi-$MULTI_TYPE.hex"
fi
if [ -e "$SKETCH_PATH/multi-$MULTI_TYPE.bin" ]; then
rm "$SKETCH_PATH/multi-$MULTI_TYPE.bin"
fi
fi
fi

View File

@@ -1,79 +0,0 @@
@ECHO OFF
SETLOCAL EnableDelayedExpansion
REM SET DEBUG=1
SET BUILD_PATH=%1
SET PROJECT_NAME=%2
SET SKETCH_PATH=%3
SET MULTI_BOARD=%4
SET BOARD_VERSION=%5
SET EXPORT_FLAG=%6
REM Remove double-quotes from the paths
SET BUILD_PATH=%BUILD_PATH:"=%
SET SKETCH_PATH=%SKETCH_PATH:"=%
IF %MULTI_BOARD%==MULTI_NO_BOOT SET MULTI_TYPE=avr
IF %MULTI_BOARD%==MULTI_FLASH_FROM_TX SET MULTI_TYPE=avr
IF %MULTI_BOARD%==MULTI_STM32_NO_BOOT SET MULTI_TYPE=stm
IF %MULTI_BOARD%==MULTI_STM32_FLASH_FROM_TX SET MULTI_TYPE=stm
IF %MULTI_BOARD%==MULTI_ORANGERX SET MULTI_TYPE=orx
IF DEFINED DEBUG (
ECHO.
ECHO Sketch Path: %SKETCH_PATH%
ECHO Multi Board: %MULTI_BOARD%
ECHO Multi Board Type: %MULTI_TYPE%
ECHO.
)
IF EXIST "%BUILD_PATH%\sketch\Multiprotocol.h" (
IF DEFINED DEBUG ECHO Getting Multi firmware version from "%BUILD_PATH%\sketch\Multiprotocol.h"
FOR /F "tokens=* usebackq" %%A in (`%SystemRoot%\system32\findstr.exe /C:"#define VERSION_MAJOR" "%BUILD_PATH%\sketch\Multiprotocol.h"`) DO FOR /F "tokens=3" %%i in ("%%A") do SET MAJOR_VERSION=%%i
FOR /F "tokens=* usebackq" %%B in (`%SystemRoot%\system32\findstr.exe /C:"#define VERSION_MINOR" "%BUILD_PATH%\sketch\Multiprotocol.h"`) DO FOR /F "tokens=3" %%i in ("%%B") do SET MINOR_VERSION=%%i
FOR /F "tokens=* usebackq" %%C in (`%SystemRoot%\system32\findstr.exe /C:"#define VERSION_REVISION" "%BUILD_PATH%\sketch\Multiprotocol.h"`) DO FOR /F "tokens=3" %%i in ("%%C") do SET REVISION_VERSION=%%i
FOR /F "tokens=* usebackq" %%D in (`%SystemRoot%\system32\findstr.exe /C:"#define VERSION_PATCH_LEVEL" "%BUILD_PATH%\sketch\Multiprotocol.h"`) DO FOR /F "tokens=3" %%i in ("%%D") do SET PATCH_VERSION=%%i
SET MULTI_VER=!MAJOR_VERSION!.!MINOR_VERSION!.!REVISION_VERSION!.!PATCH_VERSION!
) ELSE (
SET MULTI_VER=
)
IF DEFINED DEBUG (
ECHO.
ECHO Multi Firmware Version: %MULTI_VER%
ECHO.
)
REM Copy the compiled file to the sketch folder with the version number in the file name
IF EXIST "%BUILD_PATH%\%PROJECT_NAME%.hex" (
IF DEFINED DEBUG ECHO COPY "%BUILD_PATH%\%PROJECT_NAME%.hex" "%BUILD_PATH%\multi-%MULTI_TYPE%-%MULTI_VER%.hex" /Y
COPY "%BUILD_PATH%\%PROJECT_NAME%.hex" "%BUILD_PATH%\multi-%MULTI_TYPE%-%MULTI_VER%.hex" /Y >NUL
)
IF EXIST "%BUILD_PATH%\%PROJECT_NAME%.bin" (
IF DEFINED DEBUG ECHO COPY "%BUILD_PATH%\%PROJECT_NAME%.bin" "%BUILD_PATH%\multi-%MULTI_TYPE%-%MULTI_VER%.bin" /Y
COPY "%BUILD_PATH%\%PROJECT_NAME%.bin" "%BUILD_PATH%\multi-%MULTI_TYPE%-%MULTI_VER%.bin" /Y >NUL
)
IF "%EXPORT_FLAG%"=="EXPORT" (
REM Copy the compiled file to the sketch folder with the version number in the file name
IF EXIST "%BUILD_PATH%\%PROJECT_NAME%.hex" (
IF DEFINED DEBUG ECHO COPY "%BUILD_PATH%\%PROJECT_NAME%.hex" "%SKETCH_PATH%\multi-%MULTI_TYPE%-%MULTI_VER%.hex" /Y
COPY "%BUILD_PATH%\%PROJECT_NAME%.hex" "%SKETCH_PATH%\multi-%MULTI_TYPE%-%MULTI_VER%.hex" /Y >NUL
)
IF EXIST "%BUILD_PATH%\%PROJECT_NAME%.bin" (
IF DEFINED DEBUG ECHO COPY "%BUILD_PATH%\%PROJECT_NAME%.bin" "%SKETCH_PATH%\multi-%MULTI_TYPE%-%MULTI_VER%.bin" /Y
COPY "%BUILD_PATH%\%PROJECT_NAME%.bin" "%SKETCH_PATH%\multi-%MULTI_TYPE%-%MULTI_VER%.bin" /Y >NUL
)
IF EXIST "%SKETCH_PATH%\multi-%MULTI_TYPE%.bin" (
IF DEFINED DEBUG ECHO DEL "%SKETCH_PATH%\multi-%MULTI_TYPE%.bin"
DEL "%SKETCH_PATH%\multi-%MULTI_TYPE%.bin" >NUL
)
IF EXIST "%SKETCH_PATH%\multi-%MULTI_TYPE%.hex" (
IF DEFINED DEBUG ECHO DEL "%SKETCH_PATH%\multi-%MULTI_TYPE%.hex"
DEL "%SKETCH_PATH%\multi-%MULTI_TYPE%.hex" >NUL
)
)

View File

@@ -1,702 +0,0 @@
/*
pins_arduino.h - Pin definition functions for Arduino
Part of Arduino - http://www.arduino.cc/
Copyright (c) 2007 David A. Mellis
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
Boston, MA 02111-1307 USA
Updated for 'xmega' core by bob frazier, S.F.T. Inc. - http://mrp3.com/
X M E G A X M E G A X M E G A X M E G A X M E G A X M E G A X M E G A X M E G A X M E G A X M E G A X M E G A
The xmega code mods make a considerable number of assumptions
about the pin number assignments (as defined here):
DEFAULT MAPPING ('DIGITAL_IO_PIN_SHIFT' NOT DEFINED)
----------------------------------------------------
PORTD - digital 0-7
PORTC - digital 8-15
PORTE - digital 16-20
PORTR - digital 20-21 (built-in LED on PORTR pin 1, aka '21')
PORTA - analog 0-7, digital 22-29
PORTB - analog 8-11, digital 30-33
SPI is assumed to be on PORTC (pins 4-7)
Serial is implemented on PORTD, Serial2 on PORTC, both using pins 2,3 (no flow control)
PORTR pin 1 is assumed to be connected to an LED. Pin 1 is the 'built-in' LED, defined
as 'LED_BUILTIN', and is active HIGH.
Your Mileage May Vary, depending on your board layout. Some boards shift the
digital pin assignments by 2 so that digital I/O pin 0 is PORTD Rx, pin 13 is PORTC SCK, just
like the Arduino ATmega board. Then they align the physical pins so that a regular Arduino shield
will work, and assign PORTD 0-1 to 2 different digital I/O pin numbers (such as 20 and 21).
To facilitate that specific change, uncomment the #define for 'DIGITAL_IO_PIN_SHIFT', below.
Alternately you can create a separate version of this file with a different variant name,
such as 'xmega-compat', with the #define uncommented, stored in an appropriately named directory.
============================
HARDWARE SERIAL FLOW CONTROL
============================
This version of the xmega Arduino startup+support files supports HARDWARE FLOW CONTROL on BOTH serial ports via
RTS (output) and CTS (input). CTS is implemented as input from remote device's DTR. RTS is implemented as DTR output.
To implement RTS/CTS, use definitions similar to the following in your version of this header file
NOTE: RTS(DTR) will be configured as an output, active low (high tells sender to stop sending data to the UART)
CTS will be configured as an input, active low (high stops data from being sent out via UART)
CTS high to low transition causes an interrupt that may result in serial I/O (for faster response time).
// RTS(DTR) as GPIO 0 (port D pin 0)
#define SERIAL_0_RTS_PORT_NAME PORTD
#define SERIAL_0_RTS_PIN_INDEX 0
// CTS as GPIO 1 (port D pin 1)
#define SERIAL_0_CTS_PORT_NAME PORTD
#define SERIAL_0_CTS_PIN_INDEX 1
use similar definitions for serial 1, aka 'SERIAL_1_CTS_PORT'
NOTE: you can even use PORTA or PORTB pins for this, if you don't need to measure analog volts on those pins
X M E G A X M E G A X M E G A X M E G A X M E G A X M E G A X M E G A X M E G A X M E G A X M E G A X M E G A
*/
#ifndef Pins_Arduino_h
#define Pins_Arduino_h
#include <avr/pgmspace.h>
// for now, the default xmega uses a simple assignment of digital pin numbers, beginning with port D
// to accomodate a useful "compatibility" shield design, these pins can be shifted so that the pin
// that maps to 'digitalRead(0)' would be D2 rather than D0. This also puts 'Serial' on pins 0 and 1
// exactly like the Arduino UNO. For any other mapping, create your own 'pins_arduino.h' file.
//
#define DIGITAL_IO_PIN_SHIFT /* COMMENT THIS to disable the shifting of digital pin assignments for Arduino shield compatibility */
// default two-wire port is TWIC. '#define'ing USE_TWIC maps it to digital pins 20 and 21. Only valid with DIGITAL_IO_PIN_SHIFT '#define'd
#define USE_TWIC /* define this to re-map TWIC to digital pins 20 and 21, similar to an Arduino Mega2560. requires DIGITAL_IO_PIN_SHIFT */
#define NUM_DIGITAL_PINS 22
#define NUM_ANALOG_INPUTS 12
#define analogInputToDigitalPin(p) ((p < 12) ? (p) + 22 : -1)
#ifdef DIGITAL_IO_PIN_SHIFT
#ifdef USE_TWIC
#define digitalPinHasPWM(p) ((p) < 18 || (p) == 20 || (p) == 21) /* PORTC pins 0 and 1 are 20 and 21, respectively */
#else // USE_TWIC
#define digitalPinHasPWM(p) ((p) < 18 || (p) == 20 || (p) == 21) /* PORTD pins 0 and 1 are 20 and 21, respectively */
#endif // USE_TWIC
#else // no digital I/O pin shift
#define digitalPinHasPWM(p) ((p) < 20) /* port E pin 3 is the highest one that has PWM */
#endif // DIGITAL_IO_PIN_SHIFT
// this returns the DEFAULT INTERRUPT (in this case, interrupt 0) for any digital or analog pin
// If you choose a port's pin 2, it will be the same as using 'PORTn_INT0'
#define digitalPinToInterrupt(p) \
( pgm_read_byte(&port_to_int0_PGM[pgm_read_byte(&digital_pin_to_port_PGM[p])]) | \
( ((pgm_read_byte(&digital_pin_to_bit_mask_PGM[p]) - 2) & 7) << 5 ) )
// xmega-specific - Interrupt 'vector number' assignments:
// Interrupts are PORT-SPECIFIC, not pin specific.
// pin 2 on any port is always asynchronous (except for 'R' which doesn't have a pin 2)
// all other pins can manage synchronous interrupts. 'wakeup' from sleep mode
// and other async interrupts must be on a 'pin 2', on ports A through E
//
// Each port has 2 separate interrupt vectors. They can be assigned different pins.
// The same pin can also be assigned to both vectors on the same port, if desired.
#define PORTD_INT0 0
#define PORTD_INT1 1
#define PORTC_INT0 2
#define PORTC_INT1 3
#define PORTE_INT0 4
#define PORTE_INT1 5
#define PORTA_INT0 6
#define PORTA_INT1 7
#define PORTB_INT0 8
#define PORTB_INT1 9
#define PORTR_INT0 10
#define PORTR_INT1 11
#define EXTERNAL_NUM_INTERRUPTS 12 /* defined here instead of wiring_private.h - max value is 32 */
// was in wiring_external.h, moved here
#define EXTERNAL_INT_0 0
#define EXTERNAL_INT_1 1
#define EXTERNAL_INT_2 2
#define EXTERNAL_INT_3 3
#define EXTERNAL_INT_4 4
#define EXTERNAL_INT_5 5
#define EXTERNAL_INT_6 6
#define EXTERNAL_INT_7 7
#define EXTERNAL_INT_8 8
#define EXTERNAL_INT_9 9
#define EXTERNAL_INT_10 10
#define EXTERNAL_INT_11 11
// xmega 'D' series has 2 sets of UART and SPI.
// The default UART is assigned on Port D, pins PD2-3
// The default SPI is assigned on Port C, pins PC4-7
//
// Also there are multiple 2-wire ports, the default being assigned to PC0-1
// see definition for DEFAULT_TWI and USE_TWIC
//
// Standard GPIO pins are assigned as follows:
// PD0-7 Digital 0-7
// PC0-7 Digital 8-15
// PE0-3 digital 16-19
// PR0-1 digital 20-21
// PA0-7 analog A0-A7
// PB0-3 analog A8-A11
//
// '#define'ing DIGITAL_IO_PIN_SHIFT shifts this down by 2, and places PD0-1 on 20-21
// This is for Arduino 'atmega' compatibility with respect to existing shields, so that
// you don't have to re-map pin numbers with #defines in existing software that hard-codes them
// or makes assumptions about pin numbers vs functionality [except TWI won't ever match up]
//
// '#define'ing USE_TWIC puts PC0-1 on 20-21 (corresponding to TWI pins on later Arduinos)
//
//
// ALL PORT REMAP registers must be assigned to 0 (default mappings for pins)
// this puts PWM output on pins 0-3 for PORT E (the timers are split for C and D)
// Additionally, CLKOUT should be 0 (no clock outputs on any port/pin).
//
// TIMERS
// Timer 0 should be configured as 'Tx2' (for 8 PWM outputs) by default, essentially
// as a dual 8-bit timer, more or less compatible with the Arduino's 3 timers and
// supporting all 8 pins on ports C and D for PWM output. Port C's timer supports
// the system clock.
//
// See 'D' manual chapter 13 for more on this
// ------------------------------------------
// DEFINITIONS FOR SERIAL PORTS AND TWI PORTS
// ------------------------------------------
// TWI ports
#define DEFAULT_TWI TWIC /* note see definitions for SDA and SCL, below - alter accordingly */
// the XMega64D4 has two TWI ports
#define TWI_PORT0 TWIC
#define TWI_VECTOR_S0 TWIC_TWIS_vect
#define TWI_VECTOR_M0 TWIC_TWIM_vect
#define TWI_PORT1 TWIE
#define TWI_VECTOR_S1 TWIE_TWIS_vect
#define TWI_VECTOR_M1 TWIE_TWIM_vect
#define TWI_INTERFACE_COUNT 2
// obsolete - consider removal in all of them
//#define TWIC_VECT_ENABLE /* use this to select the correct interrupt vectors for default */
// serial port 0
#define SERIAL_0_PORT_NAME PORTD
#define SERIAL_0_USART_NAME USARTD0
#define SERIAL_0_USART_DATA USARTD0_DATA
#define SERIAL_0_RXC_ISR ISR(USARTD0_RXC_vect)
#define SERIAL_0_DRE_ISR ISR(USARTD0_DRE_vect)
//#define SERIAL_0_REMAP PORTD_REMAP /* define THIS to re-map the pins from 0-3 to 4-7 on serial port 0 */
#define SERIAL_0_REMAP_BIT 4 /* the bit needed to remap the port if SERIAL_0_REMAP is defined */
#define SERIAL_0_RX_PIN_INDEX 2 /* the pin number on the port, not the mapped digital pin number */
#define SERIAL_0_TX_PIN_INDEX 3 /* the pin number on the port, not the mapped digital pin number */
#define USARTD0_VECTOR_EXISTS
// serial port 1
#define SERIAL_1_PORT_NAME PORTC
#define SERIAL_1_USART_NAME USARTC0
#define SERIAL_1_USART_DATA USARTC0_DATA
#define SERIAL_1_RXC_ISR ISR(USARTC0_RXC_vect)
#define SERIAL_1_DRE_ISR ISR(USARTC0_DRE_vect)
//#define SERIAL_1_REMAP PORTC_REMAP /* define THIS to re-map the pins from 0-3 to 4-7 on serial port 1 */
#define SERIAL_1_REMAP_BIT 4 /* the bit needed to remap the port if SERIAL_1_REMAP is defined */
#define SERIAL_1_RX_PIN_INDEX 2 /* the pin number on the port, not the mapped digital pin number */
#define SERIAL_1_TX_PIN_INDEX 3 /* the pin number on the port, not the mapped digital pin number */
#define USARTC0_VECTOR_EXISTS
// For atmega/Arduino shield compatibility, with DIGITAL_IO_PIN_SHIFT defined
// typical board/pin layout might be like this (for shield pins):
//
// NOTE: this design/layout assumes USE_TWIC is defined, so TWI is on TWIC (port C pins 0/1)
//
// M M
// S I O T R
// A C S S S x x
// S S R G K O I S 2 2 T R
// C D E N 1 1 1 1 x x
// L A F D 3 2 1 0 9 8 7 6 5 4 3 2 1 0
// ----o-o-o-o-o-o-o-o-o-o--o-o-o-o-o-o-o-o----
// P P P P P P P P P P P P P P P P
// C C C C C C C C C C D D D D D D
// 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2
//
//
// T O P V I E W
//
//
// P P P P P P
// A A A A A A
// 5 4 3 2 1 0
// ------------o-o-o-o-o-o-o-o--o-o-o-o-o-o----
// G I R 3 5 G G V A A A A A A
// N O E . V N N i 5 4 3 2 1 0
// D R S 3 D D n
// E E V
// F T
//
// As with the MEGA2560 and other 'mega' Arduino boards, additional connectors would
// break out the additional pins, with appropriate labeling. Additionally, there should
// be an LED on PORTR pin 1 for 'LED_BUILTIN'.
//
// This layout is based on the 'Rev 3' Arduino.
//
// NOTE - NO AREF: AREF is not connected. AREF is a bit of an issue on xmega because
// it DOES! NOT! WORK! THE! SAME! as it does on the ATmegaXXX and so you would need to
// (literally) steal one of the additional analog input pins to implement it. It's not
// impossible, or even THAT difficult. I'm just not doing it here.
#ifdef DIGITAL_IO_PIN_SHIFT // aka digital I/O pin 0 is PORTD pin 2
// SHIFTED I/O pins (atmega compatibility) - see xmega mod description in comment at top
// default SPI
static const uint8_t SS = 10;
static const uint8_t MOSI = 11;
static const uint8_t MISO = 12;
static const uint8_t SCK = 13;
// primary SPI on PC4-7
static const uint8_t SS0 = 10;
static const uint8_t MOSI0 = 11;
static const uint8_t MISO0 = 12;
static const uint8_t SCK0 = 13;
// secondary SPI on PD4-7
static const uint8_t SS1 = 2;
static const uint8_t MOSI1 = 3;
static const uint8_t MISO1 = 4;
static const uint8_t SCK1 = 5;
// default 2-wire on PC0,PC1 - TWIC
#ifdef USE_TWIC
static const uint8_t SDA = 20;
static const uint8_t SCL = 21;
#else // !USE_TWIC
static const uint8_t SDA = 6;
static const uint8_t SCL = 7;
#endif // USE_TWIC
// port-specific 2-wire
#ifdef USE_TWIC
static const uint8_t SDA0 = 20;
static const uint8_t SCL0 = 21;
#else // !USE_TWIC
static const uint8_t SDA0 = 6;
static const uint8_t SCL0 = 7;
#endif // USE_TWIC
static const uint8_t SDA1 = 14;
static const uint8_t SCL1 = 15;
// keep track of the indices for port R since its control register
// settings should be slightly different - D manual table 11-6
#define PR0 18
#define PR1 19
#else // no digital I/O pin shifting, PORTD pin 0 is digital I/O pin 0 (as it should be)
// default "no shift" pin assignments
// default SPI
static const uint8_t SS = 12;
static const uint8_t MOSI = 13;
static const uint8_t MISO = 14;
static const uint8_t SCK = 15;
// primary SPI on PC4-7
static const uint8_t SS0 = 12;
static const uint8_t MOSI0 = 13;
static const uint8_t MISO0 = 14;
static const uint8_t SCK0 = 15;
// secondary SPI on PD4-7
static const uint8_t SS1 = 4;
static const uint8_t MOSI1 = 5;
static const uint8_t MISO1 = 6;
static const uint8_t SCK1 = 7;
// default 2-wire on PC0,PC1 - TWIC (TWIE appears to be broken)
static const uint8_t SDA = 8;
static const uint8_t SCL = 9;
static const uint8_t SDA0 = 8;
static const uint8_t SCL0 = 9;
static const uint8_t SDA1 = 16;
static const uint8_t SCL1 = 17;
// keep track of the indices for port R since its control register
// settings should be slightly different - D manual table 11-6
#define PR0 20
#define PR1 21
#endif // DIGITAL_IO_PIN_SHIFT
// default 'status' LED on PR1
//static const uint8_t LED_BUILTIN = PR1;
#define LED_BUILTIN PR1 /* Arduino 1.06 uses #define, not a const uint8_t */
static const uint8_t A0 = 22;
static const uint8_t A1 = 23;
static const uint8_t A2 = 24;
static const uint8_t A3 = 25;
static const uint8_t A4 = 26;
static const uint8_t A5 = 27;
static const uint8_t A6 = 28;
static const uint8_t A7 = 29;
static const uint8_t A8 = 30;
static const uint8_t A9 = 31;
static const uint8_t A10 = 32;
static const uint8_t A11 = 33;
// on the xmega64d4, PA2, PB2, PC2, PD2, and PE2 are asynchronous ints. Others are 'synchronous' which means
// that they must be held in their 'interrupt state' long enough for the system to detect them. In any case
// all digital input pins can be use as interrupts, synchronous or otherwise.
#ifdef ARDUINO_MAIN
const uint16_t PROGMEM port_to_mode_PGM[] = {
NOT_A_PORT, // 0
(uint16_t) &PORTA_DIR, // PA
(uint16_t) &PORTB_DIR, // PB
(uint16_t) &PORTC_DIR, // PC
(uint16_t) &PORTD_DIR, // PD
(uint16_t) &PORTE_DIR, // PE
(uint16_t) &PORTR_DIR, // PR
};
const uint16_t PROGMEM port_to_output_PGM[] = {
NOT_A_PORT, // 0
(uint16_t) &PORTA_OUT, // PA
(uint16_t) &PORTB_OUT, // PB
(uint16_t) &PORTC_OUT, // PC
(uint16_t) &PORTD_OUT, // PD
(uint16_t) &PORTE_OUT, // PE
(uint16_t) &PORTR_OUT, // PR
};
const uint16_t PROGMEM port_to_input_PGM[] = {
NOT_A_PORT, // 0
(uint16_t) &PORTA_IN, // PA
(uint16_t) &PORTB_IN, // PB
(uint16_t) &PORTC_IN, // PC
(uint16_t) &PORTD_IN, // PD
(uint16_t) &PORTE_IN, // PE
(uint16_t) &PORTR_IN, // PR
};
const uint8_t PROGMEM port_to_int0_PGM[] = {
NOT_AN_INTERRUPT, // 0
PORTA_INT0, // PA
PORTB_INT0, // PB
PORTC_INT0, // PC
PORTD_INT0, // PD
PORTE_INT0, // PE
PORTR_INT0, // PR
};
// xmega has a per-pin config register as well. Normally these will be 00000111 for analog, 00000000 for digital 'totem pole'
// for 'INPUT_PULLUP' these will be 00011111
// bits 2:0 (trigger) 000 both edges 001 rising 010 falling 011 level 111 input buffer disabled
// note: 'input buffer disabled' required to use the 'IN' register (so default here)
// also port R does not support 'INTPUT_DISABLED' (sic) so use BOTHEDGES [0] instead
// bits 5:3 (out/pull) 000 TOTEM [normal], 001 bus keeper [sticky], 010 pulldown, 011 pullup,
// 100 wired 'or', 101 wired 'and', 110 wired 'or' pulldown, 111 wired 'and' pullup
// bit 6: "invert logic" (0 = normal, 1 = inverted)
// bit 7: unused, must be zero
// NOTE: PORTA through PORTE (PORTF?) support 'input buffer disabled' and this setting is recommended
// for analog inputs. PORTR apparently does NOT support this (set to zero?)
const uint16_t PROGMEM digital_pin_to_control_PGM[] = {
#ifndef DIGITAL_IO_PIN_SHIFT
(uint16_t) &PORTD_PIN0CTRL, // PD 0 ** 0 **
(uint16_t) &PORTD_PIN1CTRL, // PD 1 ** 1 **
#endif // DIGITAL_IO_PIN_SHIFT
// subtract 2 from the digital pin number if DIGITAL_IO_PIN_SHIFT is defined
(uint16_t) &PORTD_PIN2CTRL, // PD 2 ** 2 ** USARTD_RX ASYNC
(uint16_t) &PORTD_PIN3CTRL, // PD 3 ** 3 ** USARTD_TX
(uint16_t) &PORTD_PIN4CTRL, // PD 4 ** 4 **
(uint16_t) &PORTD_PIN5CTRL, // PD 5 ** 5 **
(uint16_t) &PORTD_PIN6CTRL, // PD 6 ** 6 **
(uint16_t) &PORTD_PIN7CTRL, // PD 7 ** 7 **
#if defined(DIGITAL_IO_PIN_SHIFT) && defined(USE_TWIC)
(uint16_t) &PORTD_PIN0CTRL, // PD 0 ** 8 ** map PORTD pins 0/1 here if TWIC is used
(uint16_t) &PORTD_PIN1CTRL, // PD 1 ** 9 **
#else
(uint16_t) &PORTC_PIN0CTRL, // PC 0 ** 8 ** SDA
(uint16_t) &PORTC_PIN1CTRL, // PC 1 ** 9 ** SCL
#endif // defined(DIGITAL_IO_PIN_SHIFT) && defined(USE_TWIC)
(uint16_t) &PORTC_PIN2CTRL, // PC 2 ** 10 ** ASYNC
(uint16_t) &PORTC_PIN3CTRL, // PC 3 ** 11 **
(uint16_t) &PORTC_PIN4CTRL, // PC 4 ** 12 ** SPI_SS
(uint16_t) &PORTC_PIN5CTRL, // PC 5 ** 13 ** SPI_MOSI
(uint16_t) &PORTC_PIN6CTRL, // PC 6 ** 14 ** SPI_MISO
(uint16_t) &PORTC_PIN7CTRL, // PC 7 ** 15 ** SPI_SCK
(uint16_t) &PORTE_PIN0CTRL, // PE 0 ** 16 ** SDA1
(uint16_t) &PORTE_PIN1CTRL, // PE 1 ** 17 ** SCL1
(uint16_t) &PORTE_PIN2CTRL, // PE 2 ** 18 ** ASYNC
(uint16_t) &PORTE_PIN3CTRL, // PE 3 ** 19 **
(uint16_t) &PORTR_PIN0CTRL, // PR 0 ** 20 **
(uint16_t) &PORTR_PIN1CTRL, // PR 1 ** 21 ** default LED
#ifdef DIGITAL_IO_PIN_SHIFT
#ifdef USE_TWIC
(uint16_t) &PORTC_PIN0CTRL, // PC 0 ** the new 20 ** SDA, SDA0
(uint16_t) &PORTC_PIN1CTRL, // PC 1 ** the new 21 ** SCL, SCL0
#else
(uint16_t) &PORTD_PIN0CTRL, // PD 0 ** the new 20 **
(uint16_t) &PORTD_PIN1CTRL, // PD 1 ** the new 21 **
#endif // USE_TWIC
#endif // DIGITAL_IO_PIN_SHIFT
(uint16_t) &PORTA_PIN0CTRL, // PA 0 ** 22 ** A0
(uint16_t) &PORTA_PIN1CTRL, // PA 1 ** 23 ** A1
(uint16_t) &PORTA_PIN2CTRL, // PA 2 ** 24 ** A2 ASYNC
(uint16_t) &PORTA_PIN3CTRL, // PA 3 ** 25 ** A3
(uint16_t) &PORTA_PIN4CTRL, // PA 4 ** 26 ** A4
(uint16_t) &PORTA_PIN5CTRL, // PA 5 ** 27 ** A5
(uint16_t) &PORTA_PIN6CTRL, // PA 6 ** 28 ** A6
(uint16_t) &PORTA_PIN7CTRL, // PA 7 ** 29 ** A7
(uint16_t) &PORTB_PIN0CTRL, // PB 0 ** 30 ** A8
(uint16_t) &PORTB_PIN1CTRL, // PB 1 ** 31 ** A9
(uint16_t) &PORTB_PIN2CTRL, // PB 2 ** 32 ** A10 ASYNC
(uint16_t) &PORTB_PIN3CTRL, // PB 3 ** 33 ** A11
};
const uint8_t PROGMEM digital_pin_to_port_PGM[] = {
// PORTLIST
// -------------------------------------------
#ifndef DIGITAL_IO_PIN_SHIFT
_PD, // PD 0 ** 0 **
_PD, // PD 1 ** 1 **
#endif // DIGITAL_IO_PIN_SHIFT
// subtract 2 from the digital pin number if DIGITAL_IO_PIN_SHIFT is defined
_PD, // PD 2 ** 2 ** USARTD_RX
_PD, // PD 3 ** 3 ** USARTD_TX
_PD, // PD 4 ** 4 **
_PD, // PD 5 ** 5 **
_PD, // PD 6 ** 6 **
_PD, // PD 7 ** 7 **
#if defined(DIGITAL_IO_PIN_SHIFT) && defined(USE_TWIC)
_PD, // PD 0 ** 8 **
_PD, // PD 1 ** 9 **
#else
_PC, // PC 0 ** 8 ** SDA
_PC, // PC 1 ** 9 ** SCL
#endif // defined(DIGITAL_IO_PIN_SHIFT) && defined(USE_TWIC)
_PC, // PC 2 ** 10 **
_PC, // PC 3 ** 11 **
_PC, // PC 4 ** 12 ** SPI_SS
_PC, // PC 5 ** 13 ** SPI_MOSI
_PC, // PC 6 ** 14 ** SPI_MISO
_PC, // PC 7 ** 15 ** SPI_SCK
_PE, // PE 0 ** 16 ** SDA
_PE, // PE 1 ** 17 ** SCL
_PE, // PE 2 ** 18 **
_PE, // PE 3 ** 19 **
_PR, // PR 0 ** 20 **
_PR, // PR 1 ** 21 ** default LED
#ifdef DIGITAL_IO_PIN_SHIFT
#ifdef USE_TWIC
_PC, // PC 0 ** the new 20 ** SDA
_PC, // PC 1 ** the new 21 ** SCL
#else
_PD, // PD 0 ** the new 20 **
_PD, // PD 1 ** the new 21 **
#endif // USE_TWIC
#endif // DIGITAL_IO_PIN_SHIFT
_PA, // PA 0 ** 22 ** A0
_PA, // PA 1 ** 23 ** A1
_PA, // PA 2 ** 24 ** A2
_PA, // PA 3 ** 25 ** A3
_PA, // PA 4 ** 26 ** A4
_PA, // PA 5 ** 27 ** A5
_PA, // PA 6 ** 28 ** A6
_PA, // PA 7 ** 29 ** A7
_PB, // PB 0 ** 30 ** A8
_PB, // PB 1 ** 31 ** A9
_PB, // PB 2 ** 32 ** A10
_PB, // PB 3 ** 33 ** A11
};
const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] = {
// PIN IN PORT
// -------------------------------------------
#ifndef DIGITAL_IO_PIN_SHIFT
_BV( 0 ), // PD 0 ** 0 **
_BV( 1 ), // PD 1 ** 1 **
#endif // DIGITAL_IO_PIN_SHIFT
// subtract 2 from the digital pin number if DIGITAL_IO_PIN_SHIFT is defined
_BV( 2 ), // PD 2 ** 2 ** USARTD_RX
_BV( 3 ), // PD 3 ** 3 ** USARTD_TX
_BV( 4 ), // PD 4 ** 4 **
_BV( 5 ), // PD 5 ** 5 **
_BV( 6 ), // PD 6 ** 6 **
_BV( 7 ), // PD 7 ** 7 **
#if defined(DIGITAL_IO_PIN_SHIFT) && defined(USE_TWIC)
_BV( 0 ), // PD 0 ** 8 **
_BV( 1 ), // PD 1 ** 9 **
#else
_BV( 0 ), // PC 0 ** 8 ** SDA
_BV( 1 ), // PC 1 ** 9 ** SCL
#endif // defined(DIGITAL_IO_PIN_SHIFT) && defined(USE_TWIC)
_BV( 2 ), // PC 2 ** 10 **
_BV( 3 ), // PC 3 ** 11 **
_BV( 4 ), // PC 4 ** 12 ** SPI_SS
_BV( 5 ), // PC 5 ** 13 ** SPI_MOSI
_BV( 6 ), // PC 6 ** 14 ** SPI_MISO
_BV( 7 ), // PC 7 ** 15 ** SPI_SCK
_BV( 0 ), // PE 0 ** 16 ** SDA
_BV( 1 ), // PE 1 ** 17 ** SCL
_BV( 2 ), // PE 2 ** 18 **
_BV( 3 ), // PE 3 ** 19 **
_BV( 0 ), // PR 0 ** 20 **
_BV( 1 ), // PR 1 ** 21 ** default LED
#ifdef DIGITAL_IO_PIN_SHIFT
#ifdef USE_TWIC
_BV( 0 ), // PC 0 ** the new 20 ** SDA
_BV( 1 ), // PC 1 ** the new 21 ** SCL
#else
_BV( 0 ), // PD 0 ** the new 20 **
_BV( 1 ), // PD 1 ** the new 21 **
#endif // USE_TWIC
#endif // DIGITAL_IO_PIN_SHIFT
_BV( 0 ), // PA 0 ** 22 ** A0
_BV( 1 ), // PA 1 ** 23 ** A1
_BV( 2 ), // PA 2 ** 24 ** A2
_BV( 3 ), // PA 3 ** 25 ** A3
_BV( 4 ), // PA 4 ** 26 ** A4
_BV( 5 ), // PA 5 ** 27 ** A5
_BV( 6 ), // PA 6 ** 28 ** A6
_BV( 7 ), // PA 7 ** 29 ** A7
_BV( 0 ), // PB 0 ** 30 ** A8
_BV( 1 ), // PB 1 ** 31 ** A9
_BV( 2 ), // PB 2 ** 32 ** A10
_BV( 3 ), // PB 3 ** 33 ** A11
};
const uint8_t PROGMEM digital_pin_to_timer_PGM[] = {
// TIMERS
// -------------------------------------------
// for now 'NOT_ON_TIMER' for all - later, assign timers based
// on pins 0-3 being enabled as PWM out for ports A through E
// corresponding to timers A through D (see D manual sections 11.12.14,
// also see D manual sect 13.6 for using the 'compare' channel on 'TCx2' to generate
// a PWM output. Must select pin as output, _AND_ enable the 'compare' output
// for the appropriate pin. LCMPENx/HCMPENx registers to enable it.
#ifndef DIGITAL_IO_PIN_SHIFT
TIMERD2, // PD 0 ** 0 **
TIMERD2, // PD 1 ** 1 **
#endif // DIGITAL_IO_PIN_SHIFT
// subtract 2 from the digital pin number if DIGITAL_IO_PIN_SHIFT is defined
TIMERD2, // PD 2 ** 2 ** USARTD_RX
TIMERD2, // PD 3 ** 3 ** USARTD_TX
TIMERD2, // PD 4 ** 4 **
TIMERD2, // PD 5 ** 5 **
TIMERD2, // PD 6 ** 6 **
TIMERD2, // PD 7 ** 7 **
#if defined(DIGITAL_IO_PIN_SHIFT) && defined(USE_TWIC)
TIMERD2, // PD 0 ** 8 **
TIMERD2, // PD 1 ** 9 **
#else
TIMERC2, // PC 0 ** 8 ** SDA
TIMERC2, // PC 1 ** 9 ** SCL
#endif // defined(DIGITAL_IO_PIN_SHIFT) && defined(USE_TWIC)
TIMERC2, // PC 2 ** 10 **
TIMERC2, // PC 3 ** 11 **
TIMERC2, // PC 4 ** 12 ** SPI_SS
TIMERC2, // PC 5 ** 13 ** SPI_MOSI
TIMERC2, // PC 6 ** 14 ** SPI_MISO
TIMERC2, // PC 7 ** 15 ** SPI_SCK
TIMERE0, // PE 0 ** 16 ** SDA
TIMERE0, // PE 1 ** 17 ** SCL
TIMERE0, // PE 2 ** 18 **
TIMERE0, // PE 3 ** 19 **
NOT_ON_TIMER, // PR 0 ** 20 **
NOT_ON_TIMER, // PR 1 ** 21 ** default LED
#ifdef DIGITAL_IO_PIN_SHIFT
#ifdef USE_TWIC
TIMERC2, // PC 0 ** the new 20 ** SDA
TIMERC2, // PC 1 ** the new 21 ** SCL
#else
TIMERD2, // PD 0 ** the new 20 **
TIMERD2, // PD 1 ** the new 21 **
#endif // USE_TWIC
#endif // DIGITAL_IO_PIN_SHIFT
NOT_ON_TIMER, // PA 0 ** 22 ** A0
NOT_ON_TIMER, // PA 1 ** 23 ** A1
NOT_ON_TIMER, // PA 2 ** 24 ** A2
NOT_ON_TIMER, // PA 3 ** 25 ** A3
NOT_ON_TIMER, // PA 4 ** 26 ** A4
NOT_ON_TIMER, // PA 5 ** 27 ** A5
NOT_ON_TIMER, // PA 6 ** 28 ** A6
NOT_ON_TIMER, // PA 7 ** 29 ** A7
NOT_ON_TIMER, // PB 0 ** 30 ** A8
NOT_ON_TIMER, // PB 1 ** 31 ** A9
NOT_ON_TIMER, // PB 2 ** 32 ** A10
NOT_ON_TIMER, // PB 3 ** 33 ** A11
};
#endif
// These serial port names are intended to allow libraries and architecture-neutral
// sketches to automatically default to the correct port name for a particular type
// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN,
// the first hardware serial port whose RX/TX pins are not dedicated to another use.
//
// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor
//
// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial
//
// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library
//
// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins.
//
// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX
// pins are NOT connected to anything by default.
#define SERIAL_PORT_MONITOR Serial
#define SERIAL_PORT_HARDWARE Serial
#define SERIAL_HARDWARE_OPEN Serial2
#endif

View File

@@ -1,26 +0,0 @@
#!/bin/bash
AVR_VERSION=$(grep "^version=[0-9].[0-9].[0-9]" "avr/platform.txt" | awk -F = '{ print $2 }')
STM_VERSION=$(grep "^version=[0-9].[0-9].[0-9]" "stm32/platform.txt" | awk -F = '{ print $2 }')
echo
echo "AVR Version: $AVR_VERSION"
echo "Creating archive 'package_multi_4in1_avr_board_v$AVR_VERSION.tar.gz'"
tar -czf ../Archives/package_multi_4in1_avr_board_v$AVR_VERSION.tar.gz --transform s/avr/package_multi_4in1_avr_board_v$AVR_VERSION/ avr/*
sleep 1s
echo
echo "Package: package_multi_4in1_avr_board_v$AVR_VERSION.tar.gz"
echo "SHA256: `(sha256sum ../Archives/package_multi_4in1_avr_board_v$AVR_VERSION.tar.gz | awk -v N=1 '{print $N}')`"
echo "Size: `(ls -al ../Archives/package_multi_4in1_avr_board_v$AVR_VERSION.tar.gz | awk -v N=5 '{print $N}')`"
echo
echo "STM Version: $STM_VERSION"
echo "Creating archive 'package_multi_4in1_stm32_board_v$STM_VERSION.tar.gz'"
tar -czf ../Archives/package_multi_4in1_stm32_board_v$STM_VERSION.tar.gz --transform s/stm32/package_multi_4in1_stm32_board_v$STM_VERSION/ stm32/*
sleep 1s
echo
echo "Package: package_multi_4in1_stm_board_v$STM_VERSION.tar.gz"
echo "SHA256: `(sha256sum ../Archives/package_multi_4in1_stm32_board_v$STM_VERSION.tar.gz | awk -v N=1 '{print $N}')`"
echo "Size: `(ls -al ../Archives/package_multi_4in1_stm32_board_v$STM_VERSION.tar.gz | awk -v N=5 '{print $N}')`"
echo
echo Done
echo

View File

@@ -1,64 +0,0 @@
# See: https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification
# See: http://code.google.com/p/arduino/wiki/Platforms
##############################################################
menu.upload_method=Upload method
menu.bootloader=Bootloader
##############################################################
## Multi 4-in-1 STM32
## --------------------------------------------------
multistm32f103c.name=Multi 4-in-1 (STM32F103CB)
multistm32f103c.vid.0=0x1EAF
multistm32f103c.pid.0=0x0004
multistm32f103c.build.variant=generic_stm32f103c
multistm32f103c.build.vect=VECT_TAB_ADDR=0x8000000
multistm32f103c.build.core=maple
multistm32f103c.build.board=MULTI_STM32_FLASH_FROM_TX=103
multistm32f103c.upload.use_1200bps_touch=false
multistm32f103c.upload.file_type=bin
multistm32f103c.upload.auto_reset=true
multistm32f103c.upload.tool=maple_upload
multistm32f103c.upload.protocol=maple_dfu
multistm32f103c.build.cpu_flags=-DMCU_STM32F103CB
multistm32f103c.build.ldscript=ld/jtag.ld
multistm32f103c.upload.maximum_size=131072
multistm32f103c.upload.maximum_data_size=20480
multistm32f103c.build.f_cpu=72000000L
multistm32f103c.build.flags.optimize=-Os
multistm32f103c.build.flags.ldspecs=
multistm32f103c.bootloader.tool=serial_upload
#---------------------------- UPLOAD METHODS ---------------------------
multistm32f103c.menu.upload_method.TxFlashMethod=Flash from Tx
multistm32f103c.menu.upload_method.TxFlashMethod.build.board=MULTI_STM32_FLASH_FROM_TX=103
multistm32f103c.menu.upload_method.TxFlashMethod.upload.tool=tx_upload
multistm32f103c.menu.upload_method.TxFlashMethod.build.upload_flags=-DSERIAL_USB -DGENERIC_BOOTLOADER
multistm32f103c.menu.upload_method.TxFlashMethod.build.vect=VECT_TAB_ADDR=0x8002000
multistm32f103c.menu.upload_method.TxFlashMethod.build.ldscript=ld/bootloader_20.ld
multistm32f103c.menu.upload_method.TxFlashMethod.bootloader.file=Multi4in1/StmMultiBoot.bin
multistm32f103c.menu.upload_method.DFUUploadMethod=Upload via USB
multistm32f103c.menu.upload_method.DFUUploadMethod.build.board=MULTI_STM32_NO_BOOT=103
multistm32f103c.menu.upload_method.DFUUploadMethod.upload.protocol=maple_dfu
multistm32f103c.menu.upload_method.DFUUploadMethod.upload.tool=maple_upload
multistm32f103c.menu.upload_method.DFUUploadMethod.build.upload_flags=-DSERIAL_USB -DGENERIC_BOOTLOADER
multistm32f103c.menu.upload_method.DFUUploadMethod.build.vect=VECT_TAB_ADDR=0x8002000
multistm32f103c.menu.upload_method.DFUUploadMethod.build.ldscript=ld/bootloader_20.ld
multistm32f103c.menu.upload_method.DFUUploadMethod.upload.usbID=1EAF:0003
multistm32f103c.menu.upload_method.DFUUploadMethod.upload.altID=2
multistm32f103c.menu.upload_method.DFUUploadMethod.bootloader.file=Multi4in1/StmMultiUSB.bin
multistm32f103c.menu.upload_method.serialMethod=Upload via Serial (FTDI)
multistm32f103c.menu.upload_method.serialMethod.upload.protocol=maple_serial
multistm32f103c.menu.upload_method.serialMethod.upload.tool=serial_upload
multistm32f103c.menu.upload_method.serialMethod.build.upload_flags=-DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG
multistm32f103c.menu.upload_method.serialMethod.build.board=MULTI_STM32_NO_BOOT=103
##############################################################

View File

@@ -1,44 +0,0 @@
/******************************************************************************
* The MIT License
*
* Copyright (c) 2010 LeafLabs LLC.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*****************************************************************************/
#ifndef _WIRISH_WPROGRAM_H_
#define _WIRISH_WPROGRAM_H_
#include "wirish.h"
void setup();
void loop();
#ifdef __cplusplus
extern "C"{
#endif // __cplusplus
void yield(void);
#ifdef __cplusplus
}
#endif // __cplusplus
#include "variant.h"
#endif

View File

@@ -1,45 +0,0 @@
/*
Client.h - Base class that provides Client
Copyright (c) 2011 Adrian McEwen. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef client_h
#define client_h
#include "Print.h"
#include "Stream.h"
#include "IPAddress.h"
class Client : public Stream {
public:
virtual int connect(IPAddress ip, uint16_t port) =0;
virtual int connect(const char *host, uint16_t port) =0;
virtual size_t write(uint8_t) =0;
virtual size_t write(const uint8_t *buf, size_t size) =0;
virtual int available() = 0;
virtual int read() = 0;
virtual int read(uint8_t *buf, size_t size) = 0;
virtual int peek() = 0;
virtual void flush() = 0;
virtual void stop() = 0;
virtual uint8_t connected() = 0;
virtual operator bool() = 0;
protected:
uint8_t* rawIPAddress(IPAddress& addr) { return addr.raw_address(); };
};
#endif

View File

@@ -1,200 +0,0 @@
/******************************************************************************
* The MIT License
*
* Copyright (c) 2010 Perry Hung.
* Copyright (c) 2011, 2012 LeafLabs, LLC.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*****************************************************************************/
/**
* @file wirish/HardwareSerial.cpp
* @brief Wirish serial port implementation.
*/
#include "HardwareSerial.h"
#include <libmaple/libmaple.h>
#include <libmaple/gpio.h>
#include <libmaple/timer.h>
#include <libmaple/usart.h>
#if 0
#define DEFINE_HWSERIAL(name, n) \
HardwareSerial name(USART##n, \
BOARD_USART##n##_TX_PIN, \
BOARD_USART##n##_RX_PIN)
#define DEFINE_HWSERIAL_UART(name, n) \
HardwareSerial name(UART##n, \
BOARD_USART##n##_TX_PIN, \
BOARD_USART##n##_RX_PIN)
#ifdef SERIAL_USB
#if BOARD_HAVE_USART1
DEFINE_HWSERIAL(Serial1, 1);
#endif
#if BOARD_HAVE_USART2
DEFINE_HWSERIAL(Serial2, 2);
#endif
#if BOARD_HAVE_USART3
DEFINE_HWSERIAL(Serial3, 3);
#endif
#if BOARD_HAVE_UART4
DEFINE_HWSERIAL_UART(Serial4, 4);
#endif
#if BOARD_HAVE_UART5
DEFINE_HWSERIAL_UART(Serial5, 5);
#endif
#if BOARD_HAVE_USART6
DEFINE_HWSERIAL_UART(Serial6, 6);
#endif
#else
#if BOARD_HAVE_USART1
DEFINE_HWSERIAL(Serial, 1);
#endif
#if BOARD_HAVE_USART2
DEFINE_HWSERIAL(Serial1, 2);
#endif
#if BOARD_HAVE_USART3
DEFINE_HWSERIAL(Serial2, 3);
#endif
#if BOARD_HAVE_UART4
DEFINE_HWSERIAL_UART(Serial3, 4);
#endif
#if BOARD_HAVE_UART5
DEFINE_HWSERIAL_UART(Serial4, 5);
#endif
#if BOARD_HAVE_USART6
DEFINE_HWSERIAL_UART(Serial5, 6);
#endif
#endif
#endif
HardwareSerial::HardwareSerial(usart_dev *usart_device,
uint8 tx_pin,
uint8 rx_pin) {
this->usart_device = usart_device;
this->tx_pin = tx_pin;
this->rx_pin = rx_pin;
}
/*
* Set up/tear down
*/
#if STM32_MCU_SERIES == STM32_SERIES_F1
/* F1 MCUs have no GPIO_AFR[HL], so turn off PWM if there's a conflict
* on this GPIO bit. */
static void disable_timer_if_necessary(timer_dev *dev, uint8 ch) {
if (dev != NULL) {
timer_set_mode(dev, ch, TIMER_DISABLED);
}
}
#elif (STM32_MCU_SERIES == STM32_SERIES_F2) || \
(STM32_MCU_SERIES == STM32_SERIES_F4)
#define disable_timer_if_necessary(dev, ch) ((void)0)
#else
#warning "Unsupported STM32 series; timer conflicts are possible"
#endif
void HardwareSerial::begin(uint32 baud)
{
begin(baud,SERIAL_8N1);
}
/*
* Roger Clark.
* Note. The config parameter is not currently used. This is a work in progress.
* Code needs to be written to set the config of the hardware serial control register in question.
*
*/
void HardwareSerial::begin(uint32 baud, uint8_t config)
{
// ASSERT(baud <= this->usart_device->max_baud);// Roger Clark. Assert doesn't do anything useful, we may as well save the space in flash and ram etc
if (baud > this->usart_device->max_baud) {
return;
}
const stm32_pin_info *txi = &PIN_MAP[this->tx_pin];
const stm32_pin_info *rxi = &PIN_MAP[this->rx_pin];
disable_timer_if_necessary(txi->timer_device, txi->timer_channel);
usart_init(this->usart_device);
usart_config_gpios_async(this->usart_device,
rxi->gpio_device, rxi->gpio_bit,
txi->gpio_device, txi->gpio_bit,
config);
usart_set_baud_rate(this->usart_device, USART_USE_PCLK, baud);
usart_enable(this->usart_device);
}
void HardwareSerial::end(void) {
usart_disable(this->usart_device);
}
/*
* I/O
*/
int HardwareSerial::read(void) {
if(usart_data_available(usart_device) > 0) {
return usart_getc(usart_device);
} else {
return -1;
}
}
int HardwareSerial::available(void) {
return usart_data_available(this->usart_device);
}
/* Roger Clark. Added function missing from LibMaple code */
int HardwareSerial::peek(void)
{
return usart_peek(this->usart_device);
}
int HardwareSerial::availableForWrite(void)
{
/* Roger Clark.
* Currently there isn't an output ring buffer, chars are sent straight to the hardware.
* so just return 1, meaning that 1 char can be written
* This will be slower than a ring buffer implementation, but it should at least work !
*/
return 1;
}
size_t HardwareSerial::write(unsigned char ch) {
usart_putc(this->usart_device, ch);
return 1;
}
/* edogaldo: Waits for the transmission of outgoing serial data to complete (Arduino 1.0 api specs) */
void HardwareSerial::flush(void) {
while(!rb_is_empty(this->usart_device->wb)); // wait for TX buffer empty
while(!((this->usart_device->regs->SR) & (1<<USART_SR_TC_BIT))); // wait for TC (Transmission Complete) flag set
}

View File

@@ -1,224 +0,0 @@
/******************************************************************************
* The MIT License
*
* Copyright (c) 2010 Perry Hung.
* Copyright (c) 2011, 2012 LeafLabs, LLC.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*****************************************************************************/
/**
* @file wirish/include/wirish/HardwareSerial.h
* @brief Wirish serial port interface.
*/
#ifndef _WIRISH_HARDWARESERIAL_H_
#define _WIRISH_HARDWARESERIAL_H_
#include <libmaple/libmaple_types.h>
#include "Print.h"
#include "boards.h"
#include "Stream.h"
/*
* IMPORTANT:
*
* This class documented "by hand" (i.e., not using Doxygen) in the
* leaflabs-docs/ repository.
*
* If you alter the public HardwareSerial interface, you MUST update
* the documentation accordingly.
*/
// Define constants and variables for buffering incoming serial data. We're
// using a ring buffer (I think), in which head is the index of the location
// to which to write the next incoming character and tail is the index of the
// location from which to read.
#if !(defined(SERIAL_TX_BUFFER_SIZE) && defined(SERIAL_RX_BUFFER_SIZE))
#if (RAMEND < 1000)
#define SERIAL_TX_BUFFER_SIZE 16
#define SERIAL_RX_BUFFER_SIZE 16
#else
#define SERIAL_TX_BUFFER_SIZE 64
#define SERIAL_RX_BUFFER_SIZE 64
#endif
#endif
#if (SERIAL_TX_BUFFER_SIZE>256)
typedef uint16_t tx_buffer_index_t;
#else
typedef uint8_t tx_buffer_index_t;
#endif
#if (SERIAL_RX_BUFFER_SIZE>256)
typedef uint16_t rx_buffer_index_t;
#else
typedef uint8_t rx_buffer_index_t;
#endif
struct usart_dev;
/* Roger Clark
*
* Added config defines from AVR
* Note. The values will need to be changed to match STM32 USART config register values, these are just place holders.
*/
// Define config for Serial.begin(baud, config);
// Note. STM32 doesn't support as many different Serial modes as AVR or SAM cores.
// The word legth bit M must be set when using parity bit.
#define SERIAL_8N1 0B00000000
#define SERIAL_8N2 0B00100000
#define SERIAL_9N1 0B00001000
#define SERIAL_9N2 0B00101000
#define SERIAL_8E1 0B00001010
#define SERIAL_8E2 0B00101010
/* not supported:
#define SERIAL_9E1 0B00001010
#define SERIAL_9E2 0B00101010
*/
#define SERIAL_8O1 0B00001011
#define SERIAL_8O2 0B00101011
/* not supported:
#define SERIAL_9O1 0B00001011
#define SERIAL_9O2 0B00101011
*/
/* Roger Clark
* Moved macros from hardwareSerial.cpp
*/
#define DEFINE_HWSERIAL(name, n) \
HardwareSerial name(USART##n, \
BOARD_USART##n##_TX_PIN, \
BOARD_USART##n##_RX_PIN)
#define DEFINE_HWSERIAL_UART(name, n) \
HardwareSerial name(UART##n, \
BOARD_USART##n##_TX_PIN, \
BOARD_USART##n##_RX_PIN)
/* Roger clark. Changed class inheritance from Print to Stream.
* Also added new functions for peek() and availableForWrite()
* Note. AvailableForWrite is only a stub function in the cpp
*/
class HardwareSerial : public Stream {
public:
HardwareSerial(struct usart_dev *usart_device,
uint8 tx_pin,
uint8 rx_pin);
/* Set up/tear down */
void begin(uint32 baud);
void begin(uint32 baud,uint8_t config);
void end();
virtual int available(void);
virtual int peek(void);
virtual int read(void);
int availableForWrite(void);
virtual void flush(void);
virtual size_t write(uint8_t);
inline size_t write(unsigned long n) { return write((uint8_t)n); }
inline size_t write(long n) { return write((uint8_t)n); }
inline size_t write(unsigned int n) { return write((uint8_t)n); }
inline size_t write(int n) { return write((uint8_t)n); }
using Print::write;
/* Pin accessors */
int txPin(void) { return this->tx_pin; }
int rxPin(void) { return this->rx_pin; }
operator bool() { return true; }
/* Escape hatch into libmaple */
/* FIXME [0.0.13] documentation */
struct usart_dev* c_dev(void) { return this->usart_device; }
private:
struct usart_dev *usart_device;
uint8 tx_pin;
uint8 rx_pin;
protected:
#if 0
volatile uint8_t * const _ubrrh;
volatile uint8_t * const _ubrrl;
volatile uint8_t * const _ucsra;
volatile uint8_t * const _ucsrb;
volatile uint8_t * const _ucsrc;
volatile uint8_t * const _udr;
// Has any byte been written to the UART since begin()
bool _written;
volatile rx_buffer_index_t _rx_buffer_head;
volatile rx_buffer_index_t _rx_buffer_tail;
volatile tx_buffer_index_t _tx_buffer_head;
volatile tx_buffer_index_t _tx_buffer_tail;
// Don't put any members after these buffers, since only the first
// 32 bytes of this struct can be accessed quickly using the ldd
// instruction.
unsigned char _rx_buffer[SERIAL_RX_BUFFER_SIZE];
unsigned char _tx_buffer[SERIAL_TX_BUFFER_SIZE];
#endif
};
#ifdef SERIAL_USB
#if BOARD_HAVE_USART1
extern HardwareSerial Serial1;
#endif
#if BOARD_HAVE_USART2
extern HardwareSerial Serial2;
#endif
#if BOARD_HAVE_USART3
extern HardwareSerial Serial3;
#endif
#if BOARD_HAVE_UART4
extern HardwareSerial Serial4;
#endif
#if BOARD_HAVE_UART5
extern HardwareSerial Serial5;
#endif
#if BOARD_HAVE_USART6
extern HardwareSerial Serial6;
#endif
#else
#if BOARD_HAVE_USART1
extern HardwareSerial Serial;
#endif
#if BOARD_HAVE_USART2
extern HardwareSerial Serial1;
#endif
#if BOARD_HAVE_USART3
extern HardwareSerial Serial2;
#endif
#if BOARD_HAVE_UART4
extern HardwareSerial Serial3;
#endif
#if BOARD_HAVE_UART5
extern HardwareSerial Serial4;
#endif
#if BOARD_HAVE_USART6
extern HardwareSerial Serial5;
#endif
#endif
#endif

View File

@@ -1,192 +0,0 @@
/******************************************************************************
* The MIT License
*
* Copyright (c) 2010 Bryan Newbold.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*****************************************************************************/
#include "HardwareTimer.h"
#include <libmaple/rcc.h>
#include "ext_interrupts.h" // for noInterrupts(), interrupts()
#include "wirish_math.h"
#include <board/board.h> // for CYCLES_PER_MICROSECOND
// TODO [0.1.0] Remove deprecated pieces
/*
* Evil hack to infer this->dev from timerNum in the HardwareTimer
* constructor. See:
*
* http://www.parashift.com/c++-faq-lite/pointers-to-members.html#faq-33.2
* http://yosefk.com/c++fqa/function.html#fqa-33.2
*/
extern "C" {
static timer_dev **this_devp;
static rcc_clk_id this_id;
static void set_this_dev(timer_dev *dev) {
if (dev->clk_id == this_id) {
*this_devp = dev;
}
}
}
/*
* HardwareTimer routines
*/
HardwareTimer::HardwareTimer(uint8 timerNum) {
rcc_clk_id timerID = (rcc_clk_id)(RCC_TIMER1 + (timerNum - 1));
this->dev = NULL;
noInterrupts(); // Hack to ensure we're the only ones using
// set_this_dev() and friends. TODO: use a lock.
this_id = timerID;
this_devp = &this->dev;
timer_foreach(set_this_dev);
interrupts();
ASSERT(this->dev != NULL);
}
void HardwareTimer::pause(void) {
timer_pause(this->dev);
}
void HardwareTimer::resume(void) {
timer_resume(this->dev);
}
uint32 HardwareTimer::getPrescaleFactor(void) {
return timer_get_prescaler(this->dev) + 1;
}
void HardwareTimer::setPrescaleFactor(uint32 factor) {
timer_set_prescaler(this->dev, (uint16)(factor - 1));
}
uint16 HardwareTimer::getOverflow() {
return timer_get_reload(this->dev);
}
void HardwareTimer::setOverflow(uint16 val) {
timer_set_reload(this->dev, val);
}
uint16 HardwareTimer::getCount(void) {
return timer_get_count(this->dev);
}
void HardwareTimer::setCount(uint16 val) {
uint16 ovf = this->getOverflow();
timer_set_count(this->dev, min(val, ovf));
}
#define MAX_RELOAD ((1 << 16) - 1)
uint16 HardwareTimer::setPeriod(uint32 microseconds) {
// Not the best way to handle this edge case?
if (!microseconds) {
this->setPrescaleFactor(1);
this->setOverflow(1);
return this->getOverflow();
}
uint32 period_cyc = microseconds * CYCLES_PER_MICROSECOND;
uint16 prescaler = (uint16)(period_cyc / MAX_RELOAD + 1);
uint16 overflow = (uint16)((period_cyc + (prescaler / 2)) / prescaler);
this->setPrescaleFactor(prescaler);
this->setOverflow(overflow);
return overflow;
}
void HardwareTimer::setMode(int channel, timer_mode mode) {
timer_set_mode(this->dev, (uint8)channel, (timer_mode)mode);
}
uint16 HardwareTimer::getCompare(int channel) {
return timer_get_compare(this->dev, (uint8)channel);
}
void HardwareTimer::setCompare(int channel, uint16 val) {
uint16 ovf = this->getOverflow();
timer_set_compare(this->dev, (uint8)channel, min(val, ovf));
}
void HardwareTimer::attachInterrupt(int channel, voidFuncPtr handler) {
timer_attach_interrupt(this->dev, (uint8)channel, handler);
}
void HardwareTimer::detachInterrupt(int channel) {
timer_detach_interrupt(this->dev, (uint8)channel);
}
void HardwareTimer::enableDMA(int channel) {
timer_dma_enable_req(this->dev, (uint8)channel);
}
void HardwareTimer::disableDMA(int channel) {
timer_dma_disable_req(this->dev, (uint8)channel);
}
void HardwareTimer::refresh(void) {
timer_generate_update(this->dev);
}
void HardwareTimer::setMasterModeTrGo(uint32_t mode) {
this->dev->regs.bas->CR2 &= ~TIMER_CR2_MMS;
this->dev->regs.bas->CR2 |= mode;
}
/* CARLOS Changes to add encoder mode.*/
//direction of movement. (to be better described).
uint8 HardwareTimer::getDirection(){
return get_direction(this->dev);
}
//set if the encoder will count edges on one, which or both channels.
void HardwareTimer::setEdgeCounting(uint32 counting) {
(dev->regs).gen->SMCR = counting;//TIMER_SMCR_SMS_ENCODER3; //choose encoder 3, counting on
}
uint8 HardwareTimer::getEdgeCounting() {
return (dev->regs).gen->SMCR;
}
//set the polarity of counting... not sure how interesting this is..
void HardwareTimer::setPolarity(){}
/* -- Deprecated predefined instances -------------------------------------- */
HardwareTimer Timer1(1);
HardwareTimer Timer2(2);
HardwareTimer Timer3(3);
HardwareTimer Timer4(4);
#ifdef STM32_HIGH_DENSITY
HardwareTimer Timer5(5);
HardwareTimer Timer6(6);
HardwareTimer Timer7(7);
HardwareTimer Timer8(8);
#endif

View File

@@ -1,383 +0,0 @@
/******************************************************************************
* The MIT License
*
* Copyright (c) 2010 Bryan Newbold.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*****************************************************************************/
/**
* @brief Wirish timer class.
*/
#ifndef _WIRISH_HARDWARETIMER_H_
#define _WIRISH_HARDWARETIMER_H_
// TODO [0.1.0] Remove deprecated pieces, pick a better API
#include <libmaple/timer.h>
/** Timer mode. */
typedef timer_mode TimerMode;
//CARLOS
//defines for the ENCODER mode.
/**
* @brief Interface to one of the 16-bit timer peripherals.
*/
class HardwareTimer {
private:
timer_dev *dev;
public:
/**
* @brief Construct a new HardwareTimer instance.
* @param timerNum number of the timer to control.
*/
HardwareTimer(uint8 timerNum);
/**
* @brief Stop the counter, without affecting its configuration.
*
* @see HardwareTimer::resume()
*/
void pause(void);
/**
* @brief Resume a paused timer, without affecting its configuration.
*
* The timer will resume counting and firing interrupts as
* appropriate.
*
* Note that there is some function call overhead associated with
* using this method, so using it in concert with
* HardwareTimer::pause() is not a robust way to align multiple
* timers to the same count value.
*
* @see HardwareTimer::pause()
*/
void resume(void);
/**
* @brief Get the timer's prescale factor.
* @return Timer prescaler, from 1 to 65,536.
* @see HardwareTimer::setPrescaleFactor()
*/
uint32 getPrescaleFactor();
/**
* @brief Set the timer's prescale factor.
*
* The new value won't take effect until the next time the counter
* overflows. You can force the counter to reset using
* HardwareTimer::refresh().
*
* @param factor The new prescale value to set, from 1 to 65,536.
* @see HardwareTimer::refresh()
*/
void setPrescaleFactor(uint32 factor);
/**
* @brief Get the timer overflow value.
* @see HardwareTimer::setOverflow()
*/
uint16 getOverflow();
/**
* @brief Set the timer overflow (or "reload") value.
*
* The new value won't take effect until the next time the counter
* overflows. You can force the counter to reset using
* HardwareTimer::refresh().
*
* @param val The new overflow value to set
* @see HardwareTimer::refresh()
*/
void setOverflow(uint16 val);
/**
* @brief Get the current timer count.
*
* @return The timer's current count value
*/
uint16 getCount(void);
/**
* @brief Set the current timer count.
*
* @param val The new count value to set. If this value exceeds
* the timer's overflow value, it is truncated to the
* overflow value.
*/
void setCount(uint16 val);
/**
* @brief Set the timer's period in microseconds.
*
* Configures the prescaler and overflow values to generate a timer
* reload with a period as close to the given number of
* microseconds as possible.
*
* @param microseconds The desired period of the timer. This must be
* greater than zero.
* @return The new overflow value.
*/
uint16 setPeriod(uint32 microseconds);
/**
* @brief Configure a timer channel's mode.
* @param channel Timer channel, from 1 to 4
* @param mode Mode to set
*/
void setMode(int channel, timer_mode mode);
/**
* @brief Get the compare value for the given channel.
* @see HardwareTimer::setCompare()
*/
uint16 getCompare(int channel);
/**
* @brief Set the compare value for the given channel.
*
* @param channel the channel whose compare to set, from 1 to 4.
* @param compare The compare value to set. If greater than this
* timer's overflow value, it will be truncated to
* the overflow value.
*
* @see timer_mode
* @see HardwareTimer::setMode()
* @see HardwareTimer::attachInterrupt()
*/
void setCompare(int channel, uint16 compare);
/**
* @brief Attach an interrupt handler to the given channel.
*
* This interrupt handler will be called when the timer's counter
* reaches the given channel compare value.
*
* @param channel the channel to attach the ISR to, from 0 to 4.
* Channel 0 is for overflow interrupt (update interrupt).
* @param handler The ISR to attach to the given channel.
* @see voidFuncPtr
*/
void attachInterrupt(int channel, voidFuncPtr handler);
/**
* @brief Remove the interrupt handler attached to the given
* channel, if any.
*
* The handler will no longer be called by this timer.
*
* @param channel the channel whose interrupt to detach, from 0 to 4.
* Channel 0 is for overflow interrupt (update interrupt).
* @see HardwareTimer::attachInterrupt()
*/
void detachInterrupt(int channel);
/**
* @brief Reset the counter, and update the prescaler and overflow
* values.
*
* This will reset the counter to 0 in upcounting mode (the
* default). It will also update the timer's prescaler and
* overflow, if you have set them up to be changed using
* HardwareTimer::setPrescaleFactor() or
* HardwareTimer::setOverflow().
*
* @see HardwareTimer::setPrescaleFactor()
* @see HardwareTimer::setOverflow()
*/
void refresh(void);
// SYFRE
/**
* @brief Set the Master mode TRGO signal
* These bits allow to select the information to be sent in master mode to slave timers for
* synchronization (TRGO).
* mode:
* TIMER_CR2_MMS_RESET
* TIMER_CR2_MMS_ENABLE
* TIMER_CR2_MMS_UPDATE
* TIMER_CR2_MMS_COMPARE_PULSE
* TIMER_CR2_MMS_COMPARE_OC1REF
* TIMER_CR2_MMS_COMPARE_OC2REF
* TIMER_CR2_MMS_COMPARE_OC3REF
* TIMER_CR2_MMS_COMPARE_OC4REF
*/
void setMasterModeTrGo(uint32_t mode);
//CARLOS.
/*
added these functions to make sense for the encoder mode.
*/
//direction of movement. (to be better described).
uint8 getDirection();
//set if the encoder will count edges on one, which or both channels.
void setEdgeCounting(uint32 counting);
uint8 getEdgeCounting(); //not sure if needed.
//set the polarity of counting... not sure how interesting this is..
void setPolarity();
//add the filtering definition for the input channel.
/* Escape hatch */
/**
* @brief Enable/disable DMA request for the input channel.
*/
void enableDMA(int channel);
void disableDMA(int channel);
/**
* @brief Get a pointer to the underlying libmaple timer_dev for
* this HardwareTimer instance.
*/
timer_dev* c_dev(void) { return this->dev; }
/* -- The rest of this file is deprecated. --------------------------------- */
/** @brief Deprecated; use setMode(channel, mode) instead. */
void setChannelMode(int channel, timer_mode mode) {
setMode(channel, mode);
}
/** @brief Deprecated; use setMode(TIMER_CH1, mode) instead. */
void setChannel1Mode(timer_mode mode) { setMode(TIMER_CH1, mode); }
/** @brief Deprecated; use setMode(TIMER_CH2, mode) instead. */
void setChannel2Mode(timer_mode mode) { setMode(TIMER_CH2, mode); }
/** @brief Deprecated; use setMode(TIMER_CH3, mode) instead. */
void setChannel3Mode(timer_mode mode) { setMode(TIMER_CH3, mode); }
/** @brief Deprecated; use setMode(TIMER_CH4, mode) instead. */
void setChannel4Mode(timer_mode mode) { setMode(TIMER_CH4, mode); }
/** @brief Deprecated; use return getCompare(TIMER_CH1) instead. */
uint16 getCompare1() { return getCompare(TIMER_CH1); }
/** @brief Deprecated; use return getCompare(TIMER_CH2) instead. */
uint16 getCompare2() { return getCompare(TIMER_CH2); }
/** @brief Deprecated; use return getCompare(TIMER_CH3) instead. */
uint16 getCompare3() { return getCompare(TIMER_CH3); }
/** @brief Deprecated; use return getCompare(TIMER_CH4) instead. */
uint16 getCompare4() { return getCompare(TIMER_CH4); }
/** @brief Deprecated; use setCompare(TIMER_CH1, compare) instead. */
void setCompare1(uint16 compare) { setCompare(TIMER_CH1, compare); }
/** @brief Deprecated; use setCompare(TIMER_CH2, compare) instead. */
void setCompare2(uint16 compare) { setCompare(TIMER_CH2, compare); }
/** @brief Deprecated; use setCompare(TIMER_CH3, compare) instead. */
void setCompare3(uint16 compare) { setCompare(TIMER_CH3, compare); }
/** @brief Deprecated; use setCompare(TIMER_CH4, compare) instead. */
void setCompare4(uint16 compare) { setCompare(TIMER_CH4, compare); }
/** @brief Deprecated; use attachInterrupt(TIMER_CH1, handler) instead. */
void attachCompare1Interrupt(voidFuncPtr handler) {
attachInterrupt(TIMER_CH1, handler);
}
/** @brief Deprecated; use attachInterrupt(TIMER_CH2, handler) instead. */
void attachCompare2Interrupt(voidFuncPtr handler) {
attachInterrupt(TIMER_CH2, handler);
}
/** @brief Deprecated; use attachInterrupt(TIMER_CH3, handler) instead. */
void attachCompare3Interrupt(voidFuncPtr handler) {
attachInterrupt(TIMER_CH3, handler);
}
/** @brief Deprecated; use attachInterrupt(TIMER_CH4, handler) instead. */
void attachCompare4Interrupt(voidFuncPtr handler) {
attachInterrupt(TIMER_CH4, handler);
}
/** @brief Deprecated; use detachInterrupt(TIMER_CH1) instead. */
void detachCompare1Interrupt(void) { detachInterrupt(TIMER_CH1); }
/** @brief Deprecated; use detachInterrupt(TIMER_CH2) instead. */
void detachCompare2Interrupt(void) { detachInterrupt(TIMER_CH2); }
/** @brief Deprecated; use detachInterrupt(TIMER_CH3) instead. */
void detachCompare3Interrupt(void) { detachInterrupt(TIMER_CH3); }
/** @brief Deprecated; use detachInterrupt(TIMER_CH4) instead. */
void detachCompare4Interrupt(void) { detachInterrupt(TIMER_CH4); }
/** @brief Deprecated; use refresh() instead. */
void generateUpdate(void) { refresh(); }
};
/** @brief Deprecated; use TIMER_OUTPUT_COMPARE instead. */
#define TIMER_OUTPUTCOMPARE TIMER_OUTPUT_COMPARE
/**
* @brief Deprecated.
*
* Pre-instantiated timer.
*/
extern HardwareTimer Timer1;
/**
* @brief Deprecated.
*
* Pre-instantiated timer.
*/
extern HardwareTimer Timer2;
/**
* @brief Deprecated.
*
* Pre-instantiated timer.
*/
extern HardwareTimer Timer3;
/**
* @brief Deprecated.
*
* Pre-instantiated timer.
*/
extern HardwareTimer Timer4;
#if (STM32_MCU_SERIES == STM32_SERIES_F1) && defined(STM32_HIGH_DENSITY)
/**
* @brief Deprecated.
*
* Pre-instantiated timer.
*/
extern HardwareTimer Timer5;
/**
* @brief Deprecated.
*
* Pre-instantiated timer.
*/
extern HardwareTimer Timer8;
#endif
#endif

View File

@@ -1,129 +0,0 @@
/*
IPAddress.cpp - Base class that provides IPAddress
Copyright (c) 2011 Adrian McEwen. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <Arduino.h>
#include <IPAddress.h>
#include <Print.h>
IPAddress::IPAddress()
{
_address.dword = 0;
}
IPAddress::IPAddress(uint8_t first_octet, uint8_t second_octet, uint8_t third_octet, uint8_t fourth_octet)
{
_address.bytes[0] = first_octet;
_address.bytes[1] = second_octet;
_address.bytes[2] = third_octet;
_address.bytes[3] = fourth_octet;
}
IPAddress::IPAddress(uint32_t address)
{
_address.dword = address;
}
IPAddress::IPAddress(const uint8_t *address)
{
memcpy(_address.bytes, address, sizeof(_address.bytes));
}
bool IPAddress::fromString(const char *address)
{
// TODO: add support for "a", "a.b", "a.b.c" formats
uint16_t acc = 0; // Accumulator
uint8_t dots = 0;
while (*address)
{
char c = *address++;
if (c >= '0' && c <= '9')
{
acc = acc * 10 + (c - '0');
if (acc > 255) {
// Value out of [0..255] range
return false;
}
}
else if (c == '.')
{
if (dots == 3) {
// Too much dots (there must be 3 dots)
return false;
}
_address.bytes[dots++] = acc;
acc = 0;
}
else
{
// Invalid char
return false;
}
}
if (dots != 3) {
// Too few dots (there must be 3 dots)
return false;
}
_address.bytes[3] = acc;
return true;
}
IPAddress& IPAddress::operator=(const uint8_t *address)
{
memcpy(_address.bytes, address, sizeof(_address.bytes));
return *this;
}
IPAddress& IPAddress::operator=(uint32_t address)
{
_address.dword = address;
return *this;
}
bool IPAddress::operator==(const uint8_t* addr) const
{
return memcmp(addr, _address.bytes, sizeof(_address.bytes)) == 0;
}
size_t IPAddress::printTo(Print& p) const
{
size_t n = 0;
for (int i =0; i < 3; i++)
{
n += p.print(_address.bytes[i], DEC);
n += p.print('.');
}
n += p.print(_address.bytes[3], DEC);
return n;
}
String IPAddress::toString()
{
String str = String(_address.bytes[0]);
str += ".";
str += String(_address.bytes[1]);
str += ".";
str += String(_address.bytes[2]);
str += ".";
str += String(_address.bytes[3]);
return str;
}

View File

@@ -1,80 +0,0 @@
/*
IPAddress.h - Base class that provides IPAddress
Copyright (c) 2011 Adrian McEwen. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef IPAddress_h
#define IPAddress_h
#include <stdint.h>
#include <WString.h>
#include <Printable.h>
// A class to make it easier to handle and pass around IP addresses
class IPAddress : public Printable {
private:
union {
uint8_t bytes[4]; // IPv4 address
uint32_t dword;
} _address;
// Access the raw byte array containing the address. Because this returns a pointer
// to the internal structure rather than a copy of the address this function should only
// be used when you know that the usage of the returned uint8_t* will be transient and not
// stored.
uint8_t* raw_address() { return _address.bytes; };
public:
// Constructors
IPAddress();
IPAddress(uint8_t first_octet, uint8_t second_octet, uint8_t third_octet, uint8_t fourth_octet);
IPAddress(uint32_t address);
IPAddress(const uint8_t *address);
bool fromString(const char *address);
bool fromString(const String &address) { return fromString(address.c_str()); }
// Overloaded cast operator to allow IPAddress objects to be used where a pointer
// to a four-byte uint8_t array is expected
operator uint32_t() const { return _address.dword; };
bool operator==(const IPAddress& addr) const { return _address.dword == addr._address.dword; };
bool operator==(const uint8_t* addr) const;
// Overloaded index operator to allow getting and setting individual octets of the address
uint8_t operator[](int index) const { return _address.bytes[index]; };
uint8_t& operator[](int index) { return _address.bytes[index]; };
// Overloaded copy operators to allow initialisation of IPAddress objects from other types
IPAddress& operator=(const uint8_t *address);
IPAddress& operator=(uint32_t address);
virtual size_t printTo(Print& p) const;
String toString();
friend class EthernetClass;
friend class UDP;
friend class Client;
friend class Server;
friend class DhcpClass;
friend class DNSClient;
};
const IPAddress INADDR_NONE(0,0,0,0);
#endif

View File

@@ -1,322 +0,0 @@
/*
* Print.cpp - Base class that provides print() and println()
* Copyright (c) 2008 David A. Mellis. All right reserved.
* Copyright (c) 2011 LeafLabs, LLC.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
* Modified 23 November 2006 by David A. Mellis
* Modified 12 April 2011 by Marti Bolivar <mbolivar@leaflabs.com>
*/
#include "Print.h"
#include "wirish_math.h"
#include "limits.h"
#ifndef LLONG_MAX
/*
* Note:
*
* At time of writing (12 April 2011), the limits.h that came with the
* newlib we distributed didn't include LLONG_MAX. Because we're
* staying away from using templates (see /notes/coding_standard.rst,
* "Language Features and Compiler Extensions"), this value was
* copy-pasted from a println() of the value
*
* std::numeric_limits<long long>::max().
*/
#define LLONG_MAX 9223372036854775807LL
#endif
/*
* Public methods
*/
size_t Print::write(const char *str) {
size_t n = 0;
while (*str) {
write(*str++);
n++;
}
return n;
}
size_t Print::write(const void *buffer, uint32 size) {
size_t n = 0;
uint8 *ch = (uint8*)buffer;
while (size--) {
write(*ch++);
n++;
}
return n;
}
size_t Print::print(uint8 b, int base) {
return print((uint64)b, base);
}
size_t Print::print(const String &s)
{
return write(s.c_str(), s.length());
}
size_t Print::print(char c) {
return write(c);
}
size_t Print::print(const char str[]) {
return write(str);
}
size_t Print::print(int n, int base) {
return print((long long)n, base);
}
size_t Print::print(unsigned int n, int base) {
return print((unsigned long long)n, base);
}
size_t Print::print(long n, int base) {
return print((long long)n, base);
}
size_t Print::print(unsigned long n, int base) {
return print((unsigned long long)n, base);
}
size_t Print::print(long long n, int base) {
if (n < 0) {
print('-');
n = -n;
}
return printNumber(n, base);
}
size_t Print::print(unsigned long long n, int base) {
return printNumber(n, base);
}
size_t Print::print(double n, int digits) {
return printFloat(n, digits);
}
size_t Print::print(const __FlashStringHelper *ifsh)
{
return print(reinterpret_cast<const char *>(ifsh));
}
size_t Print::print(const Printable& x)
{
return x.printTo(*this);
}
size_t Print::println(void)
{
size_t n = print('\r');
n += print('\n');
return n;
}
size_t Print::println(const String &s)
{
size_t n = print(s);
n += println();
return n;
}
size_t Print::println(char c) {
size_t n = print(c);
n += println();
return n;
}
size_t Print::println(const char c[]) {
size_t n = print(c);
n += println();
return n;
}
size_t Print::println(uint8 b, int base) {
size_t n = print(b, base);
n += println();
return n;
}
size_t Print::println(int n, int base) {
size_t s = print(n, base);
s += println();
return s;
}
size_t Print::println(unsigned int n, int base) {
size_t s = print(n, base);
s += println();
return s;
}
size_t Print::println(long n, int base) {
size_t s = print((long long)n, base);
s += println();
return s;
}
size_t Print::println(unsigned long n, int base) {
size_t s = print((unsigned long long)n, base);
s += println();
return s;
}
size_t Print::println(long long n, int base) {
size_t s = print(n, base);
s += println();
return s;
}
size_t Print::println(unsigned long long n, int base) {
size_t s = print(n, base);
s += println();
return s;
}
size_t Print::println(double n, int digits) {
size_t s = print(n, digits);
s += println();
return s;
}
size_t Print::println(const __FlashStringHelper *ifsh)
{
size_t n = print(ifsh);
n += println();
return n;
}
size_t Print::println(const Printable& x)
{
size_t n = print(x);
n += println();
return n;
}
#ifdef SUPPORTS_PRINTF
#include <stdio.h>
#include <stdarg.h>
// Work in progress to support printf.
// Need to implement stream FILE to write individual chars to chosen serial port
int Print::printf (__const char *__restrict __format, ...)
{
FILE *__restrict __stream;
int ret_status = 0;
va_list args;
va_start(args,__format);
ret_status = vfprintf(__stream, __format, args);
va_end(args);
return ret_status;
}
#endif
/*
* Private methods
*/
size_t Print::printNumber(unsigned long long n, uint8 base) {
unsigned char buf[CHAR_BIT * sizeof(long long)];
unsigned long i = 0;
size_t s=0;
if (n == 0) {
print('0');
return 1;
}
while (n > 0) {
buf[i++] = n % base;
n /= base;
}
for (; i > 0; i--) {
s += print((char)(buf[i - 1] < 10 ?
'0' + buf[i - 1] :
'A' + buf[i - 1] - 10));
}
return s;
}
/* According to snprintf(),
*
* nextafter((double)numeric_limits<long long>::max(), 0.0) ~= 9.22337e+18
*
* This slightly smaller value was picked semi-arbitrarily. */
#define LARGE_DOUBLE_TRESHOLD (9.1e18)
/* THIS FUNCTION SHOULDN'T BE USED IF YOU NEED ACCURATE RESULTS.
*
* This implementation is meant to be simple and not occupy too much
* code size. However, printing floating point values accurately is a
* subtle task, best left to a well-tested library function.
*
* See Steele and White 2003 for more details:
*
* http://kurtstephens.com/files/p372-steele.pdf
*/
size_t Print::printFloat(double number, uint8 digits) {
size_t s=0;
// Hackish fail-fast behavior for large-magnitude doubles
if (abs(number) >= LARGE_DOUBLE_TRESHOLD) {
if (number < 0.0) {
s=print('-');
}
s+=print("<large double>");
return s;
}
// Handle negative numbers
if (number < 0.0) {
s+=print('-');
number = -number;
}
// Simplistic rounding strategy so that e.g. print(1.999, 2)
// prints as "2.00"
double rounding = 0.5;
for (uint8 i = 0; i < digits; i++) {
rounding /= 10.0;
}
number += rounding;
// Extract the integer part of the number and print it
long long int_part = (long long)number;
double remainder = number - int_part;
s+=print(int_part);
// Print the decimal point, but only if there are digits beyond
if (digits > 0) {
s+=print(".");
}
// Extract digits from the remainder one at a time
while (digits-- > 0) {
remainder *= 10.0;
int to_print = (int)remainder;
s+=print(to_print);
remainder -= to_print;
}
return s;
}

View File

@@ -1,88 +0,0 @@
/*
* Print.h - Base class that provides print() and println()
* Copyright (c) 2008 David A. Mellis. All right reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* Modified 12 April 2011 by Marti Bolivar <mbolivar@leaflabs.com>
*/
#ifndef _WIRISH_PRINT_H_
#define _WIRISH_PRINT_H_
#include <libmaple/libmaple_types.h>
#include "WString.h"
#include "Printable.h"
enum {
BIN = 2,
OCT = 8,
DEC = 10,
HEX = 16
};
class Print {
public:
virtual size_t write(uint8 ch) = 0;
virtual size_t write(const char *str);
virtual size_t write(const void *buf, uint32 len);
size_t print(const String &);
size_t print(char);
size_t print(const char[]);
size_t print(uint8, int=DEC);
size_t print(int, int=DEC);
size_t print(unsigned int, int=DEC);
size_t print(long, int=DEC);
size_t print(unsigned long, int=DEC);
size_t print(long long, int=DEC);
size_t print(unsigned long long, int=DEC);
size_t print(double, int=2);
size_t print(const __FlashStringHelper *);
size_t print(const Printable&);
size_t println(void);
size_t println(const String &s);
size_t println(char);
size_t println(const char[]);
size_t println(uint8, int=DEC);
size_t println(int, int=DEC);
size_t println(unsigned int, int=DEC);
size_t println(long, int=DEC);
size_t println(unsigned long, int=DEC);
size_t println(long long, int=DEC);
size_t println(unsigned long long, int=DEC);
size_t println(double, int=2);
size_t println(const __FlashStringHelper *);
size_t println(const Printable&);
#ifdef SUPPORTS_PRINTF
// Roger Clark. Work in progress to add printf support
int printf(const char * format, ...);
#endif
Print() : write_error(0) {}
int getWriteError() { return write_error; }
void clearWriteError() { setWriteError(0); }
protected:
void setWriteError(int err = 1) { write_error = err; }
private:
int write_error;
size_t printNumber(unsigned long long, uint8);
size_t printFloat(double, uint8);
};
#endif

View File

@@ -1,40 +0,0 @@
/*
Printable.h - Interface class that allows printing of complex types
Copyright (c) 2011 Adrian McEwen. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef Printable_h
#define Printable_h
#include <stdlib.h>
class Print;
/** The Printable class provides a way for new classes to allow themselves to be printed.
By deriving from Printable and implementing the printTo method, it will then be possible
for users to print out instances of this class by passing them into the usual
Print::print and Print::println methods.
*/
class Printable
{
public:
virtual size_t printTo(Print& p) const = 0;
};
#endif

View File

@@ -1,30 +0,0 @@
/*
Server.h - Base class that provides Server
Copyright (c) 2011 Adrian McEwen. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef server_h
#define server_h
#include "Print.h"
class Server : public Print {
public:
virtual void begin() =0;
};
#endif

View File

@@ -1,335 +0,0 @@
/*
Stream.cpp - adds parsing methods to Stream class
Copyright (c) 2008 David A. Mellis. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Created July 2011
parsing functions based on TextFinder library by Michael Margolis
*/
#include "Arduino.h"
#include "Stream.h"
#define PARSE_TIMEOUT 1000 // default number of milli-seconds to wait
#define NO_SKIP_CHAR 1 // a magic char not found in a valid ASCII numeric field
// private method to read stream with timeout
int Stream::timedRead()
{
int c;
_startMillis = millis();
do {
c = read();
if (c >= 0) return c;
} while(millis() - _startMillis < _timeout);
return -1; // -1 indicates timeout
}
// private method to peek stream with timeout
int Stream::timedPeek()
{
int c;
_startMillis = millis();
do {
c = peek();
if (c >= 0) return c;
} while(millis() - _startMillis < _timeout);
return -1; // -1 indicates timeout
}
// returns peek of the next digit in the stream or -1 if timeout
// discards non-numeric characters
int Stream::peekNextDigit()
{
int c;
while (1) {
c = timedPeek();
if (c < 0) return c; // timeout
if (c == '-') return c;
if (c >= '0' && c <= '9') return c;
read(); // discard non-numeric
}
}
// Public Methods
//////////////////////////////////////////////////////////////
void Stream::setTimeout(unsigned long timeout) // sets the maximum number of milliseconds to wait
{
_timeout = timeout;
}
// find returns true if the target string is found
bool Stream::find(char *target)
{
return findUntil(target, (char*)"");
}
// reads data from the stream until the target string of given length is found
// returns true if target string is found, false if timed out
bool Stream::find(char *target, size_t length)
{
return findUntil(target, length, NULL, 0);
}
// as find but search ends if the terminator string is found
bool Stream::findUntil(char *target, char *terminator)
{
return findUntil(target, strlen(target), terminator, strlen(terminator));
}
// reads data from the stream until the target string of the given length is found
// search terminated if the terminator string is found
// returns true if target string is found, false if terminated or timed out
bool Stream::findUntil(char *target, size_t targetLen, char *terminator, size_t termLen)
{
size_t index = 0; // maximum target string length is 64k bytes!
size_t termIndex = 0;
int c;
if( *target == 0)
return true; // return true if target is a null string
while( (c = timedRead()) > 0){
if(c != target[index])
index = 0; // reset index if any char does not match
if( c == target[index]){
//////Serial.print("found "); Serial.write(c); Serial.print("index now"); Serial.println(index+1);
if(++index >= targetLen){ // return true if all chars in the target match
return true;
}
}
if(termLen > 0 && c == terminator[termIndex]){
if(++termIndex >= termLen)
return false; // return false if terminate string found before target string
}
else
termIndex = 0;
}
return false;
}
// returns the first valid (long) integer value from the current position.
// initial characters that are not digits (or the minus sign) are skipped
// function is terminated by the first character that is not a digit.
long Stream::parseInt()
{
return parseInt(NO_SKIP_CHAR); // terminate on first non-digit character (or timeout)
}
// as above but a given skipChar is ignored
// this allows format characters (typically commas) in values to be ignored
long Stream::parseInt(char skipChar)
{
boolean isNegative = false;
long value = 0;
int c;
c = peekNextDigit();
// ignore non numeric leading characters
if(c < 0)
return 0; // zero returned if timeout
do{
if(c == skipChar)
; // ignore this charactor
else if(c == '-')
isNegative = true;
else if(c >= '0' && c <= '9') // is c a digit?
value = value * 10 + c - '0';
read(); // consume the character we got with peek
c = timedPeek();
}
while( (c >= '0' && c <= '9') || c == skipChar );
if(isNegative)
value = -value;
return value;
}
// as parseInt but returns a floating point value
float Stream::parseFloat()
{
return parseFloat(NO_SKIP_CHAR);
}
// as above but the given skipChar is ignored
// this allows format characters (typically commas) in values to be ignored
float Stream::parseFloat(char skipChar){
boolean isNegative = false;
boolean isFraction = false;
long value = 0;
int c;
float fraction = 1.0;
c = peekNextDigit();
// ignore non numeric leading characters
if(c < 0)
return 0; // zero returned if timeout
do{
if(c == skipChar)
; // ignore
else if(c == '-')
isNegative = true;
else if (c == '.')
isFraction = true;
else if(c >= '0' && c <= '9') { // is c a digit?
value = value * 10 + c - '0';
if(isFraction)
fraction *= 0.1;
}
read(); // consume the character we got with peek
c = timedPeek();
}
while( (c >= '0' && c <= '9') || c == '.' || c == skipChar );
if(isNegative)
value = -value;
if(isFraction)
return value * fraction;
else
return value;
}
// read characters from stream into buffer
// terminates if length characters have been read, or timeout (see setTimeout)
// returns the number of characters placed in the buffer
// the buffer is NOT null terminated.
//
size_t Stream::readBytes(char *buffer, size_t length)
{
size_t count = 0;
while (count < length) {
int c = timedRead();
if (c < 0) break;
*buffer++ = (char)c;
count++;
}
return count;
}
// as readBytes with terminator character
// terminates if length characters have been read, timeout, or if the terminator character detected
// returns the number of characters placed in the buffer (0 means no valid data found)
size_t Stream::readBytesUntil(char terminator, char *buffer, size_t length)
{
if (length < 1) return 0;
size_t index = 0;
while (index < length) {
int c = timedRead();
if (c < 0 || c == terminator) break;
*buffer++ = (char)c;
index++;
}
return index; // return number of characters, not including null terminator
}
String Stream::readString()
{
String ret;
int c = timedRead();
while (c >= 0)
{
ret += (char)c;
c = timedRead();
}
return ret;
}
String Stream::readStringUntil(char terminator)
{
String ret;
int c = timedRead();
while (c >= 0 && c != terminator)
{
ret += (char)c;
c = timedRead();
}
return ret;
}
int Stream::findMulti( struct Stream::MultiTarget *targets, int tCount) {
// any zero length target string automatically matches and would make
// a mess of the rest of the algorithm.
for (struct MultiTarget *t = targets; t < targets+tCount; ++t) {
if (t->len <= 0)
return t - targets;
}
while (1) {
int c = timedRead();
if (c < 0)
return -1;
for (struct MultiTarget *t = targets; t < targets+tCount; ++t) {
// the simple case is if we match, deal with that first.
if (c == t->str[t->index]) {
if (++t->index == t->len)
return t - targets;
else
continue;
}
// if not we need to walk back and see if we could have matched further
// down the stream (ie '1112' doesn't match the first position in '11112'
// but it will match the second position so we can't just reset the current
// index to 0 when we find a mismatch.
if (t->index == 0)
continue;
int origIndex = t->index;
do {
--t->index;
// first check if current char works against the new current index
if (c != t->str[t->index])
continue;
// if it's the only char then we're good, nothing more to check
if (t->index == 0) {
t->index++;
break;
}
// otherwise we need to check the rest of the found string
int diff = origIndex - t->index;
size_t i;
for (i = 0; i < t->index; ++i) {
if (t->str[i] != t->str[i + diff])
break;
}
// if we successfully got through the previous loop then our current
// index is good.
if (i == t->index) {
t->index++;
break;
}
// otherwise we just try the next index
} while (t->index);
}
}
// unreachable
return -1;
}

View File

@@ -1,115 +0,0 @@
/*
Stream.h - base class for character-based streams.
Copyright (c) 2010 David A. Mellis. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
parsing functions based on TextFinder library by Michael Margolis
*/
#ifndef Stream_h
#define Stream_h
#include <inttypes.h>
#include "Print.h"
// compatability macros for testing
/*
#define getInt() parseInt()
#define getInt(skipChar) parseInt(skipchar)
#define getFloat() parseFloat()
#define getFloat(skipChar) parseFloat(skipChar)
#define getString( pre_string, post_string, buffer, length)
readBytesBetween( pre_string, terminator, buffer, length)
*/
class Stream : public Print
{
protected:
unsigned long _timeout; // number of milliseconds to wait for the next char before aborting timed read
unsigned long _startMillis; // used for timeout measurement
int timedRead(); // private method to read stream with timeout
int timedPeek(); // private method to peek stream with timeout
int peekNextDigit(); // returns the next numeric digit in the stream or -1 if timeout
public:
virtual int available() = 0;
virtual int read() = 0;
virtual int peek() = 0;
virtual void flush() = 0;
Stream() {_timeout=1000;}
// parsing methods
void setTimeout(unsigned long timeout); // sets maximum milliseconds to wait for stream data, default is 1 second
unsigned long getTimeout(void) { return _timeout; }
bool find(char *target); // reads data from the stream until the target string is found
bool find(uint8_t *target) { return find ((char *)target); }
// returns true if target string is found, false if timed out (see setTimeout)
bool find(char *target, size_t length); // reads data from the stream until the target string of given length is found
bool find(uint8_t *target, size_t length) { return find ((char *)target, length); }
// returns true if target string is found, false if timed out
bool find(char target) { return find (&target, 1); }
bool findUntil(char *target, char *terminator); // as find but search ends if the terminator string is found
bool findUntil(uint8_t *target, char *terminator) { return findUntil((char *)target, terminator); }
bool findUntil(char *target, size_t targetLen, char *terminate, size_t termLen); // as above but search ends if the terminate string is found
bool findUntil(uint8_t *target, size_t targetLen, char *terminate, size_t termLen) {return findUntil((char *)target, targetLen, terminate, termLen); }
long parseInt(); // returns the first valid (long) integer value from the current position.
// initial characters that are not digits (or the minus sign) are skipped
// integer is terminated by the first character that is not a digit.
float parseFloat(); // float version of parseInt
size_t readBytes( char *buffer, size_t length); // read chars from stream into buffer
size_t readBytes( uint8_t *buffer, size_t length) { return readBytes((char *)buffer, length); }
// terminates if length characters have been read or timeout (see setTimeout)
// returns the number of characters placed in the buffer (0 means no valid data found)
size_t readBytesUntil( char terminator, char *buffer, size_t length); // as readBytes with terminator character
size_t readBytesUntil( char terminator, uint8_t *buffer, size_t length) { return readBytesUntil(terminator, (char *)buffer, length); }
// terminates if length characters have been read, timeout, or if the terminator character detected
// returns the number of characters placed in the buffer (0 means no valid data found)
// Arduino String functions to be added here
String readString();
String readStringUntil(char terminator);
protected:
long parseInt(char skipChar); // as above but the given skipChar is ignored
// as above but the given skipChar is ignored
// this allows format characters (typically commas) in values to be ignored
float parseFloat(char skipChar); // as above but the given skipChar is ignored
struct MultiTarget {
const char *str; // string you're searching for
size_t len; // length of string you're searching for
size_t index; // index used by the search routine.
};
// This allows you to search for an arbitrary number of strings.
// Returns index of the target that is found first or -1 if timeout occurs.
int findMulti(struct MultiTarget *targets, int tCount);
};
#endif

View File

@@ -1,88 +0,0 @@
/*
* Udp.cpp: Library to send/receive UDP packets.
*
* NOTE: UDP is fast, but has some important limitations (thanks to Warren Gray for mentioning these)
* 1) UDP does not guarantee the order in which assembled UDP packets are received. This
* might not happen often in practice, but in larger network topologies, a UDP
* packet can be received out of sequence.
* 2) UDP does not guard against lost packets - so packets *can* disappear without the sender being
* aware of it. Again, this may not be a concern in practice on small local networks.
* For more information, see http://www.cafeaulait.org/course/week12/35.html
*
* MIT License:
* Copyright (c) 2008 Bjoern Hartmann
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* bjoern@cs.stanford.edu 12/30/2008
*/
#ifndef udp_h
#define udp_h
#include <Stream.h>
#include <IPAddress.h>
class UDP : public Stream {
public:
virtual uint8_t begin(uint16_t) =0; // initialize, start listening on specified port. Returns 1 if successful, 0 if there are no sockets available to use
virtual void stop() =0; // Finish with the UDP socket
// Sending UDP packets
// Start building up a packet to send to the remote host specific in ip and port
// Returns 1 if successful, 0 if there was a problem with the supplied IP address or port
virtual int beginPacket(IPAddress ip, uint16_t port) =0;
// Start building up a packet to send to the remote host specific in host and port
// Returns 1 if successful, 0 if there was a problem resolving the hostname or port
virtual int beginPacket(const char *host, uint16_t port) =0;
// Finish off this packet and send it
// Returns 1 if the packet was sent successfully, 0 if there was an error
virtual int endPacket() =0;
// Write a single byte into the packet
virtual size_t write(uint8_t) =0;
// Write size bytes from buffer into the packet
virtual size_t write(const uint8_t *buffer, size_t size) =0;
// Start processing the next available incoming packet
// Returns the size of the packet in bytes, or 0 if no packets are available
virtual int parsePacket() =0;
// Number of bytes remaining in the current packet
virtual int available() =0;
// Read a single byte from the current packet
virtual int read() =0;
// Read up to len bytes from the current packet and place them into buffer
// Returns the number of bytes read, or 0 if none are available
virtual int read(unsigned char* buffer, size_t len) =0;
// Read up to len characters from the current packet and place them into buffer
// Returns the number of characters read, or 0 if none are available
virtual int read(char* buffer, size_t len) =0;
// Return the next byte from the current packet without moving on to the next byte
virtual int peek() =0;
virtual void flush() =0; // Finish reading the current packet
// Return the IP address of the host who sent the current incoming packet
virtual IPAddress remoteIP() =0;
// Return the port of the host who sent the current incoming packet
virtual uint16_t remotePort() =0;
protected:
uint8_t* rawIPAddress(IPAddress& addr) { return addr.raw_address(); };
};
#endif

View File

@@ -1,180 +0,0 @@
/*
WCharacter.h - Character utility functions for Wiring & Arduino
Copyright (c) 2010 Hernando Barragan. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef Character_h
#define Character_h
#include <ctype.h>
#ifdef __cplusplus
extern "C" {
#endif
// WCharacter.h prototypes
#if defined ( __GNUC__ )
inline boolean isAlphaNumeric(int c) __attribute__((always_inline));
inline boolean isAlpha(int c) __attribute__((always_inline));
inline boolean isAscii(int c) __attribute__((always_inline));
inline boolean isWhitespace(int c) __attribute__((always_inline));
inline boolean isControl(int c) __attribute__((always_inline));
inline boolean isDigit(int c) __attribute__((always_inline));
inline boolean isGraph(int c) __attribute__((always_inline));
inline boolean isLowerCase(int c) __attribute__((always_inline));
inline boolean isPrintable(int c) __attribute__((always_inline));
inline boolean isPunct(int c) __attribute__((always_inline));
inline boolean isSpace(int c) __attribute__((always_inline));
inline boolean isUpperCase(int c) __attribute__((always_inline));
inline boolean isHexadecimalDigit(int c) __attribute__((always_inline));
inline int toAscii(int c) __attribute__((always_inline));
inline int toLowerCase(int c) __attribute__((always_inline));
inline int toUpperCase(int c)__attribute__((always_inline));
#elif defined ( __ICCARM__ )
#endif
// Checks for an alphanumeric character.
// It is equivalent to (isalpha(c) || isdigit(c)).
inline boolean isAlphaNumeric(int c)
{
return ( isalnum(c) == 0 ? false : true);
}
// Checks for an alphabetic character.
// It is equivalent to (isupper(c) || islower(c)).
inline boolean isAlpha(int c)
{
return ( isalpha(c) == 0 ? false : true);
}
// Checks whether c is a 7-bit unsigned char value
// that fits into the ASCII character set.
inline boolean isAscii(int c)
{
/* return ( isascii(c) == 0 ? false : true); */
return ( (c & ~0x7f) != 0 ? false : true);
}
// Checks for a blank character, that is, a space or a tab.
inline boolean isWhitespace(int c)
{
return ( isblank (c) == 0 ? false : true);
}
// Checks for a control character.
inline boolean isControl(int c)
{
return ( iscntrl (c) == 0 ? false : true);
}
// Checks for a digit (0 through 9).
inline boolean isDigit(int c)
{
return ( isdigit (c) == 0 ? false : true);
}
// Checks for any printable character except space.
inline boolean isGraph(int c)
{
return ( isgraph (c) == 0 ? false : true);
}
// Checks for a lower-case character.
inline boolean isLowerCase(int c)
{
return (islower (c) == 0 ? false : true);
}
// Checks for any printable character including space.
inline boolean isPrintable(int c)
{
return ( isprint (c) == 0 ? false : true);
}
// Checks for any printable character which is not a space
// or an alphanumeric character.
inline boolean isPunct(int c)
{
return ( ispunct (c) == 0 ? false : true);
}
// Checks for white-space characters. For the avr-libc library,
// these are: space, formfeed ('\f'), newline ('\n'), carriage
// return ('\r'), horizontal tab ('\t'), and vertical tab ('\v').
inline boolean isSpace(int c)
{
return ( isspace (c) == 0 ? false : true);
}
// Checks for an uppercase letter.
inline boolean isUpperCase(int c)
{
return ( isupper (c) == 0 ? false : true);
}
// Checks for a hexadecimal digits, i.e. one of 0 1 2 3 4 5 6 7
// 8 9 a b c d e f A B C D E F.
inline boolean isHexadecimalDigit(int c)
{
return ( isxdigit (c) == 0 ? false : true);
}
// Converts c to a 7-bit unsigned char value that fits into the
// ASCII character set, by clearing the high-order bits.
inline int toAscii(int c)
{
/* return toascii (c); */
return (c & 0x7f);
}
// Warning:
// Many people will be unhappy if you use this function.
// This function will convert accented letters into random
// characters.
// Converts the letter c to lower case, if possible.
inline int toLowerCase(int c)
{
return tolower (c);
}
// Converts the letter c to upper case, if possible.
inline int toUpperCase(int c)
{
return toupper (c);
}
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -1,35 +0,0 @@
/******************************************************************************
* The MIT License
*
* Copyright (c) 2010 LeafLabs LLC.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*****************************************************************************/
#ifndef _WIRISH_WPROGRAM_H_
#define _WIRISH_WPROGRAM_H_
#include <wirish.h>
void setup();
void loop();
#endif

View File

@@ -1,747 +0,0 @@
/*
WString.cpp - String library for Wiring & Arduino
...mostly rewritten by Paul Stoffregen...
Copyright (c) 2009-10 Hernando Barragan. All rights reserved.
Copyright 2011, Paul Stoffregen, paul@pjrc.com
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "WString.h"
#include "itoa.h"
#include "avr/dtostrf.h"
/*********************************************/
/* Constructors */
/*********************************************/
String::String(const char *cstr)
{
init();
if (cstr) copy(cstr, strlen(cstr));
}
String::String(const String &value)
{
init();
*this = value;
}
String::String(const __FlashStringHelper *pstr)
{
init();
*this = pstr;
}
#if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__)
String::String(String &&rval)
{
init();
move(rval);
}
String::String(StringSumHelper &&rval)
{
init();
move(rval);
}
#endif
String::String(char c)
{
init();
char buf[2];
buf[0] = c;
buf[1] = 0;
*this = buf;
}
String::String(unsigned char value, unsigned char base)
{
init();
char buf[1 + 8 * sizeof(unsigned char)];
utoa(value, buf, base);
*this = buf;
}
String::String(int value, unsigned char base)
{
init();
char buf[2 + 8 * sizeof(int)];
itoa(value, buf, base);
*this = buf;
}
String::String(unsigned int value, unsigned char base)
{
init();
char buf[1 + 8 * sizeof(unsigned int)];
utoa(value, buf, base);
*this = buf;
}
String::String(long value, unsigned char base)
{
init();
char buf[2 + 8 * sizeof(long)];
ltoa(value, buf, base);
*this = buf;
}
String::String(unsigned long value, unsigned char base)
{
init();
char buf[1 + 8 * sizeof(unsigned long)];
ultoa(value, buf, base);
*this = buf;
}
String::String(float value, unsigned char decimalPlaces)
{
init();
char buf[33];
*this = dtostrf(value, (decimalPlaces + 2), decimalPlaces, buf);
}
String::String(double value, unsigned char decimalPlaces)
{
init();
char buf[33];
*this = dtostrf(value, (decimalPlaces + 2), decimalPlaces, buf);
}
String::~String()
{
free(buffer);
}
/*********************************************/
/* Memory Management */
/*********************************************/
inline void String::init(void)
{
buffer = NULL;
capacity = 0;
len = 0;
}
void String::invalidate(void)
{
if (buffer) free(buffer);
buffer = NULL;
capacity = len = 0;
}
unsigned char String::reserve(unsigned int size)
{
if (buffer && capacity >= size) return 1;
if (changeBuffer(size)) {
if (len == 0) buffer[0] = 0;
return 1;
}
return 0;
}
unsigned char String::changeBuffer(unsigned int maxStrLen)
{
char *newbuffer = (char *)realloc(buffer, maxStrLen + 1);
if (newbuffer) {
buffer = newbuffer;
capacity = maxStrLen;
return 1;
}
return 0;
}
/*********************************************/
/* Copy and Move */
/*********************************************/
String & String::copy(const char *cstr, unsigned int length)
{
if (!reserve(length)) {
invalidate();
return *this;
}
len = length;
strcpy(buffer, cstr);
return *this;
}
String & String::copy(const __FlashStringHelper *pstr, unsigned int length)
{
if (!reserve(length)) {
invalidate();
return *this;
}
len = length;
strcpy_P(buffer, (PGM_P)pstr);
return *this;
}
#if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__)
void String::move(String &rhs)
{
if (buffer) {
if (rhs && capacity >= rhs.len) {
strcpy(buffer, rhs.buffer);
len = rhs.len;
rhs.len = 0;
return;
} else {
free(buffer);
}
}
buffer = rhs.buffer;
capacity = rhs.capacity;
len = rhs.len;
rhs.buffer = NULL;
rhs.capacity = 0;
rhs.len = 0;
}
#endif
String & String::operator = (const String &rhs)
{
if (this == &rhs) return *this;
if (rhs.buffer) copy(rhs.buffer, rhs.len);
else invalidate();
return *this;
}
#if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__)
String & String::operator = (String &&rval)
{
if (this != &rval) move(rval);
return *this;
}
String & String::operator = (StringSumHelper &&rval)
{
if (this != &rval) move(rval);
return *this;
}
#endif
String & String::operator = (const char *cstr)
{
if (cstr) copy(cstr, strlen(cstr));
else invalidate();
return *this;
}
String & String::operator = (const __FlashStringHelper *pstr)
{
if (pstr) copy(pstr, strlen_P((PGM_P)pstr));
else invalidate();
return *this;
}
/*********************************************/
/* concat */
/*********************************************/
unsigned char String::concat(const String &s)
{
return concat(s.buffer, s.len);
}
unsigned char String::concat(const char *cstr, unsigned int length)
{
unsigned int newlen = len + length;
if (!cstr) return 0;
if (length == 0) return 1;
if (!reserve(newlen)) return 0;
strcpy(buffer + len, cstr);
len = newlen;
return 1;
}
unsigned char String::concat(const char *cstr)
{
if (!cstr) return 0;
return concat(cstr, strlen(cstr));
}
unsigned char String::concat(char c)
{
char buf[2];
buf[0] = c;
buf[1] = 0;
return concat(buf, 1);
}
unsigned char String::concat(unsigned char num)
{
char buf[1 + 3 * sizeof(unsigned char)];
itoa(num, buf, 10);
return concat(buf, strlen(buf));
}
unsigned char String::concat(int num)
{
char buf[2 + 3 * sizeof(int)];
itoa(num, buf, 10);
return concat(buf, strlen(buf));
}
unsigned char String::concat(unsigned int num)
{
char buf[1 + 3 * sizeof(unsigned int)];
utoa(num, buf, 10);
return concat(buf, strlen(buf));
}
unsigned char String::concat(long num)
{
char buf[2 + 3 * sizeof(long)];
ltoa(num, buf, 10);
return concat(buf, strlen(buf));
}
unsigned char String::concat(unsigned long num)
{
char buf[1 + 3 * sizeof(unsigned long)];
ultoa(num, buf, 10);
return concat(buf, strlen(buf));
}
unsigned char String::concat(float num)
{
char buf[20];
char* string = dtostrf(num, 4, 2, buf);
return concat(string, strlen(string));
}
unsigned char String::concat(double num)
{
char buf[20];
char* string = dtostrf(num, 4, 2, buf);
return concat(string, strlen(string));
}
unsigned char String::concat(const __FlashStringHelper * str)
{
if (!str) return 0;
int length = strlen_P((const char *) str);
if (length == 0) return 1;
unsigned int newlen = len + length;
if (!reserve(newlen)) return 0;
strcpy_P(buffer + len, (const char *) str);
len = newlen;
return 1;
}
/*********************************************/
/* Concatenate */
/*********************************************/
StringSumHelper & operator + (const StringSumHelper &lhs, const String &rhs)
{
StringSumHelper &a = const_cast<StringSumHelper&>(lhs);
if (!a.concat(rhs.buffer, rhs.len)) a.invalidate();
return a;
}
StringSumHelper & operator + (const StringSumHelper &lhs, const char *cstr)
{
StringSumHelper &a = const_cast<StringSumHelper&>(lhs);
if (!cstr || !a.concat(cstr, strlen(cstr))) a.invalidate();
return a;
}
StringSumHelper & operator + (const StringSumHelper &lhs, char c)
{
StringSumHelper &a = const_cast<StringSumHelper&>(lhs);
if (!a.concat(c)) a.invalidate();
return a;
}
StringSumHelper & operator + (const StringSumHelper &lhs, unsigned char num)
{
StringSumHelper &a = const_cast<StringSumHelper&>(lhs);
if (!a.concat(num)) a.invalidate();
return a;
}
StringSumHelper & operator + (const StringSumHelper &lhs, int num)
{
StringSumHelper &a = const_cast<StringSumHelper&>(lhs);
if (!a.concat(num)) a.invalidate();
return a;
}
StringSumHelper & operator + (const StringSumHelper &lhs, unsigned int num)
{
StringSumHelper &a = const_cast<StringSumHelper&>(lhs);
if (!a.concat(num)) a.invalidate();
return a;
}
StringSumHelper & operator + (const StringSumHelper &lhs, long num)
{
StringSumHelper &a = const_cast<StringSumHelper&>(lhs);
if (!a.concat(num)) a.invalidate();
return a;
}
StringSumHelper & operator + (const StringSumHelper &lhs, unsigned long num)
{
StringSumHelper &a = const_cast<StringSumHelper&>(lhs);
if (!a.concat(num)) a.invalidate();
return a;
}
StringSumHelper & operator + (const StringSumHelper &lhs, float num)
{
StringSumHelper &a = const_cast<StringSumHelper&>(lhs);
if (!a.concat(num)) a.invalidate();
return a;
}
StringSumHelper & operator + (const StringSumHelper &lhs, double num)
{
StringSumHelper &a = const_cast<StringSumHelper&>(lhs);
if (!a.concat(num)) a.invalidate();
return a;
}
StringSumHelper & operator + (const StringSumHelper &lhs, const __FlashStringHelper *rhs)
{
StringSumHelper &a = const_cast<StringSumHelper&>(lhs);
if (!a.concat(rhs)) a.invalidate();
return a;
}
/*********************************************/
/* Comparison */
/*********************************************/
int String::compareTo(const String &s) const
{
if (!buffer || !s.buffer) {
if (s.buffer && s.len > 0) return 0 - *(unsigned char *)s.buffer;
if (buffer && len > 0) return *(unsigned char *)buffer;
return 0;
}
return strcmp(buffer, s.buffer);
}
unsigned char String::equals(const String &s2) const
{
return (len == s2.len && compareTo(s2) == 0);
}
unsigned char String::equals(const char *cstr) const
{
if (len == 0) return (cstr == NULL || *cstr == 0);
if (cstr == NULL) return buffer[0] == 0;
return strcmp(buffer, cstr) == 0;
}
unsigned char String::operator<(const String &rhs) const
{
return compareTo(rhs) < 0;
}
unsigned char String::operator>(const String &rhs) const
{
return compareTo(rhs) > 0;
}
unsigned char String::operator<=(const String &rhs) const
{
return compareTo(rhs) <= 0;
}
unsigned char String::operator>=(const String &rhs) const
{
return compareTo(rhs) >= 0;
}
unsigned char String::equalsIgnoreCase( const String &s2 ) const
{
if (this == &s2) return 1;
if (len != s2.len) return 0;
if (len == 0) return 1;
const char *p1 = buffer;
const char *p2 = s2.buffer;
while (*p1) {
if (tolower(*p1++) != tolower(*p2++)) return 0;
}
return 1;
}
unsigned char String::startsWith( const String &s2 ) const
{
if (len < s2.len) return 0;
return startsWith(s2, 0);
}
unsigned char String::startsWith( const String &s2, unsigned int offset ) const
{
if (offset > len - s2.len || !buffer || !s2.buffer) return 0;
return strncmp( &buffer[offset], s2.buffer, s2.len ) == 0;
}
unsigned char String::endsWith( const String &s2 ) const
{
if ( len < s2.len || !buffer || !s2.buffer) return 0;
return strcmp(&buffer[len - s2.len], s2.buffer) == 0;
}
/*********************************************/
/* Character Access */
/*********************************************/
char String::charAt(unsigned int loc) const
{
return operator[](loc);
}
void String::setCharAt(unsigned int loc, char c)
{
if (loc < len) buffer[loc] = c;
}
char & String::operator[](unsigned int index)
{
static char dummy_writable_char;
if (index >= len || !buffer) {
dummy_writable_char = 0;
return dummy_writable_char;
}
return buffer[index];
}
char String::operator[]( unsigned int index ) const
{
if (index >= len || !buffer) return 0;
return buffer[index];
}
void String::getBytes(unsigned char *buf, unsigned int bufsize, unsigned int index) const
{
if (!bufsize || !buf) return;
if (index >= len) {
buf[0] = 0;
return;
}
unsigned int n = bufsize - 1;
if (n > len - index) n = len - index;
strncpy((char *)buf, buffer + index, n);
buf[n] = 0;
}
/*********************************************/
/* Search */
/*********************************************/
int String::indexOf(char c) const
{
return indexOf(c, 0);
}
int String::indexOf( char ch, unsigned int fromIndex ) const
{
if (fromIndex >= len) return -1;
const char* temp = strchr(buffer + fromIndex, ch);
if (temp == NULL) return -1;
return temp - buffer;
}
int String::indexOf(const String &s2) const
{
return indexOf(s2, 0);
}
int String::indexOf(const String &s2, unsigned int fromIndex) const
{
if (fromIndex >= len) return -1;
const char *found = strstr(buffer + fromIndex, s2.buffer);
if (found == NULL) return -1;
return found - buffer;
}
int String::lastIndexOf( char theChar ) const
{
return lastIndexOf(theChar, len - 1);
}
int String::lastIndexOf(char ch, unsigned int fromIndex) const
{
if (fromIndex >= len) return -1;
char tempchar = buffer[fromIndex + 1];
buffer[fromIndex + 1] = '\0';
char* temp = strrchr( buffer, ch );
buffer[fromIndex + 1] = tempchar;
if (temp == NULL) return -1;
return temp - buffer;
}
int String::lastIndexOf(const String &s2) const
{
return lastIndexOf(s2, len - s2.len);
}
int String::lastIndexOf(const String &s2, unsigned int fromIndex) const
{
if (s2.len == 0 || len == 0 || s2.len > len) return -1;
if (fromIndex >= len) fromIndex = len - 1;
int found = -1;
for (char *p = buffer; p <= buffer + fromIndex; p++) {
p = strstr(p, s2.buffer);
if (!p) break;
if ((unsigned int)(p - buffer) <= fromIndex) found = p - buffer;
}
return found;
}
String String::substring(unsigned int left, unsigned int right) const
{
if (left > right) {
unsigned int temp = right;
right = left;
left = temp;
}
String out;
if (left >= len) return out;
if (right > len) right = len;
char temp = buffer[right]; // save the replaced character
buffer[right] = '\0';
out = buffer + left; // pointer arithmetic
buffer[right] = temp; //restore character
return out;
}
/*********************************************/
/* Modification */
/*********************************************/
void String::replace(char find, char replace)
{
if (!buffer) return;
for (char *p = buffer; *p; p++) {
if (*p == find) *p = replace;
}
}
void String::replace(const String& find, const String& replace)
{
if (len == 0 || find.len == 0) return;
int diff = replace.len - find.len;
char *readFrom = buffer;
char *foundAt;
if (diff == 0) {
while ((foundAt = strstr(readFrom, find.buffer)) != NULL) {
memcpy(foundAt, replace.buffer, replace.len);
readFrom = foundAt + replace.len;
}
} else if (diff < 0) {
char *writeTo = buffer;
while ((foundAt = strstr(readFrom, find.buffer)) != NULL) {
unsigned int n = foundAt - readFrom;
memcpy(writeTo, readFrom, n);
writeTo += n;
memcpy(writeTo, replace.buffer, replace.len);
writeTo += replace.len;
readFrom = foundAt + find.len;
len += diff;
}
strcpy(writeTo, readFrom);
} else {
unsigned int size = len; // compute size needed for result
while ((foundAt = strstr(readFrom, find.buffer)) != NULL) {
readFrom = foundAt + find.len;
size += diff;
}
if (size == len) return;
if (size > capacity && !changeBuffer(size)) return; // XXX: tell user!
int index = len - 1;
while (index >= 0 && (index = lastIndexOf(find, index)) >= 0) {
readFrom = buffer + index + find.len;
memmove(readFrom + diff, readFrom, len - (readFrom - buffer));
len += diff;
buffer[len] = 0;
memcpy(buffer + index, replace.buffer, replace.len);
index--;
}
}
}
void String::remove(unsigned int index){
// Pass the biggest integer as the count. The remove method
// below will take care of truncating it at the end of the
// string.
remove(index, (unsigned int)-1);
}
void String::remove(unsigned int index, unsigned int count){
if (index >= len) { return; }
if (count <= 0) { return; }
if (count > len - index) { count = len - index; }
char *writeTo = buffer + index;
len = len - count;
strncpy(writeTo, buffer + index + count,len - index);
buffer[len] = 0;
}
void String::toLowerCase(void)
{
if (!buffer) return;
for (char *p = buffer; *p; p++) {
*p = tolower(*p);
}
}
void String::toUpperCase(void)
{
if (!buffer) return;
for (char *p = buffer; *p; p++) {
*p = toupper(*p);
}
}
void String::trim(void)
{
if (!buffer || len == 0) return;
char *begin = buffer;
while (isspace(*begin)) begin++;
char *end = buffer + len - 1;
while (isspace(*end) && end >= begin) end--;
len = end + 1 - begin;
if (begin > buffer) memcpy(buffer, begin, len);
buffer[len] = 0;
}
/*********************************************/
/* Parsing / Conversion */
/*********************************************/
long String::toInt(void) const
{
if (buffer) return atol(buffer);
return 0;
}
float String::toFloat(void) const
{
if (buffer) return float(atof(buffer));
return 0;
}

View File

@@ -1,228 +0,0 @@
/*
WString.h - String library for Wiring & Arduino
...mostly rewritten by Paul Stoffregen...
Copyright (c) 2009-10 Hernando Barragan. All right reserved.
Copyright 2011, Paul Stoffregen, paul@pjrc.com
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef String_class_h
#define String_class_h
#ifdef __cplusplus
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <avr/pgmspace.h>
// When compiling programs with this class, the following gcc parameters
// dramatically increase performance and memory (RAM) efficiency, typically
// with little or no increase in code size.
// -felide-constructors
// -std=c++0x
class __FlashStringHelper;
#define F(string_literal) (reinterpret_cast<const __FlashStringHelper *>(PSTR(string_literal)))
// An inherited class for holding the result of a concatenation. These
// result objects are assumed to be writable by subsequent concatenations.
class StringSumHelper;
// The string class
class String
{
// use a function pointer to allow for "if (s)" without the
// complications of an operator bool(). for more information, see:
// http://www.artima.com/cppsource/safebool.html
typedef void (String::*StringIfHelperType)() const;
void StringIfHelper() const {}
public:
// constructors
// creates a copy of the initial value.
// if the initial value is null or invalid, or if memory allocation
// fails, the string will be marked as invalid (i.e. "if (s)" will
// be false).
String(const char *cstr = "");
String(const String &str);
String(const __FlashStringHelper *str);
#if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__)
String(String &&rval);
String(StringSumHelper &&rval);
#endif
explicit String(char c);
explicit String(unsigned char, unsigned char base=10);
explicit String(int, unsigned char base=10);
explicit String(unsigned int, unsigned char base=10);
explicit String(long, unsigned char base=10);
explicit String(unsigned long, unsigned char base=10);
explicit String(float, unsigned char decimalPlaces=2);
explicit String(double, unsigned char decimalPlaces=2);
~String(void);
// memory management
// return true on success, false on failure (in which case, the string
// is left unchanged). reserve(0), if successful, will validate an
// invalid string (i.e., "if (s)" will be true afterwards)
unsigned char reserve(unsigned int size);
inline unsigned int length(void) const {return len;}
// creates a copy of the assigned value. if the value is null or
// invalid, or if the memory allocation fails, the string will be
// marked as invalid ("if (s)" will be false).
String & operator = (const String &rhs);
String & operator = (const char *cstr);
String & operator = (const __FlashStringHelper *str);
#if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__)
String & operator = (String &&rval);
String & operator = (StringSumHelper &&rval);
#endif
// concatenate (works w/ built-in types)
// returns true on success, false on failure (in which case, the string
// is left unchanged). if the argument is null or invalid, the
// concatenation is considered unsucessful.
unsigned char concat(const String &str);
unsigned char concat(const char *cstr);
unsigned char concat(char c);
unsigned char concat(unsigned char c);
unsigned char concat(int num);
unsigned char concat(unsigned int num);
unsigned char concat(long num);
unsigned char concat(unsigned long num);
unsigned char concat(float num);
unsigned char concat(double num);
unsigned char concat(const __FlashStringHelper * str);
// if there's not enough memory for the concatenated value, the string
// will be left unchanged (but this isn't signalled in any way)
String & operator += (const String &rhs) {concat(rhs); return (*this);}
String & operator += (const char *cstr) {concat(cstr); return (*this);}
String & operator += (char c) {concat(c); return (*this);}
String & operator += (unsigned char num) {concat(num); return (*this);}
String & operator += (int num) {concat(num); return (*this);}
String & operator += (unsigned int num) {concat(num); return (*this);}
String & operator += (long num) {concat(num); return (*this);}
String & operator += (unsigned long num) {concat(num); return (*this);}
String & operator += (float num) {concat(num); return (*this);}
String & operator += (double num) {concat(num); return (*this);}
String & operator += (const __FlashStringHelper *str){concat(str); return (*this);}
friend StringSumHelper & operator + (const StringSumHelper &lhs, const String &rhs);
friend StringSumHelper & operator + (const StringSumHelper &lhs, const char *cstr);
friend StringSumHelper & operator + (const StringSumHelper &lhs, char c);
friend StringSumHelper & operator + (const StringSumHelper &lhs, unsigned char num);
friend StringSumHelper & operator + (const StringSumHelper &lhs, int num);
friend StringSumHelper & operator + (const StringSumHelper &lhs, unsigned int num);
friend StringSumHelper & operator + (const StringSumHelper &lhs, long num);
friend StringSumHelper & operator + (const StringSumHelper &lhs, unsigned long num);
friend StringSumHelper & operator + (const StringSumHelper &lhs, float num);
friend StringSumHelper & operator + (const StringSumHelper &lhs, double num);
friend StringSumHelper & operator + (const StringSumHelper &lhs, const __FlashStringHelper *rhs);
// comparison (only works w/ Strings and "strings")
operator StringIfHelperType() const { return buffer ? &String::StringIfHelper : 0; }
int compareTo(const String &s) const;
unsigned char equals(const String &s) const;
unsigned char equals(const char *cstr) const;
unsigned char operator == (const String &rhs) const {return equals(rhs);}
unsigned char operator == (const char *cstr) const {return equals(cstr);}
unsigned char operator != (const String &rhs) const {return !equals(rhs);}
unsigned char operator != (const char *cstr) const {return !equals(cstr);}
unsigned char operator < (const String &rhs) const;
unsigned char operator > (const String &rhs) const;
unsigned char operator <= (const String &rhs) const;
unsigned char operator >= (const String &rhs) const;
unsigned char equalsIgnoreCase(const String &s) const;
unsigned char startsWith( const String &prefix) const;
unsigned char startsWith(const String &prefix, unsigned int offset) const;
unsigned char endsWith(const String &suffix) const;
// character acccess
char charAt(unsigned int index) const;
void setCharAt(unsigned int index, char c);
char operator [] (unsigned int index) const;
char& operator [] (unsigned int index);
void getBytes(unsigned char *buf, unsigned int bufsize, unsigned int index=0) const;
void toCharArray(char *buf, unsigned int bufsize, unsigned int index=0) const
{getBytes((unsigned char *)buf, bufsize, index);}
const char * c_str() const { return buffer; }
char* begin() { return buffer; }
char* end() { return buffer + length(); }
const char* begin() const { return c_str(); }
const char* end() const { return c_str() + length(); }
// search
int indexOf( char ch ) const;
int indexOf( char ch, unsigned int fromIndex ) const;
int indexOf( const String &str ) const;
int indexOf( const String &str, unsigned int fromIndex ) const;
int lastIndexOf( char ch ) const;
int lastIndexOf( char ch, unsigned int fromIndex ) const;
int lastIndexOf( const String &str ) const;
int lastIndexOf( const String &str, unsigned int fromIndex ) const;
String substring( unsigned int beginIndex ) const { return substring(beginIndex, len); };
String substring( unsigned int beginIndex, unsigned int endIndex ) const;
// modification
void replace(char find, char replace);
void replace(const String& find, const String& replace);
void remove(unsigned int index);
void remove(unsigned int index, unsigned int count);
void toLowerCase(void);
void toUpperCase(void);
void trim(void);
// parsing/conversion
long toInt(void) const;
float toFloat(void) const;
protected:
char *buffer; // the actual char array
unsigned int capacity; // the array length minus one (for the '\0')
unsigned int len; // the String length (not counting the '\0')
protected:
void init(void);
void invalidate(void);
unsigned char changeBuffer(unsigned int maxStrLen);
unsigned char concat(const char *cstr, unsigned int length);
// copy and move
String & copy(const char *cstr, unsigned int length);
String & copy(const __FlashStringHelper *pstr, unsigned int length);
#if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__)
void move(String &rhs);
#endif
};
class StringSumHelper : public String
{
public:
StringSumHelper(const String &s) : String(s) {}
StringSumHelper(const char *p) : String(p) {}
StringSumHelper(char c) : String(c) {}
StringSumHelper(unsigned char num) : String(num) {}
StringSumHelper(int num) : String(num) {}
StringSumHelper(unsigned int num) : String(num) {}
StringSumHelper(long num) : String(num) {}
StringSumHelper(unsigned long num) : String(num) {}
StringSumHelper(float num) : String(num) {}
StringSumHelper(double num) : String(num) {}
};
#endif // __cplusplus
#endif // String_class_h

View File

@@ -1,29 +0,0 @@
/*
dtostrf - Emulation for dtostrf function from avr-libc
Copyright (c) 2013 Arduino. All rights reserved.
Written by Cristian Maglie <c.maglie@bug.st>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <stdio.h>
char *dtostrf (double val, signed char width, unsigned char prec, char *sout) {
char fmt[20];
sprintf(fmt, "%%%d.%df", width, prec);
sprintf(sout, fmt, val);
return sout;
}

View File

@@ -1,29 +0,0 @@
/*
dtostrf - Emulation for dtostrf function from avr-libc
Copyright (c) 2013 Arduino. All rights reserved.
Written by Cristian Maglie <c.maglie@bug.st>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifdef __cplusplus
extern "C" {
#endif
char *dtostrf (double val, signed char width, unsigned char prec, char *sout);
#ifdef __cplusplus
}
#endif

View File

@@ -1,44 +0,0 @@
#ifndef __PGMSPACE_H_
#define __PGMSPACE_H_ 1
#include <inttypes.h>
#define PROGMEM
#define PGM_P const char *
#define PSTR(str) (str)
#define _SFR_BYTE(n) (n)
typedef void prog_void;
typedef char prog_char;
typedef unsigned char prog_uchar;
typedef int8_t prog_int8_t;
typedef uint8_t prog_uint8_t;
typedef int16_t prog_int16_t;
typedef uint16_t prog_uint16_t;
typedef int32_t prog_int32_t;
typedef uint32_t prog_uint32_t;
#define memcpy_P(dest, src, num) memcpy((dest), (src), (num))
#define strcpy_P(dest, src) strcpy((dest), (src))
#define strcat_P(dest, src) strcat((dest), (src))
#define strcmp_P(a, b) strcmp((a), (b))
#define strstr_P(a, b) strstr((a), (b))
#define strlen_P(a) strlen((a))
#define sprintf_P(s, f, ...) sprintf((s), (f), __VA_ARGS__)
#define pgm_read_byte(addr) (*(const unsigned char *)(addr))
#define pgm_read_word(addr) (*(const unsigned short *)(addr))
#define pgm_read_dword(addr) (*(const unsigned long *)(addr))
#define pgm_read_float(addr) (*(const float *)(addr))
#define pgm_read_byte_near(addr) pgm_read_byte(addr)
#define pgm_read_word_near(addr) pgm_read_word(addr)
#define pgm_read_dword_near(addr) pgm_read_dword(addr)
#define pgm_read_float_near(addr) pgm_read_float(addr)
#define pgm_read_byte_far(addr) pgm_read_byte(addr)
#define pgm_read_word_far(addr) pgm_read_word(addr)
#define pgm_read_dword_far(addr) pgm_read_dword(addr)
#define pgm_read_float_far(addr) pgm_read_float(addr)
#endif

View File

@@ -1,579 +0,0 @@
/******************************************************************************
* The MIT License
*
* Copyright (c) 2010 LeafLabs, LLC.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*****************************************************************************/
/**
* @brief BIT[n] and binary literal defines, for Arduino
* compatibility.
*/
#ifndef _WIRISH_BIT_CONSTANTS_H_
#define _WIRISH_BIT_CONSTANTS_H_
#define BIT0 (1 << 0)
#define BIT1 (1 << 1)
#define BIT2 (1 << 2)
#define BIT3 (1 << 3)
#define BIT4 (1 << 4)
#define BIT5 (1 << 5)
#define BIT6 (1 << 6)
#define BIT7 (1 << 7)
#define BIT8 (1 << 8)
#define BIT9 (1 << 9)
#define BIT10 (1 << 10)
#define BIT11 (1 << 11)
#define BIT12 (1 << 12)
#define BIT13 (1 << 13)
#define BIT14 (1 << 14)
#define BIT15 (1 << 15)
#define BIT16 (1 << 16)
#define BIT17 (1 << 17)
#define BIT18 (1 << 18)
#define BIT19 (1 << 19)
#define BIT20 (1 << 20)
#define BIT21 (1 << 21)
#define BIT22 (1 << 22)
#define BIT23 (1 << 23)
#define BIT24 (1 << 24)
#define BIT25 (1 << 25)
#define BIT26 (1 << 26)
#define BIT27 (1 << 27)
#define BIT28 (1 << 28)
#define BIT29 (1 << 29)
#define BIT30 (1 << 30)
#define BIT31 (1 << 31)
#define B0 0
#define B00 0
#define B000 0
#define B0000 0
#define B00000 0
#define B000000 0
#define B0000000 0
#define B00000000 0
#define B1 1
#define B01 1
#define B001 1
#define B0001 1
#define B00001 1
#define B000001 1
#define B0000001 1
#define B00000001 1
#define B10 2
#define B010 2
#define B0010 2
#define B00010 2
#define B000010 2
#define B0000010 2
#define B00000010 2
#define B11 3
#define B011 3
#define B0011 3
#define B00011 3
#define B000011 3
#define B0000011 3
#define B00000011 3
#define B100 4
#define B0100 4
#define B00100 4
#define B000100 4
#define B0000100 4
#define B00000100 4
#define B101 5
#define B0101 5
#define B00101 5
#define B000101 5
#define B0000101 5
#define B00000101 5
#define B110 6
#define B0110 6
#define B00110 6
#define B000110 6
#define B0000110 6
#define B00000110 6
#define B111 7
#define B0111 7
#define B00111 7
#define B000111 7
#define B0000111 7
#define B00000111 7
#define B1000 8
#define B01000 8
#define B001000 8
#define B0001000 8
#define B00001000 8
#define B1001 9
#define B01001 9
#define B001001 9
#define B0001001 9
#define B00001001 9
#define B1010 10
#define B01010 10
#define B001010 10
#define B0001010 10
#define B00001010 10
#define B1011 11
#define B01011 11
#define B001011 11
#define B0001011 11
#define B00001011 11
#define B1100 12
#define B01100 12
#define B001100 12
#define B0001100 12
#define B00001100 12
#define B1101 13
#define B01101 13
#define B001101 13
#define B0001101 13
#define B00001101 13
#define B1110 14
#define B01110 14
#define B001110 14
#define B0001110 14
#define B00001110 14
#define B1111 15
#define B01111 15
#define B001111 15
#define B0001111 15
#define B00001111 15
#define B10000 16
#define B010000 16
#define B0010000 16
#define B00010000 16
#define B10001 17
#define B010001 17
#define B0010001 17
#define B00010001 17
#define B10010 18
#define B010010 18
#define B0010010 18
#define B00010010 18
#define B10011 19
#define B010011 19
#define B0010011 19
#define B00010011 19
#define B10100 20
#define B010100 20
#define B0010100 20
#define B00010100 20
#define B10101 21
#define B010101 21
#define B0010101 21
#define B00010101 21
#define B10110 22
#define B010110 22
#define B0010110 22
#define B00010110 22
#define B10111 23
#define B010111 23
#define B0010111 23
#define B00010111 23
#define B11000 24
#define B011000 24
#define B0011000 24
#define B00011000 24
#define B11001 25
#define B011001 25
#define B0011001 25
#define B00011001 25
#define B11010 26
#define B011010 26
#define B0011010 26
#define B00011010 26
#define B11011 27
#define B011011 27
#define B0011011 27
#define B00011011 27
#define B11100 28
#define B011100 28
#define B0011100 28
#define B00011100 28
#define B11101 29
#define B011101 29
#define B0011101 29
#define B00011101 29
#define B11110 30
#define B011110 30
#define B0011110 30
#define B00011110 30
#define B11111 31
#define B011111 31
#define B0011111 31
#define B00011111 31
#define B100000 32
#define B0100000 32
#define B00100000 32
#define B100001 33
#define B0100001 33
#define B00100001 33
#define B100010 34
#define B0100010 34
#define B00100010 34
#define B100011 35
#define B0100011 35
#define B00100011 35
#define B100100 36
#define B0100100 36
#define B00100100 36
#define B100101 37
#define B0100101 37
#define B00100101 37
#define B100110 38
#define B0100110 38
#define B00100110 38
#define B100111 39
#define B0100111 39
#define B00100111 39
#define B101000 40
#define B0101000 40
#define B00101000 40
#define B101001 41
#define B0101001 41
#define B00101001 41
#define B101010 42
#define B0101010 42
#define B00101010 42
#define B101011 43
#define B0101011 43
#define B00101011 43
#define B101100 44
#define B0101100 44
#define B00101100 44
#define B101101 45
#define B0101101 45
#define B00101101 45
#define B101110 46
#define B0101110 46
#define B00101110 46
#define B101111 47
#define B0101111 47
#define B00101111 47
#define B110000 48
#define B0110000 48
#define B00110000 48
#define B110001 49
#define B0110001 49
#define B00110001 49
#define B110010 50
#define B0110010 50
#define B00110010 50
#define B110011 51
#define B0110011 51
#define B00110011 51
#define B110100 52
#define B0110100 52
#define B00110100 52
#define B110101 53
#define B0110101 53
#define B00110101 53
#define B110110 54
#define B0110110 54
#define B00110110 54
#define B110111 55
#define B0110111 55
#define B00110111 55
#define B111000 56
#define B0111000 56
#define B00111000 56
#define B111001 57
#define B0111001 57
#define B00111001 57
#define B111010 58
#define B0111010 58
#define B00111010 58
#define B111011 59
#define B0111011 59
#define B00111011 59
#define B111100 60
#define B0111100 60
#define B00111100 60
#define B111101 61
#define B0111101 61
#define B00111101 61
#define B111110 62
#define B0111110 62
#define B00111110 62
#define B111111 63
#define B0111111 63
#define B00111111 63
#define B1000000 64
#define B01000000 64
#define B1000001 65
#define B01000001 65
#define B1000010 66
#define B01000010 66
#define B1000011 67
#define B01000011 67
#define B1000100 68
#define B01000100 68
#define B1000101 69
#define B01000101 69
#define B1000110 70
#define B01000110 70
#define B1000111 71
#define B01000111 71
#define B1001000 72
#define B01001000 72
#define B1001001 73
#define B01001001 73
#define B1001010 74
#define B01001010 74
#define B1001011 75
#define B01001011 75
#define B1001100 76
#define B01001100 76
#define B1001101 77
#define B01001101 77
#define B1001110 78
#define B01001110 78
#define B1001111 79
#define B01001111 79
#define B1010000 80
#define B01010000 80
#define B1010001 81
#define B01010001 81
#define B1010010 82
#define B01010010 82
#define B1010011 83
#define B01010011 83
#define B1010100 84
#define B01010100 84
#define B1010101 85
#define B01010101 85
#define B1010110 86
#define B01010110 86
#define B1010111 87
#define B01010111 87
#define B1011000 88
#define B01011000 88
#define B1011001 89
#define B01011001 89
#define B1011010 90
#define B01011010 90
#define B1011011 91
#define B01011011 91
#define B1011100 92
#define B01011100 92
#define B1011101 93
#define B01011101 93
#define B1011110 94
#define B01011110 94
#define B1011111 95
#define B01011111 95
#define B1100000 96
#define B01100000 96
#define B1100001 97
#define B01100001 97
#define B1100010 98
#define B01100010 98
#define B1100011 99
#define B01100011 99
#define B1100100 100
#define B01100100 100
#define B1100101 101
#define B01100101 101
#define B1100110 102
#define B01100110 102
#define B1100111 103
#define B01100111 103
#define B1101000 104
#define B01101000 104
#define B1101001 105
#define B01101001 105
#define B1101010 106
#define B01101010 106
#define B1101011 107
#define B01101011 107
#define B1101100 108
#define B01101100 108
#define B1101101 109
#define B01101101 109
#define B1101110 110
#define B01101110 110
#define B1101111 111
#define B01101111 111
#define B1110000 112
#define B01110000 112
#define B1110001 113
#define B01110001 113
#define B1110010 114
#define B01110010 114
#define B1110011 115
#define B01110011 115
#define B1110100 116
#define B01110100 116
#define B1110101 117
#define B01110101 117
#define B1110110 118
#define B01110110 118
#define B1110111 119
#define B01110111 119
#define B1111000 120
#define B01111000 120
#define B1111001 121
#define B01111001 121
#define B1111010 122
#define B01111010 122
#define B1111011 123
#define B01111011 123
#define B1111100 124
#define B01111100 124
#define B1111101 125
#define B01111101 125
#define B1111110 126
#define B01111110 126
#define B1111111 127
#define B01111111 127
#define B10000000 128
#define B10000001 129
#define B10000010 130
#define B10000011 131
#define B10000100 132
#define B10000101 133
#define B10000110 134
#define B10000111 135
#define B10001000 136
#define B10001001 137
#define B10001010 138
#define B10001011 139
#define B10001100 140
#define B10001101 141
#define B10001110 142
#define B10001111 143
#define B10010000 144
#define B10010001 145
#define B10010010 146
#define B10010011 147
#define B10010100 148
#define B10010101 149
#define B10010110 150
#define B10010111 151
#define B10011000 152
#define B10011001 153
#define B10011010 154
#define B10011011 155
#define B10011100 156
#define B10011101 157
#define B10011110 158
#define B10011111 159
#define B10100000 160
#define B10100001 161
#define B10100010 162
#define B10100011 163
#define B10100100 164
#define B10100101 165
#define B10100110 166
#define B10100111 167
#define B10101000 168
#define B10101001 169
#define B10101010 170
#define B10101011 171
#define B10101100 172
#define B10101101 173
#define B10101110 174
#define B10101111 175
#define B10110000 176
#define B10110001 177
#define B10110010 178
#define B10110011 179
#define B10110100 180
#define B10110101 181
#define B10110110 182
#define B10110111 183
#define B10111000 184
#define B10111001 185
#define B10111010 186
#define B10111011 187
#define B10111100 188
#define B10111101 189
#define B10111110 190
#define B10111111 191
#define B11000000 192
#define B11000001 193
#define B11000010 194
#define B11000011 195
#define B11000100 196
#define B11000101 197
#define B11000110 198
#define B11000111 199
#define B11001000 200
#define B11001001 201
#define B11001010 202
#define B11001011 203
#define B11001100 204
#define B11001101 205
#define B11001110 206
#define B11001111 207
#define B11010000 208
#define B11010001 209
#define B11010010 210
#define B11010011 211
#define B11010100 212
#define B11010101 213
#define B11010110 214
#define B11010111 215
#define B11011000 216
#define B11011001 217
#define B11011010 218
#define B11011011 219
#define B11011100 220
#define B11011101 221
#define B11011110 222
#define B11011111 223
#define B11100000 224
#define B11100001 225
#define B11100010 226
#define B11100011 227
#define B11100100 228
#define B11100101 229
#define B11100110 230
#define B11100111 231
#define B11101000 232
#define B11101001 233
#define B11101010 234
#define B11101011 235
#define B11101100 236
#define B11101101 237
#define B11101110 238
#define B11101111 239
#define B11110000 240
#define B11110001 241
#define B11110010 242
#define B11110011 243
#define B11110100 244
#define B11110101 245
#define B11110110 246
#define B11110111 247
#define B11111000 248
#define B11111001 249
#define B11111010 250
#define B11111011 251
#define B11111100 252
#define B11111101 253
#define B11111110 254
#define B11111111 255
#endif /* _BIT_CONSTANTS_H_ */

View File

@@ -1,35 +0,0 @@
/******************************************************************************
* The MIT License
*
* Copyright (c) 2010 LeafLabs, LLC.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*****************************************************************************/
/* Note: Use of this header file is deprecated. Use bit_constants.h
instead. */
#ifndef _WIRISH_BITS_H_
#define _WIRISH_BITS_H_
#include <bit_constants.h>
#endif

View File

@@ -1,175 +0,0 @@
/******************************************************************************
* The MIT License
*
* Copyright (c) 2010 Bryan Newbold.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*****************************************************************************/
/**
* @file wirish/include/wirish/boards.h
* @author Bryan Newbold <bnewbold@leaflabs.com>,
* Marti Bolivar <mbolivar@leaflabs.com>
* @brief init() and board-specific pin information.
*/
#ifndef _WIRISH_BOARDS_H_
#define _WIRISH_BOARDS_H_
#include <libmaple/libmaple_types.h>
#include <wirish_types.h>
#include <board/board.h>
/* Set of all possible pin names; not all boards have all these (note
* that we use the Dx convention since all of the Maple's pins are
* "digital" pins (e.g. can be used with digitalRead() and
* digitalWrite()), but not all of them are connected to ADCs. */
enum {
D0, D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13, D14, D15, D16,
D17, D18, D19, D20, D21, D22, D23, D24, D25, D26, D27, D28, D29, D30, D31,
D32, D33, D34, D35, D36, D37, D38, D39, D40, D41, D42, D43, D44, D45, D46,
D47, D48, D49, D50, D51, D52, D53, D54, D55, D56, D57, D58, D59, D60, D61,
D62, D63, D64, D65, D66, D67, D68, D69, D70, D71, D72, D73, D74, D75, D76,
D77, D78, D79, D80, D81, D82, D83, D84, D85, D86, D87, D88, D89, D90, D91,
D92, D93, D94, D95, D96, D97, D98, D99, D100, D101, D102, D103, D104, D105,
D106, D107, D108, D109, D110, D111, };
/**
* @brief Maps each Maple pin to a corresponding stm32_pin_info.
* @see stm32_pin_info
*/
extern const stm32_pin_info PIN_MAP[];
/**
* @brief Pins capable of PWM output.
*
* Its length is BOARD_NR_PWM_PINS.
*/
extern const uint8 boardPWMPins[];
/**
* @brief Array of pins capable of analog input.
*
* Its length is BOARD_NR_ADC_PINS.
*/
extern const uint8 boardADCPins[];
/**
* @brief Pins which are connected to external hardware.
*
* For example, on Maple boards, it always at least includes
* PB1 for the LED. Its length is BOARD_NR_USED_PINS.
*/
extern const uint8 boardUsedPins[];
/**
* @brief Generic board initialization function.
*
* This function is called before main(). It ensures that the clocks
* and peripherals are configured properly for use with wirish, then
* calls boardInit().
*
* @see boardInit()
*/
void init(void);
/**
* @brief Board-specific initialization function.
*
* This function is called from init() after all generic board
* initialization has been performed. Each board is required to
* define its own.
*
* @see init()
*/
extern void boardInit(void);
/**
* @brief Test if a pin is used for a special purpose on your board.
* @param pin Pin to test
* @return true if the given pin is in boardUsedPins, and false otherwise.
* @see boardUsedPins
*/
bool boardUsesPin(uint8 pin);
/*
* Derived and default board definitions
*/
#define CLOCK_SPEED_MHZ CYCLES_PER_MICROSECOND
#define CLOCK_SPEED_HZ (CLOCK_SPEED_MHZ * 1000000UL)
#ifndef SYSTICK_RELOAD_VAL
#define SYSTICK_RELOAD_VAL (1000 * CYCLES_PER_MICROSECOND - 1)
#endif
#ifndef BOARD_BUTTON_PRESSED_LEVEL
#define BOARD_BUTTON_PRESSED_LEVEL HIGH
#endif
/**
* @brief Does the board break out a USART/UART's RX and TX pins?
*
* BOARD_HAVE_USART(n) is nonzero iff USARTn is available (n must be
* an integer literal, 1 through 6). Also see BOARD_HAVE_USART1, ...,
* BOARD_HAVE_UART4 (sic), etc.
*/
#define BOARD_HAVE_USART(n) (defined(BOARD_USART##n##_TX_PIN) && \
defined(BOARD_USART##n##_RX_PIN))
/** Feature test: nonzero iff the board has USART1. */
#define BOARD_HAVE_USART1 BOARD_HAVE_USART(1)
/** Feature test: nonzero iff the board has USART2, 0 otherwise. */
#define BOARD_HAVE_USART2 BOARD_HAVE_USART(2)
/** Feature test: nonzero iff the board has USART3, 0 otherwise. */
#define BOARD_HAVE_USART3 BOARD_HAVE_USART(3)
/** Feature test: nonzero iff the board has UART4, 0 otherwise. */
#define BOARD_HAVE_UART4 BOARD_HAVE_USART(4)
/** Feature test: nonzero iff the board has UART5, 0 otherwise. */
#define BOARD_HAVE_UART5 BOARD_HAVE_USART(5)
/** Feature test: nonzero iff the board has USART6, 0 otherwise. */
#define BOARD_HAVE_USART6 BOARD_HAVE_USART(6)
/**
* @brief Does the board break out a SPI peripheral's pins?
*
* BOARD_HAVE_SPI(n) is nonzero iff SPIn is available (n must be an
* integer literal: 1, 2, or 3). Also see BOARD_HAVE_SPI1,
* BOARD_HAVE_SPI2, BOARD_HAVE_SPI3. */
#define BOARD_HAVE_SPI(n) (defined(BOARD_SPI##n##_NSS_PIN) && \
defined(BOARD_SPI##n##_SCK_PIN) && \
defined(BOARD_SPI##n##_MISO_PIN) && \
defined(BOARD_SPI##n##_MOSI_PIN))
/** Feature test: nonzero iff the board has SPI1. */
#define BOARD_HAVE_SPI1 BOARD_HAVE_SPI(1)
/** Feature test: nonzero iff the board has SPI2. */
#define BOARD_HAVE_SPI2 BOARD_HAVE_SPI(2)
/** Feature test: nonzero iff the board has SPI3. */
#define BOARD_HAVE_SPI3 BOARD_HAVE_SPI(3)
/**
* @brief Feature test: nonzero iff the board has SerialUSB.
*/
//Roger Clark. Change so that BOARD_HAVE_SERIALUSB is always true, so that it can be controller by -DSERIAL_USB
#define BOARD_HAVE_SERIALUSB 1
/*(defined(BOARD_USB_DISC_DEV) && defined(BOARD_USB_DISC_BIT))*/
#endif

View File

@@ -1,71 +0,0 @@
/******************************************************************************
* The MIT License
*
* Copyright (c) 2012 LeafLabs, LLC.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*****************************************************************************/
/**
* @file wirish/boards_private.h
* @author Marti Bolivar <mbolivar@leaflabs.com>
* @brief Private board support header.
*
* This file declares chip-specific variables and functions which
* determine how init() behaves. It is not part of the public Wirish
* API, and can change without notice.
*/
#ifndef _WIRISH_BOARDS_PRIVATE_H_
#define _WIRISH_BOARDS_PRIVATE_H_
#include <libmaple/rcc.h>
#include <libmaple/adc.h>
/* Makes the PIN_MAP rows more human-readable. */
#define PMAP_ROW(gpio_dev, gpio_bit, timer_dev, timer_ch, adc_dev, adc_ch) \
{ gpio_dev, timer_dev, adc_dev, gpio_bit, timer_ch, adc_ch }
namespace wirish {
namespace priv {
/*
* Chip-specific initialization data
*/
extern rcc_pll_cfg w_board_pll_cfg;
extern adc_prescaler w_adc_pre;
extern adc_smp_rate w_adc_smp;
/*
* Chip-specific initialization routines and helper functions.
*/
void board_reset_pll(void);
void board_setup_clock_prescalers(void);
void board_setup_gpio(void);
void board_setup_usb(void);
void series_init(void);
}
}
#endif

View File

@@ -1,6 +0,0 @@
/* We compile with nodefaultlibs, so we need to provide an error
* handler for an empty pure virtual function */
extern "C" void __cxa_pure_virtual(void) {
while(1)
;
}

View File

@@ -1,90 +0,0 @@
/******************************************************************************
* The MIT License
*
* Copyright (c) 2010 Perry Hung.
* Copyright (c) 2011, 2012 LeafLabs, LLC.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*****************************************************************************/
/**
* @file wirish/ext_interrupts.cpp
* @brief Wiring-like interface for external interrupts
*/
#include "ext_interrupts.h"
#include <libmaple/gpio.h>
#include <libmaple/exti.h>
#include "boards.h"
static inline exti_trigger_mode exti_out_mode(ExtIntTriggerMode mode);
void attachInterrupt(uint8 pin, voidFuncPtr handler, ExtIntTriggerMode mode) {
if (pin >= BOARD_NR_GPIO_PINS || !handler) {
return;
}
exti_trigger_mode outMode = exti_out_mode(mode);
exti_attach_interrupt((exti_num)(PIN_MAP[pin].gpio_bit),
gpio_exti_port(PIN_MAP[pin].gpio_device),
handler,
outMode);
}
void attachInterrupt(uint8 pin, voidArgumentFuncPtr handler, void *arg,
ExtIntTriggerMode mode) {
if (pin >= BOARD_NR_GPIO_PINS || !handler) {
return;
}
exti_trigger_mode outMode = exti_out_mode(mode);
exti_attach_callback((exti_num)(PIN_MAP[pin].gpio_bit),
gpio_exti_port(PIN_MAP[pin].gpio_device),
handler,
arg,
outMode);
}
void detachInterrupt(uint8 pin) {
if (pin >= BOARD_NR_GPIO_PINS) {
return;
}
exti_detach_interrupt((exti_num)(PIN_MAP[pin].gpio_bit));
}
static inline exti_trigger_mode exti_out_mode(ExtIntTriggerMode mode) {
switch (mode) {
case RISING:
return EXTI_RISING;
case FALLING:
return EXTI_FALLING;
case CHANGE:
return EXTI_RISING_FALLING;
}
// Can't happen
ASSERT(0);
return (exti_trigger_mode)0;
}

View File

@@ -1,128 +0,0 @@
/******************************************************************************
* The MIT License
*
* Copyright (c) 2010 Perry Hung.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*****************************************************************************/
/**
* @file wirish/include/wirish/ext_interrupts.h
* @brief Wiring-like external interrupt prototypes and types.
*/
#ifndef _WIRISH_EXT_INTERRUPTS_H_
#define _WIRISH_EXT_INTERRUPTS_H_
#include <libmaple/libmaple_types.h>
#include <libmaple/nvic.h>
/**
* The kind of transition on an external pin which should trigger an
* interrupt.
*/
typedef enum ExtIntTriggerMode {
RISING, /**< To trigger an interrupt when the pin transitions LOW
to HIGH */
FALLING, /**< To trigger an interrupt when the pin transitions
HIGH to LOW */
CHANGE /**< To trigger an interrupt when the pin transitions from
LOW to HIGH or HIGH to LOW (i.e., when the pin
changes). */
} ExtIntTriggerMode;
/**
* @brief Registers an interrupt handler on a pin.
*
* The interrupt will be triggered on a given transition on the pin,
* as specified by the mode parameter. The handler runs in interrupt
* context. The new handler will replace whatever handler is
* currently registered for the pin, if any.
*
* @param pin Pin number
* @param handler Function to run upon external interrupt trigger.
* The handler should take no arguments, and have void
* return type.
* @param mode Type of transition to trigger on, e.g. falling, rising, etc.
*
* @sideeffect Registers a handler
* @see detachInterrupt()
*/
void attachInterrupt(uint8 pin, voidFuncPtr handler, ExtIntTriggerMode mode);
/**
* @brief Registers an interrupt handler on a pin.
*
* The interrupt will be triggered on a given transition on the pin,
* as specified by the mode parameter. The handler runs in interrupt
* context. The new handler will replace whatever handler is
* currently registered for the pin, if any.
*
* @param pin Pin number
* @param handler Static class member function to run upon external interrupt
* trigger. The handler should take 1 argument and return void
* @param arg Argument that the handler will be passed when it's called. One
* use of this is to pass the specific instance of the class that
* will handle the interrupt.
* @param mode Type of transition to trigger on, e.g. falling, rising, etc.
*
* @sideeffect Registers a handler
* @see detachInterrupt()
*/
void attachInterrupt(uint8 pin, voidArgumentFuncPtr handler, void *arg,
ExtIntTriggerMode mode);
/**
* @brief Disable any registered external interrupt.
* @param pin Maple pin number
* @sideeffect unregisters external interrupt handler
* @see attachInterrupt()
*/
void detachInterrupt(uint8 pin);
/**
* Re-enable interrupts.
*
* Call this after noInterrupts() to re-enable interrupt handling,
* after you have finished with a timing-critical section of code.
*
* @see noInterrupts()
*/
static inline __always_inline void interrupts() {
nvic_globalirq_enable();
}
/**
* Disable interrupts.
*
* After calling this function, all user-programmable interrupts will
* be disabled. You can call this function before a timing-critical
* section of code, then call interrupts() to re-enable interrupt
* handling.
*
* @see interrupts()
*/
static inline __always_inline void noInterrupts() {
nvic_globalirq_disable();
}
#endif

View File

@@ -1,31 +0,0 @@
/*
Copyright (c) 2012 Arduino. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/**
* Empty yield() hook.
*
* This function is intended to be used by library writers to build
* libraries or sketches that supports cooperative threads.
*
* Its defined as a weak symbol and it can be redefined to implement a
* real cooperative scheduler.
*/
static void __empty() {
// Empty
}
void yield(void) __attribute__ ((weak, alias("__empty")));

Some files were not shown because too many files have changed in this diff Show More