Skip to content

Commit 2174adf

Browse files
committed
Fix example not compiling, some improvements
1 parent 5b561e3 commit 2174adf

File tree

7 files changed

+129
-89
lines changed

7 files changed

+129
-89
lines changed

ChangeLog.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Changelog
2-
This page documents (nearly) all bugfixes and enhancements that produce visible changes in behavior throughout the history of megaTinyCore. Note that this document is maintained by a human, who is - by nature - imperfect (this is also why there are so many bugs to fix); sometimes the changelog may not be updated at the same time as the changes go in, and occasionally a change is missed entirely in the changelog, though this is rare. Change descriptions may be incomplete or unclear; this is not meant to be an indepth reference.
2+
This page documents (nearly) all bugfixes and enhancements that produce visible changes in behavior throughout the history of DxCore. Note that this document is maintained by a human, who is - by nature - imperfect (this is also why there are so many bugs to fix); sometimes the changelog may not be updated at the same time as the changes go in, and occasionally a change is missed entirely in the changelog, though this is rare. Change descriptions may be incomplete or unclear; this is not meant to be an indepth reference.
33

44
## Planned changes not yet implemented
55
These items are in addition to what was listed under changes already in release.
@@ -10,12 +10,13 @@ These items are in addition to what was listed under changes already in release.
1010
* Bugfix: Make serialupdi work with EA.
1111
* Enhancement: Implement sleep library
1212
* Re-add SPI attach and detach.
13-
* Ensure libraries in sync with DxCore.
13+
* Ensure libraries in sync with megaTinyCore.
1414

1515
## Planned changes implemented in github
1616
These are typically planned for release in a future version (usually the next one) as noted.
1717
* Update - was not gods of C, it was a gang of rogue peripherals. After being held captive and tortured by WEX Luther and his cronies, core developer has escaped said malicious preipherals. While held captive, my computer and equipment were sabotaged by their henchmen. Particular care in restraining WEX Luther to be taken to ensure that end users do not face such attacks.
1818
* Add support for not-yet-announced S class DA-series parts, which are identical but for having the new EB-series lockdown thingie. There are no changes needed.
19+
* Support for the PTC peripheral on DA parts
1920

