|
29 | 29 | #define CLOCK_TUNE_START (USER_SIGNATURES_SIZE - 12) |
30 | 30 |
|
31 | 31 | #include "core_devices.h" |
32 | | -/* Gives names to all the timer pins - relies on core_devices.h being included first.*/ |
33 | | -/* These names look like: |
34 | | - * PIN_TCD0_WOC_DEFAULT |
35 | | - * PIN_TCA0_WO5_ALT3 |
36 | | - * and so on. |
37 | | - * They are #defines. Pins that don't exist are #defined as NOT_A_PIN. |
38 | | - * TCA and TCD only currently */ |
| 32 | + |
39 | 33 | #include <avr/pgmspace.h> |
40 | 34 | #include <avr/interrupt.h> |
41 | 35 |
|
|
82 | 76 | void check_constant_pin(__attribute__((unused))pin_size_t pin) { |
83 | 77 | return; |
84 | 78 | } |
85 | | - #endif // Intentionally outside of the above #if so that your console gets fucking spammed with this warning. |
| 79 | + #endif // Intentionally outside of the above #_if so that your console gets fucking spammed with this warning. |
86 | 80 | // The linker errors you turned off LTO to better understand will still be at the bottom. |
87 | 81 | #warning "LTO is disabled. digitalWriteFast(), digitalReadFast(), pinModeFast() and openDrainFast() are unavailable, delayMicroseconds() for short delays and delay() with millis timing disabled is less accuratetest. Unsupported forms of 'new' compile without errors (but always return a NULL pointer). Additionally, functions which normally generate a compile error when passed a value that is known to be invalid at compile time will not do so. The same is true of functions which are not valid with the currently selected tools submenu options." |
88 | 82 | #warning "This mode is ONLY for debugging LINK-TIME ERRORS that are reported by the linker as being located at .text+0, and you can't figure out where the bug is from other information it provides. As noted above, while this may make compilation succeed, it will only turn compile-time errors into incorrect runtime behavior, which is much harder to debug. As soon as the bug that forced this to be used is fixed, switch back to the standard platform.txt!" |
|
219 | 213 | #define _ADC_LOWLAT_VAL 0x04 |
220 | 214 | #define _ADC_ENABLE_VAL 0x10 |
221 | 215 | #define _ADC_ENABLE_CTRL 0x20 |
222 | | - #define _ADC_STANDBY_VAL 0X40 |
| 216 | + #define _ADC_STANDBY_VAL 0x40 |
223 | 217 | #define _ADC_STANDBY_CTRL 0x80 |
224 | 218 | #define PGA_OFF_ONCE 0x01 |
225 | 219 | #define PGA_KEEP_ON 0x02 |
@@ -725,7 +719,7 @@ See Ref_Analog.md for more information of the representations of "analog pins". |
725 | 719 | #define portOutputRegister(P) ((volatile uint8_t *)(&portToPortStruct(P)->OUT)) |
726 | 720 | #define portInputRegister(P) ((volatile uint8_t *)(&portToPortStruct(P)->IN )) |
727 | 721 | #define portModeRegister(P) ((volatile uint8_t *)(&portToPortStruct(P)->DIR)) |
728 | | -#if defined(PORTA_EVGENCTRL) //Ex-series only - this all may belong in the Event library anyway, but since the conditional is never met, this code is never used. |
| 722 | +#if defined(PORTA_EVGENCTRLA) //Ex-series only - this all may belong in the Event library anyway, but since the conditional is never met, this code is never used. |
729 | 723 | #define portEventRegister(p) ((volatile uint8_t *)(&portToPortStruct(P)->EVGENCTRL)) |
730 | 724 | uint8_t _setRTCEventChan(uint8_t val, uint8_t chan); |
731 | 725 | uint8_t _setEventPin(uint8_t pin, uint8_t number); // preliminary thought - pass a pin number, it looks up port, and from there the event control register and sets it. |
@@ -927,123 +921,123 @@ void _pinconfigure(uint8_t pin, uint16_t pin_config); |
927 | 921 | void pinConfigure(uint8_t digital_pin, uint16_t pin_config); |
928 | 922 |
|
929 | 923 | #ifdef __cplusplus |
930 | | -typedef enum : uint16_t |
931 | | -{ |
932 | | - // OUTPUT |
933 | | - PIN_DIR_SET = 0x0001, |
934 | | - PIN_DIRSET = 0x0001, |
935 | | - PIN_DIR_OUTPUT = 0x0001, |
936 | | - PIN_DIR_OUT = 0x0001, |
937 | | - // INPUT |
938 | | - PIN_DIR_CLR = 0x0002, |
939 | | - PIN_DIRCLR = 0x0002, |
940 | | - PIN_DIR_INPUT = 0x0002, |
941 | | - PIN_DIR_IN = 0x0002, |
942 | | - // TOGGLE INPUT/OUTPUT |
943 | | - PIN_DIR_TGL = 0x0003, |
944 | | - PIN_DIRTGL = 0x0003, |
945 | | - PIN_DIR_TOGGLE = 0x0003, |
946 | | - // HIGH |
947 | | - PIN_OUT_SET = 0x0004, |
948 | | - PIN_OUTSET = 0x0004, |
949 | | - PIN_OUT_HIGH = 0x0004, |
950 | | - // LOW |
951 | | - PIN_OUT_CLR = 0x0008, |
952 | | - PIN_OUTCLR = 0x0008, |
953 | | - PIN_OUT_LOW = 0x0008, |
954 | | -// CHANGE/TOGGLE |
955 | | - PIN_OUT_TGL = 0x000C, |
956 | | - PIN_OUTTGL = 0x000C, |
957 | | - PIN_OUT_TOGGLE = 0x000C, |
958 | | -//Interrupt disabled but input buffer enabled |
959 | | - PIN_ISC_ENABLE = 0x0080, |
960 | | - PIN_INPUT_ENABLE = 0x0080, |
961 | | - // Interrupt on change |
962 | | - PIN_ISC_CHANGE = 0x0090, |
963 | | - PIN_INT_CHANGE = 0x0090, |
964 | | -// Interrupt on rising edge |
965 | | - PIN_ISC_RISE = 0x00A0, |
966 | | - PIN_INT_RISE = 0x00A0, |
967 | | -// Interrupt on falling edge |
968 | | - PIN_ISC_FALL = 0x00B0, |
969 | | - PIN_INT_FALL = 0x00B0, |
970 | | -// Interrupt and input buffer disabled |
971 | | - PIN_ISC_DISABLE = 0x00C0, |
972 | | - PIN_INPUT_DISABLE = 0x00C0, |
973 | | -// Interrupt enabled with sense on low level |
974 | | - PIN_ISC_LEVEL = 0x00D0, |
975 | | - PIN_INT_LEVEL = 0x00D0, |
976 | | -// PULLUP ON |
977 | | - PIN_PULLUP_ON = 0x0100, |
978 | | - PIN_PULLUP = 0x0100, |
979 | | - PIN_PULLUP_SET = 0x0100, |
980 | | -// PULLUP OFF |
981 | | - PIN_PULLUP_OFF = 0x0200, |
982 | | - PIN_PULLUP_CLR = 0x0200, |
983 | | -// PULLUP TOGGLE |
984 | | - PIN_PULLUP_TGL = 0x0300, |
985 | | - PIN_PULLUP_TOGGLE = 0x0300, |
986 | | - PIN_NOPULLUP = 0x0200, |
987 | | -// Pin Input Level Control |
988 | | - PIN_INLVL_TTL = 0x1000, |
989 | | - PIN_INLVL_ON = 0x1000, |
990 | | - PIN_INLVL_SET = 0x1000, |
991 | | - PIN_INLVL_SCHMITT = 0x2000, |
992 | | - PIN_INLVL_OFF = 0x2000, |
993 | | - PIN_INLVL_CLR = 0x2000, // alias |
994 | | -// PIN INVERT ON |
995 | | - PIN_INVERT_ON = 0x4000, |
996 | | - PIN_INVERT_SET = 0x4000, |
997 | | -// PIN INVERT OFF |
998 | | - PIN_INVERT_OFF = 0x8000, |
999 | | - PIN_INVERT_CLR = 0x8000, |
1000 | | -// PIN_INVERT_TOGGLE |
1001 | | - PIN_INVERT_TGL = 0xC000, |
1002 | | - PIN_INVERT_TOGGLE = 0xC000 |
1003 | | -} pin_configure_t; |
1004 | | - |
1005 | | -/** |
1006 | | - * @brief Helper functions to catch the last argument in the pincfg recursion loop |
1007 | | - * |
1008 | | - * @param mode Mode parameter |
1009 | | - * @return pin_configure_t |
1010 | | - */ |
1011 | | - |
1012 | | - |
1013 | | -inline pin_configure_t _pincfg(const pin_configure_t mode) { |
1014 | | - return mode; |
1015 | | -} |
| 924 | + typedef enum : uint16_t |
| 925 | + { |
| 926 | + // OUTPUT |
| 927 | + PIN_DIR_SET = 0x0001, |
| 928 | + PIN_DIRSET = 0x0001, |
| 929 | + PIN_DIR_OUTPUT = 0x0001, |
| 930 | + PIN_DIR_OUT = 0x0001, |
| 931 | + // INPUT |
| 932 | + PIN_DIR_CLR = 0x0002, |
| 933 | + PIN_DIRCLR = 0x0002, |
| 934 | + PIN_DIR_INPUT = 0x0002, |
| 935 | + PIN_DIR_IN = 0x0002, |
| 936 | + // TOGGLE INPUT/OUTPUT |
| 937 | + PIN_DIR_TGL = 0x0003, |
| 938 | + PIN_DIRTGL = 0x0003, |
| 939 | + PIN_DIR_TOGGLE = 0x0003, |
| 940 | + // HIGH |
| 941 | + PIN_OUT_SET = 0x0004, |
| 942 | + PIN_OUTSET = 0x0004, |
| 943 | + PIN_OUT_HIGH = 0x0004, |
| 944 | + // LOW |
| 945 | + PIN_OUT_CLR = 0x0008, |
| 946 | + PIN_OUTCLR = 0x0008, |
| 947 | + PIN_OUT_LOW = 0x0008, |
| 948 | + // CHANGE/TOGGLE |
| 949 | + PIN_OUT_TGL = 0x000C, |
| 950 | + PIN_OUTTGL = 0x000C, |
| 951 | + PIN_OUT_TOGGLE = 0x000C, |
| 952 | + //Interrupt disabled but input buffer enabled |
| 953 | + PIN_ISC_ENABLE = 0x0080, |
| 954 | + PIN_INPUT_ENABLE = 0x0080, |
| 955 | + // Interrupt on change |
| 956 | + PIN_ISC_CHANGE = 0x0090, |
| 957 | + PIN_INT_CHANGE = 0x0090, |
| 958 | + // Interrupt on rising edge |
| 959 | + PIN_ISC_RISE = 0x00A0, |
| 960 | + PIN_INT_RISE = 0x00A0, |
| 961 | + // Interrupt on falling edge |
| 962 | + PIN_ISC_FALL = 0x00B0, |
| 963 | + PIN_INT_FALL = 0x00B0, |
| 964 | + // Interrupt and input buffer disabled |
| 965 | + PIN_ISC_DISABLE = 0x00C0, |
| 966 | + PIN_INPUT_DISABLE = 0x00C0, |
| 967 | + // Interrupt enabled with sense on low level |
| 968 | + PIN_ISC_LEVEL = 0x00D0, |
| 969 | + PIN_INT_LEVEL = 0x00D0, |
| 970 | + // PULLUP ON |
| 971 | + PIN_PULLUP_ON = 0x0100, |
| 972 | + PIN_PULLUP = 0x0100, |
| 973 | + PIN_PULLUP_SET = 0x0100, |
| 974 | + // PULLUP OFF |
| 975 | + PIN_PULLUP_OFF = 0x0200, |
| 976 | + PIN_PULLUP_CLR = 0x0200, |
| 977 | + // PULLUP TOGGLE |
| 978 | + PIN_PULLUP_TGL = 0x0300, |
| 979 | + PIN_PULLUP_TOGGLE = 0x0300, |
| 980 | + PIN_NOPULLUP = 0x0200, |
| 981 | + // Pin Input Level Control |
| 982 | + PIN_INLVL_TTL = 0x1000, |
| 983 | + PIN_INLVL_ON = 0x1000, |
| 984 | + PIN_INLVL_SET = 0x1000, |
| 985 | + PIN_INLVL_SCHMITT = 0x2000, |
| 986 | + PIN_INLVL_OFF = 0x2000, |
| 987 | + PIN_INLVL_CLR = 0x2000, // alias |
| 988 | + // PIN INVERT ON |
| 989 | + PIN_INVERT_ON = 0x4000, |
| 990 | + PIN_INVERT_SET = 0x4000, |
| 991 | + // PIN INVERT OFF |
| 992 | + PIN_INVERT_OFF = 0x8000, |
| 993 | + PIN_INVERT_CLR = 0x8000, |
| 994 | + // PIN_INVERT_TOGGLE |
| 995 | + PIN_INVERT_TGL = 0xC000, |
| 996 | + PIN_INVERT_TOGGLE = 0xC000 |
| 997 | + } pin_configure_t; |
| 998 | + |
| 999 | + /** |
| 1000 | + * @brief Helper functions to catch the last argument in the pincfg recursion loop |
| 1001 | + * |
| 1002 | + * @param mode Mode parameter |
| 1003 | + * @return pin_configure_t |
| 1004 | + */ |
| 1005 | + |
| 1006 | + |
| 1007 | + inline pin_configure_t _pincfg(const pin_configure_t mode) { |
| 1008 | + return mode; |
| 1009 | + } |
1016 | 1010 |
|
1017 | | -/** |
1018 | | - * @brief Helper functions to catch the nth in the pincfg recursion loop |
1019 | | - * |
1020 | | - * @param digital_pin Arduino pin |
1021 | | - * @param mode First "mode" parameter |
1022 | | - * @param modes Nth "mode" parameter |
1023 | | - * @return uint16_t pin configuration or'ed together |
1024 | | - */ |
1025 | | -template <typename... MODES> |
1026 | | -uint16_t _pincfg(const pin_configure_t mode, const MODES&... modes) { |
1027 | | - return mode | _pincfg(modes...); |
1028 | | -} |
| 1011 | + /** |
| 1012 | + * @brief Helper functions to catch the nth in the pincfg recursion loop |
| 1013 | + * |
| 1014 | + * @param digital_pin Arduino pin |
| 1015 | + * @param mode First "mode" parameter |
| 1016 | + * @param modes Nth "mode" parameter |
| 1017 | + * @return uint16_t pin configuration or'ed together |
| 1018 | + */ |
| 1019 | + template <typename... MODES> |
| 1020 | + uint16_t _pincfg(const pin_configure_t mode, const MODES&... modes) { |
| 1021 | + return mode | _pincfg(modes...); |
| 1022 | + } |
1029 | 1023 |
|
1030 | 1024 |
|
1031 | 1025 |
|
1032 | | -//void pinConfigure(const uint8_t pinNumber, const uint16_t mode, const MODES&... modes); |
| 1026 | + //void pinConfigure(const uint8_t pinNumber, const uint16_t mode, const MODES&... modes); |
1033 | 1027 |
|
1034 | | -/** |
1035 | | - * @brief Variadic template function for configuring a pin |
1036 | | - * |
1037 | | - * @param digital_pin Arduino pin number |
1038 | | - * @param mode First "mode" parameter |
1039 | | - * @param modes Nth "mode" parameter |
1040 | | - */ |
1041 | | -template <typename... MODES> |
1042 | | -void pinConfigure(const uint8_t digital_pin, const pin_configure_t mode, const MODES&... modes) { |
1043 | | - // Or-ing together the arguments using recursion |
1044 | | - uint16_t pin_config = _pincfg(mode, modes...); |
1045 | | - _pinconfigure(digital_pin, pin_config); |
1046 | | -} |
| 1028 | + /** |
| 1029 | + * @brief Variadic template function for configuring a pin |
| 1030 | + * |
| 1031 | + * @param digital_pin Arduino pin number |
| 1032 | + * @param mode First "mode" parameter |
| 1033 | + * @param modes Nth "mode" parameter |
| 1034 | + */ |
| 1035 | + template <typename... MODES> |
| 1036 | + void pinConfigure(const uint8_t digital_pin, const pin_configure_t mode, const MODES&... modes) { |
| 1037 | + // Or-ing together the arguments using recursion |
| 1038 | + uint16_t pin_config = _pincfg(mode, modes...); |
| 1039 | + _pinconfigure(digital_pin, pin_config); |
| 1040 | + } |
1047 | 1041 | #endif // end |
1048 | 1042 |
|
1049 | 1043 |
|
|
0 commit comments