2021
### 1.5.11 (Emergency fix)
2122
* At some point in the recent past, I must have angered the gods of C, and suddenly millis disabled stopped working - the system would hang (actually, with in-depth investigation, it was shown to be bootlooping - before it called init(), it was calling 0x0000 (a dirty reset) instead of eliding a weakly defined function with nothing in the body except a return, or with an empty body. Why was it doing this? And why only when millis was disabled?). millis disabled is a key piece of core functionality, necessitating an urgent fix. Moving the definitions into main.cpp resolved this issue. (#485)

megaavr/libraries/PTC/README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,15 @@ Different pins have a different parasitic capacitance. I suspect this is depends
122122
### Tuning of nodes
123123

124124
In order to ease the use of the PTC module, the ptc_add_* functions will initialize the cap_sensor_t struct with some default values, like the CC value mentioned above. That values can be easily changed and will be applied the next time a conversion of said node starts. Here is a list:
125-
- Analog Gain. Increases the sensitivity of the electrode by adjusting a capacitor on a integrator (I think) (1x Gain)
126-
- Digital Gain. Defines the amount of ADC Oversampling. Will not affect the count value, as it is internally right-shifted. (16x Oversampled)
127-
- Charge Share Delay. Affects the Sample length of the ADC. (0 extra clocks)
128-
- Prescaler. It is possible to slow down the ADC clock by adjusting the Prescaler. (Depends on CPU clock, targeted: 1MHz +/- 25%)
129-
- Serial Resistor. Allows to change the serial resistor between the Cc and the node. Fixed at 100k for Self-Cap. Creates RC-low-pass filter.
130-
131-
If a node is not sensitive enough, you can increase the Analog Gain (if it becomes too sensitive, an increase of the thresholds might be needed). However it is better to have a bigger node to begin with because the bigger the area, the higher is the capacitance delta.
125+
- `uint8_t ptc_node_set_gain(cap_sensor_t *node, ptc_gain_t gain)`. Increases the sensitivity of the electrode by adjusting a capacitor on the integrator (I think). Valid values are: `PTC_GAIN_1, PTC_GAIN_2, PTC_GAIN_4, PTC_GAIN_8, PTC_GAIN_16, PTC_GAIN_32 (Tiny only)`. Default: 1x Gain.
126+
- `uint8_t ptc_node_set_oversamples(cap_sensor_t *node, uint8_t ovs)`. Defines the amount of ADC Oversampling. Will not affect the count value, as it is internally right-shifted. Valid values are in the range from 0 to 6 resulting in 1x, 2x, 4x, 8x, 16x, 32x, 64x oversampling. Defaults to 16x.
127+
- `uint8_t ptc_node_set_charge_share_delay(cap_sensor_t *node, uint8_t csd)`. Affects the Sample length of the ADC. This does pretty much the same thing as ADC.SAMPCTRL register. Valid range is from 0 to 31. Defaults to 0 extra clocks
128+
- `uint8_t ptc_node_set_prescaler(cap_sensor_t *node, ptc_presc_t presc)`. It is possible to slow down the ADC/PTC clock by adjusting the Prescaler. The ADC/PTC Clock should be between 1 and 2 MHz. The library calculates the default based on F_CPU.
129+
Valid values for Tiny are: `PTC_PRESC_DIV2_gc, PTC_PRESC_DIV4_gc, PTC_PRESC_DIV8_gc, PTC_PRESC_DIV16_gc, PTC_PRESC_DIV32_gc, PTC_PRESC_DIV64_gc, PTC_PRESC_DIV128_gc, PTC_PRESC_DIV256_gc`
130+
Valid values for DA are: `PTC_PRESC_DIV2_gc, PTC_PRESC_DIV4_gc, PTC_PRESC_DIV6_gc, PTC_PRESC_DIV8_gc, PTC_PRESC_DIV10_gc, PTC_PRESC_DIV12_gc, PTC_PRESC_DIV14_gc, PTC_PRESC_DIV16_gc`
131+
- `uint8_t ptc_node_set_resistor(cap_sensor_t *node, ptc_rsel_t res)`. Allows to change the serial resistor between the Cc and the node. Fixed at 100k for Self-Cap. Defaults to 50k for Mutual-Cap. Valid Values are: `RSEL_VAL_0, RSEL_VAL_20, RSEL_VAL_50, RSEL_VAL_70, RSEL_VAL_80 (DA only), RSEL_VAL_100, RSEL_VAL_120 (DA only), RSEL_VAL_200`.
132+
133+
If a node is not sensitive enough, you can increase the Analog Gain (if it becomes too sensitive, an increase of the thresholds might be needed). However it is better to have a bigger electrode to begin with because the bigger the area, the higher is the capacitance delta.
132134

133135
### Global settings of the State-machine
134136
The state-machine, which changes the node's state between Calibration, touch, no touch, etc. uses some variables that are valid for all nodes, those are:

megaavr/libraries/PTC/examples/self_and_mutual_mix/self_and_mutual_mix.ino

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#include <ptc.h>
22
/*
33
* This example creates four different sensing nodes. of two different types.
4-
* PA4 and PA5 are the self-cap lines with PB0 acting as shield pin.
5-
* PA6 and PA7 are the Y-Lines with PB1 acting as the X-line.
4+
* PA4 and PA5 are the self-cap lines with PA0 acting as shield pin.
5+
* PA6 and PA7 are the Y-Lines with PA1 acting as the X-line.
66
* PTC_CB_EVENT_CONV_MUTUAL_CMPL and
77
* PTC_CB_EVENT_CONV_SHIELD_CMPL can be used to change the type that is converted.
88
* This will create an interlaced conversion, but it is not mandatory to do so.
@@ -16,11 +16,11 @@ cap_sensor_t nodes[4];
1616

1717
void setup() {
1818
// put your setup code here, to run once:
19-
ptc_add_selfcap_node(&nodes[0], PIN_TO_PTC(PIN_PB0), PIN_TO_PTC(PIN_PA4));
20-
ptc_add_selfcap_node(&nodes[1], PIN_TO_PTC(PIN_PB0), PIN_TO_PTC(PIN_PA5));
19+
ptc_add_selfcap_node(&nodes[0], PIN_TO_PTC(PIN_PA0), PIN_TO_PTC(PIN_PA4));
20+
ptc_add_selfcap_node(&nodes[1], PIN_TO_PTC(PIN_PA0), PIN_TO_PTC(PIN_PA5));
2121

22-
ptc_add_mutualcap_node(&nodes[2], PIN_TO_PTC(PIN_PB1), PIN_TO_PTC(PIN_PA6));
23-
ptc_add_mutualcap_node(&nodes[3], PIN_TO_PTC(PIN_PB1), PIN_TO_PTC(PIN_PA7));
22+
ptc_add_mutualcap_node(&nodes[2], PIN_TO_PTC(PIN_PA1), PIN_TO_PTC(PIN_PA6));
23+
ptc_add_mutualcap_node(&nodes[3], PIN_TO_PTC(PIN_PA1), PIN_TO_PTC(PIN_PA7));
2424

2525
MySerial.begin(115200);
2626
MySerial.println("Hello World!");

megaavr/libraries/PTC/src/ptc.c

Lines changed: 69 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,7 @@ void ptc_process_measurement(cap_sensor_t *node);
2929
// Handles (initial) calibration
3030
uint8_t ptc_process_calibrate(cap_sensor_t *node);
3131

32-
// Handles adjustment of the reference value when a button is not pressed
33-
void ptc_process_adjust();
3432

35-
void ptc_set_registers(cap_sensor_t *node);
3633

3734

3835
cap_sensor_t *firstNode = NULL;
@@ -73,19 +70,11 @@ ptc_lib_sm_set_t *ptc_get_sm_settings() {
7370
#if defined (__PTC_Tiny__)
7471
#define PTC_DEFAULT_SC_CC 0x0567
7572
#define PTC_DEFAULT_MC_CC 0x0234
76-
77-
const uint8_t ptc_a_gain_lut[] = {
78-
0x3F, 0x1C, 0x0B,
79-
0x05, 0x03, 0x01,
80-
};
73+
#define PTC_GAIN_BASE 0x003F
8174
#elif defined (__PTC_DA__)
8275
#define PTC_DEFAULT_SC_CC 0x00F0
8376
#define PTC_DEFAULT_MC_CC 0x00A0
84-
85-
const uint8_t ptc_a_gain_lut[] = {
86-
0x1F, 0x0F, 0x07,
87-
0x03, 0x01
88-
};
77+
#define PTC_GAIN_BASE 0x001F
8978
#endif
9079

9180

@@ -113,23 +102,28 @@ uint8_t ptc_node_set_thresholds(cap_sensor_t *node, int16_t th_in, int16_t th_ou
113102
if (NULL == node) {
114103
return PTC_LIB_BAD_POINTER;
115104
}
116-
node->touch_in_th = th_in;
117-
node->touch_out_th = th_out;
105+
if (th_in != 0) {
106+
node->touch_in_th = th_in;
107+
}
108+
if (th_out != 0) {
109+
node->touch_out_th = th_out;
110+
}
118111
return PTC_LIB_SUCCESS;
119112
}
120113

121114

122115
// Change Resistor Setting. Note: Only has an effect on mutual sensors
123-
uint8_t ptc_node_set_resistor(cap_sensor_t *node, uint8_t res) {
116+
uint8_t ptc_node_set_resistor(cap_sensor_t *node, ptc_rsel_t res) {
124117
PTC_CHECK_FOR_BAD_POINTER(node);
125118

126119
if (res > RSEL_MAX) {
127120
return PTC_LIB_BAD_ARGUMENT;
128121
}
129-
122+
res &= 0x0F;
123+
res <<= 0x04;
130124
if (node->type & NODE_MUTUAL_bm) {
131125
uint8_t presc = node->hw_rsel_presc & 0x0F;
132-
presc |= ((res & 0x0F) << 4);
126+
presc |= res;
133127
node->hw_rsel_presc = presc;
134128
return PTC_LIB_SUCCESS;
135129
}
@@ -139,50 +133,62 @@ uint8_t ptc_node_set_resistor(cap_sensor_t *node, uint8_t res) {
139133

140134

141135
// Change prescaler. Recommended ADC frequency: < 1.5MHz, but max 3 factors below
142-
uint8_t ptc_node_set_prescaler(cap_sensor_t *node, uint8_t presc) {
136+
uint8_t ptc_node_set_prescaler(cap_sensor_t *node, ptc_presc_t presc) {
143137
PTC_CHECK_FOR_BAD_POINTER(node);
144138

145139
if ((presc > (PTC_PRESC_DEFAULT + 2)) || (presc < PTC_PRESC_DEFAULT)) {
146140
return PTC_LIB_BAD_ARGUMENT;
147141
}
148-
142+
presc &= 0x0F;
149143
uint8_t res = node->hw_rsel_presc & 0xF0;
150-
res |= (presc & 0x0F);
144+
res |= presc;
151145
node->hw_rsel_presc = res;
152146
return PTC_LIB_SUCCESS;
153147
}
154148

155149

156-
uint8_t ptc_node_set_gain(cap_sensor_t *node, uint8_t aGain, uint8_t dGain) {
150+
uint8_t ptc_node_set_gain(cap_sensor_t *node, ptc_gain_t gain) {
157151
PTC_CHECK_FOR_BAD_POINTER(node);
158152

159-
#if defined (__PTC_Tiny__)
160-
if (aGain > 0x05) {
161-
if (__builtin_constant_p(aGain)) {
162-
badArg("Analog Gain too high. Max Analog Gain Value is 0x05 (equals 32x)");
153+
if (gain >= PTC_GAIN_MAX) {
154+
if (__builtin_constant_p(gain)) {
155+
badArg("Analog Gain too high. Max Analog Gain Value is 0x3F (Tiny) / 0x1F (DA)");
163156
}
164157
return PTC_LIB_BAD_ARGUMENT;
165158
}
166-
#elif defined (__PTC_DA__)
167-
if (aGain > 0x04) {
168-
if (__builtin_constant_p(aGain)) {
169-
badArg("Analog Gain too high. Max Analog Gain Value is 0x04 (equals 16x)");
170-
}
171-
return PTC_LIB_BAD_ARGUMENT;
172-
}
173-
#endif
159+
gain = PTC_GAIN_MAX - gain;
160+
gain <<= 4;
161+
uint8_t ovs = node->hw_gain_ovs & 0x0F;
162+
node->hw_gain_ovs = gain | ovs;
163+
return PTC_LIB_SUCCESS;
164+
}
165+
166+
uint8_t ptc_node_set_oversamples(cap_sensor_t *node, uint8_t ovs) {
167+
PTC_CHECK_FOR_BAD_POINTER(node);
174168

175-
if (dGain > 0x06) {
176-
if (__builtin_constant_p(dGain)) {
169+
if (ovs > 0x06) {
170+
if (__builtin_constant_p(ovs)) {
177171
badArg("Digital Gain too high. Max Digital Gain Value is 0x06 (equals 64x)");
178172
}
179173
return PTC_LIB_BAD_ARGUMENT;
180174
}
181-
node->hw_a_d_gain = NODE_GAIN(aGain, dGain);
175+
uint8_t gain = node->hw_gain_ovs & 0xF0;
176+
node->hw_gain_ovs = gain | ovs;
182177
return PTC_LIB_SUCCESS;
183178
}
184179

180+
uint8_t ptc_node_set_charge_share_delay(cap_sensor_t *node, uint8_t csd) {
181+
PTC_CHECK_FOR_BAD_POINTER(node);
182+
if (ovs > 15) {
183+
if (__builtin_constant_p(ovs)) {
184+
badArg("Charge Share Delay too high, maximum value is 15");
185+
}
186+
return PTC_LIB_BAD_ARGUMENT;
187+
}
185188

189+
node->hw_csd = hw_csd;
190+
return PTC_LIB_SUCCESS;
191+
}
186192

187193
/*
188194
* Two functions to suspend and resume of the normal PTC operation, however,
@@ -291,7 +297,7 @@ uint8_t ptc_add_node(cap_sensor_t *node, uint8_t *pCh, const uint8_t type) {
291297
}
292298
#endif
293299

294-
node->hw_a_d_gain = NODE_GAIN(0, ADC_SAMPNUM_ACC16_gc);
300+
node->hw_gain_ovs = NODE_GAIN(0, ADC_SAMPNUM_ACC16_gc);
295301

296302
if (type & NODE_MUTUAL_bm) {
297303
node->touch_in_th = 10;
@@ -878,7 +884,7 @@ void ptc_init_conversion(uint8_t nodeType) {
878884
if (NULL != lowPowerNode) {
879885
pPTC->INTCTRL = ADC_WCMP_bm; // Wakeup only above of window
880886
pPTC->CTRLE = ADC_WINCM_ABOVE_gc;
881-
pPTC->WINHT = (lowPowerNode->reference + lowPowerNode->touch_in_th) << (lowPowerNode->hw_a_d_gain & 0x0F);
887+
pPTC->WINHT = (lowPowerNode->reference + lowPowerNode->touch_in_th) << (lowPowerNode->hw_gain_ovs & 0x0F);
882888
ptc_lib_state = PTC_LIB_EVENT;
883889
ptc_start_conversion(lowPowerNode);
884890
} else {
@@ -924,7 +930,7 @@ void ptc_init_conversion(uint8_t nodeType) {
924930
if (NULL != lowPowerNode) {
925931
pPTC->INTCTRL = ADC_WCMP_bm; // Wakeup only above of window
926932
pPTC->CTRLE = ADC_WINCM_ABOVE_gc;
927-
pPTC->WINHT = (lowPowerNode->reference + lowPowerNode->touch_in_th) << (lowPowerNode->hw_a_d_gain & 0x0F);
933+
pPTC->WINHT = (lowPowerNode->reference + lowPowerNode->touch_in_th) << (lowPowerNode->hw_gain_ovs & 0x0F);
928934
ptc_lib_state = PTC_LIB_EVENT;
929935
ptc_start_conversion(lowPowerNode);
930936
} else {
@@ -951,25 +957,15 @@ void ptc_start_conversion(cap_sensor_t *node) {
951957
}
952958

953959
currConvNode = node;
954-
955-
ptc_set_registers(node);
956-
}
957-
958-
void ptc_set_registers(cap_sensor_t *node) {
960+
959961
PTC_t *pPTC;
960-
_fastPtr_d(node, node); // Sometimes it takes the compiler a bit more of convincing...
961962
_fastPtr_d(pPTC, &PTC);
962-
963-
if (NULL == node) {
964-
return;
963+
_fastPtr_d(node, node);
964+
uint8_t analogGain = PTC_GAIN_MAX;
965+
if (node->stateMachine != PTC_SM_NOINIT_CAL) {
966+
analogGain = node->hw_gain_ovs / 16; // A little workaround as >> 4 is kinda broken sometimes.
965967
}
966968

967-
uint8_t lut_index = 0;
968-
if ((node->state.disabled == 0) && (node->stateMachine != PTC_SM_NOINIT_CAL)) {
969-
lut_index = node->hw_a_d_gain / 16; // A little workaround as >> 4 is kinda broken sometimes.
970-
}
971-
uint8_t analogGain = ptc_a_gain_lut[lut_index];
972-
973969
uint8_t chargeDelay = node->hw_csd;
974970

975971
#if defined(__PTC_Tiny__)
@@ -988,10 +984,23 @@ void ptc_set_registers(cap_sensor_t *node) {
988984
pPTC->CTRLP |= 0x03;
989985

990986
#elif defined(__PTC_DA__)
991-
memcpy((void *)pPTC->XBM, node->hw_xCh_bm, sizeof(ptc_ch_arr_t));
992-
memcpy((void *)pPTC->YBM, node->hw_yCh_bm, sizeof(ptc_ch_arr_t));
987+
((uint8_t*)&pPTC->XBM)[0] = node->hw_xCh_bm[0]; // avoid memcpy to reduce register pressure
988+
((uint8_t*)&pPTC->XBM)[1] = node->hw_xCh_bm[1]; // avoiding memcpy means we can put &PTC
989+
((uint8_t*)&pPTC->XBM)[2] = node->hw_xCh_bm[2]; // and node in the Z/Y-Registers and just use
990+
((uint8_t*)&pPTC->XBM)[3] = node->hw_xCh_bm[3]; // the fast and memory efficient std/ldd instructions
991+
((uint8_t*)&pPTC->XBM)[4] = node->hw_xCh_bm[4];
992+
993+
((uint8_t*)&pPTC->YBM)[0] = node->hw_yCh_bm[0];
994+
((uint8_t*)&pPTC->YBM)[1] = node->hw_yCh_bm[1];
995+
((uint8_t*)&pPTC->YBM)[2] = node->hw_yCh_bm[2];
996+
((uint8_t*)&pPTC->YBM)[3] = node->hw_yCh_bm[3];
997+
((uint8_t*)&pPTC->YBM)[4] = node->hw_yCh_bm[4];
998+
#if __PTC_Pincount__ >= 40
999+
((uint8_t*)&pPTC->XBM)[5] = node->hw_xCh_bm[5];
1000+
((uint8_t*)&pPTC->YBM)[5] = node->hw_yCh_bm[5];
1001+
#endif
9931002

994-
if (chargeDelay < 0x7B) {
1003+
if (chargeDelay < 0x1B) {
9951004
chargeDelay += 4;
9961005
} else {
9971006
chargeDelay = 0x1F;
@@ -1014,7 +1023,7 @@ void ptc_set_registers(cap_sensor_t *node) {
10141023

10151024
pPTC->COMP = node->hw_compCaps;
10161025
pPTC->AGAIN = analogGain;
1017-
pPTC->CTRLB = node->hw_a_d_gain & 0x0F;
1026+
pPTC->CTRLB = node->hw_gain_ovs & 0x0F;
10181027
pPTC->RSEL = node->hw_rsel_presc / 16;
10191028

10201029
pPTC->CTRLA = ADC_RUNSTBY_bm | ADC_ENABLE_bm; /* 0x81 */
@@ -1076,7 +1085,7 @@ void ptc_eoc(void) {
10761085
pPTC->CTRLA = 0x00;
10771086
uint8_t flags = pPTC->INTFLAGS; // save the flags before they get cleared by RES read
10781087
uint16_t rawVal = pPTC->RES; // clears ISR flags
1079-
uint8_t oversampling = pCurrentNode->hw_a_d_gain & 0x0F;
1088+
uint8_t oversampling = pCurrentNode->hw_gain_ovs & 0x0F;
10801089
pCurrentNode->sensorData = rawVal >> oversampling;
10811090

10821091
//currConvNode->sensorData = pPTC->RES_TRUE;

megaavr/libraries/PTC/src/ptc.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,17 +97,25 @@ void ptc_set_next_conversion_type(ptc_node_type_t type);
9797
void ptc_process(uint16_t currTime);
9898

9999

100-
// Set the threshold for touch detection and away from touch for a node
100+
// Set the threshold for touch detection and away from touch for a node.
101+
// a "0" will be interpreted as don't change
101102
uint8_t ptc_node_set_thresholds(cap_sensor_t *node, int16_t th_in, int16_t th_out);
102103

103104

104105
// Change Resistor Setting. Note: Only has an effect on mutual sensors
105-
uint8_t ptc_node_set_resistor(cap_sensor_t *node, uint8_t res);
106+
uint8_t ptc_node_set_resistor(cap_sensor_t *node, ptc_rsel_t res);
106107

107108
// Change prescaler.
108-
uint8_t ptc_node_set_prescaler(cap_sensor_t *node, uint8_t presc);
109+
uint8_t ptc_node_set_prescaler(cap_sensor_t *node, ptc_presc_t presc);
109110

110-
uint8_t ptc_node_set_gain(cap_sensor_t *node, uint8_t aGain, uint8_t dGain);
111+
// Sets the gain through adjusting the charge integrator (increases the sensitivity (and noise))
112+
uint8_t ptc_node_set_gain(cap_sensor_t *node, ptc_gain_t gain);
113+
114+
// Sets the number of oversamples. (the value is right-shifted automatically (reduces noise))
115+
uint8_t ptc_node_set_oversamples(cap_sensor_t *node, uint8_t ovs);
116+
117+
// Sets the number of additional PTC Clocks for sampling a node. See also: ADC.SAMPCTRL
118+
uint8_t ptc_node_set_charge_share_delay(cap_sensor_t *node, uint8_t csd);
111119

112120
// this is an internal function, there is no sense in calling it directly
113121
uint8_t ptc_add_node(cap_sensor_t *node, uint8_t *pCh, const uint8_t type);

megaavr/libraries/PTC/src/ptc_io.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,13 @@ typedef struct PTC_struct {
5656
#define PRSC_MAX ADC_PRESC_DIV256_gc
5757

5858
#if F_CPU >= 12000000 // 16 MHz / 16 = 1.0 MHz, 20 MHz / 16 = 1.25 MHz
59-
#define PTC_PRESC_DEFAULT ADC_PRESC_DIV16_gc
59+
#define PTC_PRESC_DEFAULT PTC_PRESC_DIV16_gc
6060
#elif F_CPU >= 6000000 // 8 MHz / 8 = 1.0 MHz, 10 MHz / 8 = 1.25 MHz
61-
#define PTC_PRESC_DEFAULT ADC_PRESC_DIV8_gc
61+
#define PTC_PRESC_DEFAULT PTC_PRESC_DIV8_gc
6262
#elif F_CPU >= 3000000 // 4 MHz / 4 = 1.0 MHz, 5 MHz / 4 = 1.25 MHz
63-
#define PTC_PRESC_DEFAULT ADC_PRESC_DIV4_gc
63+
#define PTC_PRESC_DEFAULT PTC_PRESC_DIV4_gc
6464
#else // 1 MHz / 2 = 500 kHz - the lowest setting
65-
#define PTC_PRESC_DEFAULT ADC_PRESC_DIV2_gc
65+
#define PTC_PRESC_DEFAULT PTC_PRESC_DIV2_gc
6666
#endif
6767

6868
#elif defined (__PTC_DA__)

0 commit comments

Comments
 (0)