diff --git a/megaavr/libraries/PTC/examples/mutualcap/mutualcap.ino b/megaavr/libraries/PTC/examples/mutualcap/mutualcap.ino index 777193b5..14663f31 100644 --- a/megaavr/libraries/PTC/examples/mutualcap/mutualcap.ino +++ b/megaavr/libraries/PTC/examples/mutualcap/mutualcap.ino @@ -8,7 +8,7 @@ * otherwise the handling of the successive nodes would be delayed. */ #define MySerial Serial - +#if !defined(MILLIS_USE_TIMERNONE) cap_sensor_t nodes[2]; void setup() { @@ -58,3 +58,10 @@ void ptc_event_cb_calibration(const ptc_cb_event_t eventType, cap_sensor_t *node MySerial.print(" Node: "); MySerial.println(ptc_get_node_id(node)); } +#else +void setup() { +} +void loop () { +} +#endif + diff --git a/megaavr/libraries/PTC/examples/mutualcap_low_power/mutualcap_low_power.ino b/megaavr/libraries/PTC/examples/mutualcap_low_power/mutualcap_low_power.ino index 90d414a6..f418924a 100644 --- a/megaavr/libraries/PTC/examples/mutualcap_low_power/mutualcap_low_power.ino +++ b/megaavr/libraries/PTC/examples/mutualcap_low_power/mutualcap_low_power.ino @@ -8,7 +8,7 @@ * PA4 is the X-Line, while PA5, PA6 and PA7 act as Y-Line. */ #define MySerial Serial - +#if !defined(MILLIS_USE_TIMERNONE) cap_sensor_t nodes[3]; cap_sensor_t lp_node; // as an example, could also be part of the array above @@ -91,10 +91,17 @@ void ptc_event_cb_calibration(const ptc_cb_event_t eventType, cap_sensor_t *node } void ptc_event_cb_wake(const ptc_cb_event_t eventType, cap_sensor_t *node) { - if (PTC_CB_EVENT_WAKE_TOUCH == eventType) { - // True if the node was touched when a wakeup occurred + if (PTC_CB_EVENT_WAKE_TOUCH == eventType) { + // True if the node was touched when a wakeup occurred } else if (PTC_CB_EVENT_WAKE_NO_TOUCH == eventType) { // True if the node was no touch when a wakeup occurred } (void)node; // remove unused warning } +#else +void setup() { +} +void loop () { +} +#endif + diff --git a/megaavr/libraries/PTC/examples/self_and_mutual_mix/self_and_mutual_mix.ino b/megaavr/libraries/PTC/examples/self_and_mutual_mix/self_and_mutual_mix.ino index ecf8df29..160c078f 100644 --- a/megaavr/libraries/PTC/examples/self_and_mutual_mix/self_and_mutual_mix.ino +++ b/megaavr/libraries/PTC/examples/self_and_mutual_mix/self_and_mutual_mix.ino @@ -10,6 +10,7 @@ #define MySerial Serial +#if !defined(MILLIS_USE_TIMERNONE) cap_sensor_t nodes[4]; @@ -65,3 +66,10 @@ void ptc_event_cb_calibration(const ptc_cb_event_t eventType, cap_sensor_t *node MySerial.print(" Node: "); MySerial.println(ptc_get_node_id(node)); } +#else +void setup() { +} +void loop () { +} +#endif + diff --git a/megaavr/libraries/PTC/examples/selfcap/selfcap.ino b/megaavr/libraries/PTC/examples/selfcap/selfcap.ino index 06d90c15..d01f654c 100644 --- a/megaavr/libraries/PTC/examples/selfcap/selfcap.ino +++ b/megaavr/libraries/PTC/examples/selfcap/selfcap.ino @@ -8,7 +8,7 @@ * otherwise the handling of the successive nodes would be delayed. */ #define MySerial Serial - +#if !defined(MILLIS_USE_TIMERNONE) cap_sensor_t nodes[3]; void setup() { @@ -60,3 +60,9 @@ void ptc_event_cb_calibration(const ptc_cb_event_t eventType, cap_sensor_t *node MySerial.print(" Node: "); MySerial.println(ptc_get_node_id(node)); } +#else +void setup() { +} +void loop () { +} +#endif diff --git a/megaavr/libraries/PTC/examples/selfcap_other_nodes_shield/selfcap_other_nodes_shield.ino b/megaavr/libraries/PTC/examples/selfcap_other_nodes_shield/selfcap_other_nodes_shield.ino index cefd8c56..56b8c8b3 100644 --- a/megaavr/libraries/PTC/examples/selfcap_other_nodes_shield/selfcap_other_nodes_shield.ino +++ b/megaavr/libraries/PTC/examples/selfcap_other_nodes_shield/selfcap_other_nodes_shield.ino @@ -10,7 +10,7 @@ * as shield. This improves the signal-to-noise ratio. */ #define MySerial Serial - +#if !defined(MILLIS_USE_TIMERNONE) cap_sensor_t nodes[3]; void setup() { @@ -54,3 +54,10 @@ void ptc_event_callback(const ptc_cb_event_t eventType, cap_sensor_t *node) { MySerial.println(ptc_get_node_id(node)); } } +#else +void setup() { +} +void loop () { +} +#endif + diff --git a/megaavr/libraries/PTC/examples/selfcap_with_dedicated_shield/selfcap_with_dedicated_shield.ino b/megaavr/libraries/PTC/examples/selfcap_with_dedicated_shield/selfcap_with_dedicated_shield.ino index e6522c9f..659c0858 100644 --- a/megaavr/libraries/PTC/examples/selfcap_with_dedicated_shield/selfcap_with_dedicated_shield.ino +++ b/megaavr/libraries/PTC/examples/selfcap_with_dedicated_shield/selfcap_with_dedicated_shield.ino @@ -10,7 +10,7 @@ * as shield. This improves the signal-to-noise ratio. */ #define MySerial Serial - +#if !defined(MILLIS_USE_TIMERNONE) cap_sensor_t nodes[2]; void setup() { @@ -59,3 +59,10 @@ void ptc_event_cb_calibration(const ptc_cb_event_t eventType, cap_sensor_t *node MySerial.print(" Node: "); MySerial.println(ptc_get_node_id(node)); } +#else +void setup() { +} +void loop () { +} +#endif + diff --git a/megaavr/libraries/PTC/src/ptc.c b/megaavr/libraries/PTC/src/ptc.c index 8254a0d6..7cf8801e 100644 --- a/megaavr/libraries/PTC/src/ptc.c +++ b/megaavr/libraries/PTC/src/ptc.c @@ -1,4 +1,4 @@ -/* +/* * Refer to ptc.h file for copyright, changelog, usage and license information */ @@ -9,30 +9,30 @@ // The following functions are used internally only. // get the pointer of the last valid node struct can be "firstNode" -cap_sensor_t* ptc_get_last_node(void); +cap_sensor_t *ptc_get_last_node(void); -uint8_t ptc_append_node(cap_sensor_t* pNewNode); +uint8_t ptc_append_node(cap_sensor_t *pNewNode); // Prepares the ADC/PTC registers for the next conversion batch, starts conversion with firstNode void ptc_init_conversion(uint8_t nodeType); // Starts the conversion of the node that is passed as argument -void ptc_start_conversion (cap_sensor_t* node); +void ptc_start_conversion (cap_sensor_t *node); // State-Machine Handler, interprets the measured values and decides if key is "pressed" -void ptc_process_node_sm (cap_sensor_t* node); +void ptc_process_node_sm (cap_sensor_t *node); // Helper function -void ptc_process_measurement (cap_sensor_t* node); +void ptc_process_measurement (cap_sensor_t *node); // Handles (initial) calibration -uint8_t ptc_process_calibrate (cap_sensor_t* node); +uint8_t ptc_process_calibrate (cap_sensor_t *node); // Handles adjustment of the reference value when a button is not pressed void ptc_process_adjust (); -void ptc_set_registers(cap_sensor_t* node); +void ptc_set_registers(cap_sensor_t *node); cap_sensor_t *firstNode = NULL; @@ -65,7 +65,7 @@ ptc_lib_sm_set_t ptc_sm_settings = { .drift_down_nom = 15 }; -ptc_lib_sm_set_t* ptc_get_sm_settings() { +ptc_lib_sm_set_t *ptc_get_sm_settings() { return &ptc_sm_settings; } @@ -91,15 +91,15 @@ ptc_lib_sm_set_t* ptc_get_sm_settings() { __attribute__ ((weak)) -void ptc_event_callback(const ptc_cb_event_t eventType, cap_sensor_t* node) { +void ptc_event_callback(const ptc_cb_event_t eventType, cap_sensor_t *node) { (void)eventType; (void)node; } -__attribute__ ((weak, alias("ptc_event_callback"))) void ptc_event_cb_touch(const ptc_cb_event_t eventType, cap_sensor_t* node); -__attribute__ ((weak, alias("ptc_event_callback"))) void ptc_event_cb_wake(const ptc_cb_event_t eventType, cap_sensor_t* node); -__attribute__ ((weak, alias("ptc_event_callback"))) void ptc_event_cb_conversion(const ptc_cb_event_t eventType, cap_sensor_t* node); -__attribute__ ((weak, alias("ptc_event_callback"))) void ptc_event_cb_calibration(const ptc_cb_event_t eventType, cap_sensor_t* node); -__attribute__ ((weak, alias("ptc_event_callback"))) void ptc_event_cb_error(const ptc_cb_event_t eventType, cap_sensor_t* node); +__attribute__ ((weak, alias("ptc_event_callback"))) void ptc_event_cb_touch(const ptc_cb_event_t eventType, cap_sensor_t *node); +__attribute__ ((weak, alias("ptc_event_callback"))) void ptc_event_cb_wake(const ptc_cb_event_t eventType, cap_sensor_t *node); +__attribute__ ((weak, alias("ptc_event_callback"))) void ptc_event_cb_conversion(const ptc_cb_event_t eventType, cap_sensor_t *node); +__attribute__ ((weak, alias("ptc_event_callback"))) void ptc_event_cb_calibration(const ptc_cb_event_t eventType, cap_sensor_t *node); +__attribute__ ((weak, alias("ptc_event_callback"))) void ptc_event_cb_error(const ptc_cb_event_t eventType, cap_sensor_t *node); @@ -109,7 +109,7 @@ __attribute__ ((weak, alias("ptc_event_callback"))) void ptc_event_cb_error(cons */ // Set the threshold for touch detection and away from touch for a node -uint8_t ptc_node_set_thresholds (cap_sensor_t* node, int16_t th_in, int16_t th_out) { +uint8_t ptc_node_set_thresholds (cap_sensor_t *node, int16_t th_in, int16_t th_out) { if (NULL == node) return PTC_LIB_BAD_POINTER; @@ -120,7 +120,7 @@ uint8_t ptc_node_set_thresholds (cap_sensor_t* node, int16_t th_in, int16_t th_o // Change Resistor Setting. Note: Only has an effect on mutual sensors -uint8_t ptc_node_set_resistor(cap_sensor_t* node, uint8_t res) { +uint8_t ptc_node_set_resistor(cap_sensor_t *node, uint8_t res) { PTC_CHECK_FOR_BAD_POINTER(node); if (res > RSEL_MAX) @@ -139,7 +139,7 @@ uint8_t ptc_node_set_resistor(cap_sensor_t* node, uint8_t res) { // Change prescaler. Recommended ADC frequency: < 1.5MHz, but max 3 factors below -uint8_t ptc_node_set_prescaler(cap_sensor_t* node, uint8_t presc) { +uint8_t ptc_node_set_prescaler(cap_sensor_t *node, uint8_t presc) { PTC_CHECK_FOR_BAD_POINTER(node); if ((presc > (PTC_PRESC_DEFAULT + 2)) || (presc < PTC_PRESC_DEFAULT)) @@ -152,7 +152,7 @@ uint8_t ptc_node_set_prescaler(cap_sensor_t* node, uint8_t presc) { } -uint8_t ptc_node_set_gain(cap_sensor_t* node, uint8_t aGain, uint8_t dGain) { +uint8_t ptc_node_set_gain(cap_sensor_t *node, uint8_t aGain, uint8_t dGain) { PTC_CHECK_FOR_BAD_POINTER(node); #if defined (__PTC_Tiny__) @@ -240,7 +240,7 @@ void ptc_init_ADC0(void) { #endif } -uint8_t ptc_add_node(cap_sensor_t* node, uint8_t* pCh, const uint8_t type) { +uint8_t ptc_add_node(cap_sensor_t *node, uint8_t *pCh, const uint8_t type) { const uint8_t typesize = sizeof(ptc_ch_arr_t); uint8_t hi_node = (uint8_t)((uint16_t)node >> 8); @@ -279,7 +279,7 @@ uint8_t ptc_add_node(cap_sensor_t* node, uint8_t* pCh, const uint8_t type) { yCh |= orY; } if ((xCh | yCh) == 0) { /* not a single pin selected */ - return PTC_LIB_BAD_ARGUMENT; + return PTC_LIB_BAD_ARGUMENT; } #endif @@ -324,15 +324,16 @@ uint8_t ptc_add_node(cap_sensor_t* node, uint8_t* pCh, const uint8_t type) { PORTA.PINCONFIG = PORT_PULLUPEN_bm | PORT_ISC_INPUT_DISABLE_gc; // this setting is mirrored across all PORTs (guard against ISRs) uint8_t* pin_upd = (uint8_t*)&(PORTA.PINCTRLUPD); - for (uint8_t i = 0; i < typesize; i++) { - uint8_t pin_bm = *pCh; - pCh += typesize; - pin_bm |= *pCh; - pCh -= (typesize-1); // decrement by one less to increment to next byte - - *pin_upd = pin_bm; - if ((uint8_t)(uint16_t) pin_upd == (uint8_t)(uint16_t)&PORTB.PINCTRLUPD) // double cast to remove warning, skip PORTC - pin_upd += sizeof(PORT_t); + uint8_t *end = pCh + typesize; + while (pCh < end) { + if ((uint8_t)(uint16_t) pin_upd != (uint8_t)(uint16_t)&PORTC.PINCTRLUPD) { // double cast to remove warning, skip PORTC + uint8_t pin_bm = *pCh; + pCh += typesize; + pin_bm |= *pCh; + pCh -= (typesize-1); // decrement by one less to increment to next byte + + *pin_upd = pin_bm; + } pin_upd += sizeof(PORT_t); } SREG = old_sreg; @@ -343,7 +344,7 @@ uint8_t ptc_add_node(cap_sensor_t* node, uint8_t* pCh, const uint8_t type) { -uint8_t ptc_enable_node(cap_sensor_t* node) { +uint8_t ptc_enable_node(cap_sensor_t *node) { PTC_CHECK_FOR_BAD_POINTER(node); node->state.disabled = 0; @@ -351,7 +352,7 @@ uint8_t ptc_enable_node(cap_sensor_t* node) { } // Will finish conversion, but not start a new one -uint8_t ptc_disable_node(cap_sensor_t* node) { +uint8_t ptc_disable_node(cap_sensor_t *node) { PTC_CHECK_FOR_BAD_POINTER(node); node->state.disabled = 1; @@ -384,7 +385,7 @@ void ptc_set_next_conversion_type(ptc_node_type_t type) { // ev_ch: bitmask of required channels to be used for ADC0/PTC, e.g. channel 2 and 5 -> 0x24 // this would allow to periodically start ADC0/PIT by a timer without sleep // user must tell the function which event channel to connect to. -uint8_t ptc_lp_init(cap_sensor_t* node, uint8_t event_ch) { +uint8_t ptc_lp_init(cap_sensor_t *node, uint8_t event_ch) { PTC_CHECK_FOR_BAD_POINTER(node); if (NULL != lowPowerNode) @@ -434,7 +435,7 @@ uint8_t ptc_lp_was_waken(void) { /* not recommended to use, as the calculation is bloated */ -uint16_t ptc_get_node_cc_femto (cap_sensor_t* node) { +uint16_t ptc_get_node_cc_femto (cap_sensor_t *node) { if (NULL == node) return 0; @@ -509,7 +510,7 @@ void ptc_process (uint16_t currTime) { /* * Internal functions only below. Not part of the API */ -void ptc_process_measurement (cap_sensor_t* node) { +void ptc_process_measurement (cap_sensor_t *node) { if (node->state.error) return; @@ -522,7 +523,7 @@ void ptc_process_measurement (cap_sensor_t* node) { -void ptc_process_node_sm (cap_sensor_t* node) { +void ptc_process_node_sm (cap_sensor_t *node) { uint16_t nodeData = node->sensorData; uint8_t nodeSM = node->stateMachine; uint8_t lastChange = node->lastStateChange; @@ -656,7 +657,7 @@ void ptc_process_node_sm (cap_sensor_t* node) { -uint8_t ptc_process_calibrate (cap_sensor_t* node) { +uint8_t ptc_process_calibrate (cap_sensor_t *node) { uint16_t rawData = node->sensorData; #if defined(__PTC_Tiny__) @@ -990,7 +991,7 @@ void ptc_set_registers(cap_sensor_t* node) { pPTC->CTRLA = ADC_RUNSTBY_bm | ADC_ENABLE_bm; /* 0x81 */ - if (0 == node->state.low_power) + if (0 == node->state.low_power) pPTC->COMMAND = 0x01; // Normal operation: Manual Start else pPTC->EVCTRL = 0x01; // Low Power: Start by positive flank on event @@ -1009,7 +1010,7 @@ cap_sensor_t* ptc_get_last_node (void) { cap_sensor_t *nextNode = node->nextNode; if (nextNode == NULL) return node; - else + else node = nextNode; } } @@ -1057,7 +1058,7 @@ void ptc_eoc(void) { pCurrentNode->state.win_comp = 0; ptc_lib_state = PTC_LIB_CONV_LP; } - + } else { ptc_start_conversion(pCurrentNode->nextNode); } diff --git a/megaavr/libraries/PTC/src/ptc.h b/megaavr/libraries/PTC/src/ptc.h index 9c21fa8a..c2d08b43 100644 --- a/megaavr/libraries/PTC/src/ptc.h +++ b/megaavr/libraries/PTC/src/ptc.h @@ -74,21 +74,21 @@ void badCall(const char*) __attribute__((weak, error(""))); //extern void ptc_conversion_complete(uint8_t type); -//extern void ptc_error_callback(uint8_t source, cap_sensor_t* node); -extern void ptc_event_callback(const ptc_cb_event_t eventType, cap_sensor_t* node); +//extern void ptc_error_callback(uint8_t source, cap_sensor_t *node); +extern void ptc_event_callback(const ptc_cb_event_t eventType, cap_sensor_t *node); -extern void ptc_event_cb_touch(const ptc_cb_event_t eventType, cap_sensor_t* node); -extern void ptc_event_cb_wake(const ptc_cb_event_t eventType, cap_sensor_t* node); -extern void ptc_event_cb_conversion(const ptc_cb_event_t eventType, cap_sensor_t* node); -extern void ptc_event_cb_calibration(const ptc_cb_event_t eventType, cap_sensor_t* node); -extern void ptc_event_cb_error(const ptc_cb_event_t eventType, cap_sensor_t* node); +extern void ptc_event_cb_touch(const ptc_cb_event_t eventType, cap_sensor_t *node); +extern void ptc_event_cb_wake(const ptc_cb_event_t eventType, cap_sensor_t *node); +extern void ptc_event_cb_conversion(const ptc_cb_event_t eventType, cap_sensor_t *node); +extern void ptc_event_cb_calibration(const ptc_cb_event_t eventType, cap_sensor_t *node); +extern void ptc_event_cb_error(const ptc_cb_event_t eventType, cap_sensor_t *node); // Enables the node. Can be called while an acquisition is in progress. -uint8_t ptc_enable_node(cap_sensor_t* node); +uint8_t ptc_enable_node(cap_sensor_t *node); // Disables a node. If the conversion is started, it will be finished -uint8_t ptc_disable_node(cap_sensor_t* node); +uint8_t ptc_disable_node(cap_sensor_t *node); // Can be used outside an acqusition process to select ADC/SELFCAP/MUTUAL/SHIELD void ptc_set_next_conversion_type(ptc_node_type_t type); @@ -98,22 +98,22 @@ void ptc_process(uint16_t currTime); // Set the threshold for touch detection and away from touch for a node -uint8_t ptc_node_set_thresholds (cap_sensor_t* node, int16_t th_in, int16_t th_out); +uint8_t ptc_node_set_thresholds (cap_sensor_t *node, int16_t th_in, int16_t th_out); // Change Resistor Setting. Note: Only has an effect on mutual sensors -uint8_t ptc_node_set_resistor(cap_sensor_t* node, uint8_t res); +uint8_t ptc_node_set_resistor(cap_sensor_t *node, uint8_t res); // Change prescaler. -uint8_t ptc_node_set_prescaler(cap_sensor_t* node, uint8_t presc); +uint8_t ptc_node_set_prescaler(cap_sensor_t *node, uint8_t presc); -uint8_t ptc_node_set_gain(cap_sensor_t* node, uint8_t aGain, uint8_t dGain); +uint8_t ptc_node_set_gain(cap_sensor_t *node, uint8_t aGain, uint8_t dGain); // this is an internal function, there is no sense in calling it directly -uint8_t ptc_add_node(cap_sensor_t* node, uint8_t* pCh, const uint8_t type); +uint8_t ptc_add_node(cap_sensor_t *node, uint8_t *pCh, const uint8_t type); -inline uint8_t ptc_add_selfcap_node(cap_sensor_t* node, const ptc_ch_bm_t xCh, const ptc_ch_bm_t yCh) { +inline uint8_t ptc_add_selfcap_node(cap_sensor_t *node, const ptc_ch_bm_t xCh, const ptc_ch_bm_t yCh) { if(__builtin_constant_p(yCh)) { if (yCh == 0) badArg("yCh bitmap mustn't be 0 (Pin_Pxn is not a PTC pin)"); if (yCh & xCh) badArg("pin bitmap overlap detected"); @@ -150,7 +150,7 @@ inline uint8_t ptc_add_selfcap_node(cap_sensor_t* node, const ptc_ch_bm_t xCh, c }; -inline uint8_t ptc_add_mutualcap_node(cap_sensor_t* node, const ptc_ch_bm_t xCh, const ptc_ch_bm_t yCh) { +inline uint8_t ptc_add_mutualcap_node(cap_sensor_t *node, const ptc_ch_bm_t xCh, const ptc_ch_bm_t yCh) { if(__builtin_constant_p(yCh) && __builtin_constant_p(xCh)) { if (yCh == 0) badArg("yCh bitmap mustn't be 0 (Pin_Pxn is not a PTC pin)"); if (xCh == 0) badArg("xCh bitmap mustn't be 0 (Pin_Pxn is not a PTC pin)"); @@ -192,20 +192,20 @@ inline uint8_t ptc_add_mutualcap_node(cap_sensor_t* node, const ptc_ch_bm_t xCh, uint8_t ptc_suspend(void); void ptc_resume(void); -// If you want to know the compensation capacitance in fempto Farrad -uint16_t ptc_get_node_cc_fempto(cap_sensor_t* node); +// If you want to know the compensation capacitance in femto Farad +uint16_t ptc_get_node_cc_fempto(cap_sensor_t *node); -ptc_lib_sm_set_t* ptc_get_sm_settings(); +ptc_lib_sm_set_t *ptc_get_sm_settings(); // X and Y channel bitmasks -inline ptc_ch_bm_t ptc_get_node_xCh_bm(cap_sensor_t* node) { +inline ptc_ch_bm_t ptc_get_node_xCh_bm(cap_sensor_t *node) { if (node == NULL) return 0x00; ptc_ch_bm_t retval = 0; memcpy(&retval, node->hw_xCh_bm, sizeof(node->hw_xCh_bm)); return retval; } -inline ptc_ch_bm_t ptc_get_node_yCh_bm(cap_sensor_t* node) { +inline ptc_ch_bm_t ptc_get_node_yCh_bm(cap_sensor_t *node) { if (node == NULL) return 0x00; ptc_ch_bm_t retval = 0; memcpy(&retval, node->hw_yCh_bm, sizeof(node->hw_yCh_bm)); @@ -213,14 +213,14 @@ inline ptc_ch_bm_t ptc_get_node_yCh_bm(cap_sensor_t* node) { } // the measured PTC value. 512 is 0. 0x00 means BAD_POINTER -inline uint16_t ptc_get_node_sensor_value(cap_sensor_t* node) { +inline uint16_t ptc_get_node_sensor_value(cap_sensor_t *node) { if (node == NULL) return 0x00; return node->sensorData; } // returns true, if node is a valid pointer and node is touched, otherwise false. // No other return value so there can be easy checks - not null or null -inline uint8_t ptc_get_node_touched(cap_sensor_t* node) { +inline uint8_t ptc_get_node_touched(cap_sensor_t *node) { if (node == NULL) return 0x00; if (node->stateMachine & (PTC_SM_TOUCH_DETECT | PTC_SM_TOUCH_OUT_FLT)) @@ -229,27 +229,27 @@ inline uint8_t ptc_get_node_touched(cap_sensor_t* node) { } -inline uint8_t ptc_get_node_sm(cap_sensor_t* node) { +inline uint8_t ptc_get_node_sm(cap_sensor_t *node) { PTC_CHECK_FOR_BAD_POINTER(node); return node->stateMachine; } -inline int16_t ptc_get_node_delta(cap_sensor_t* node) { +inline int16_t ptc_get_node_delta(cap_sensor_t *node) { if (node == NULL) return 0x8000; //-32k - impossible value for normal operation return (node->sensorData - node->reference); } -inline uint8_t ptc_get_node_state(cap_sensor_t* node) { +inline uint8_t ptc_get_node_state(cap_sensor_t *node) { if (node == NULL) return 0xFF; return (node->stateMachine); } -inline ptc_id_t ptc_get_node_id(cap_sensor_t* node) { +inline ptc_id_t ptc_get_node_id(cap_sensor_t *node) { if (node == NULL) return 0xFF; @@ -257,7 +257,7 @@ inline ptc_id_t ptc_get_node_id(cap_sensor_t* node) { } -inline uint8_t ptc_node_request_recal(cap_sensor_t* node) { +inline uint8_t ptc_node_request_recal(cap_sensor_t *node) { PTC_CHECK_FOR_BAD_POINTER(node); node->stateMachine = PTC_SM_NOINIT_CAL; @@ -267,7 +267,7 @@ inline uint8_t ptc_node_request_recal(cap_sensor_t* node) { void ptc_init_ADC0(void); -uint8_t ptc_lp_init(cap_sensor_t* node, uint8_t event_ch); +uint8_t ptc_lp_init(cap_sensor_t *node, uint8_t event_ch); uint8_t ptc_lp_disable(void); uint8_t ptc_lp_was_waken(void); diff --git a/megaavr/libraries/PTC/src/ptc_types.h b/megaavr/libraries/PTC/src/ptc_types.h index 30dff079..ef74abb4 100644 --- a/megaavr/libraries/PTC/src/ptc_types.h +++ b/megaavr/libraries/PTC/src/ptc_types.h @@ -1,5 +1,5 @@ -/* - * Refer to ptc.h file for copyright, changelog, usage and license information +/* + * Refer to ptc.h file for copyright, changelog, usage and license information */ @@ -82,8 +82,7 @@ typedef enum ptc_freq_enum { #if defined (__PTC_Tiny__) -typedef enum PTC_PRESC_enum -{ +typedef enum PTC_PRESC_enum { PTC_PRESC_DIV2_gc = (0x00<<0), /* CLK_PER divided by 2 */ PTC_PRESC_DIV4_gc = (0x01<<0), /* CLK_PER divided by 4 */ PTC_PRESC_DIV8_gc = (0x02<<0), /* CLK_PER divided by 8 */ @@ -103,8 +102,7 @@ typedef enum PTC_RSEL_enum { RSEL_VAL_200 } PTC_RSEL_t; #elif defined (__PTC_DA__) -typedef enum PTC_PRESC_enum -{ +typedef enum PTC_PRESC_enum { PTC_PRESC_DIV2_gc = (0x00<<0), /* CLK_PER divided by 2 */ PTC_PRESC_DIV4_gc = (0x01<<0), /* CLK_PER divided by 4 */ PTC_PRESC_DIV6_gc = (0x02<<0), /* CLK_PER divided by 2 */ @@ -116,23 +114,23 @@ typedef enum PTC_PRESC_enum } PTC_PRESC_t; typedef enum tag_rsel_val_t { - RSEL_VAL_0, - RSEL_VAL_20, - RSEL_VAL_50, - RSEL_VAL_70, - RSEL_VAL_80, - RSEL_VAL_100, - RSEL_VAL_120, - RSEL_VAL_200 + RSEL_VAL_0, + RSEL_VAL_20, + RSEL_VAL_50, + RSEL_VAL_70, + RSEL_VAL_80, + RSEL_VAL_100, + RSEL_VAL_120, + RSEL_VAL_200 } PTC_RSEL_t; #endif typedef struct ptc_node_state_type { - uint8_t error:1; - uint8_t win_comp:1; - uint8_t low_power:1; - uint8_t data_ready:1; - uint8_t disabled:1; + uint8_t error: 1; + uint8_t win_comp: 1; + uint8_t low_power: 1; + uint8_t data_ready: 1; + uint8_t disabled: 1; } ptc_node_state_t; @@ -214,7 +212,7 @@ typedef enum ptc_lib_enum { } ptc_lib_t; typedef struct cap_sensor_type { - struct cap_sensor_type* nextNode; + struct cap_sensor_type *nextNode; ptc_node_type_t type; ptc_id_t id; // number for easier identification in the callback @@ -251,4 +249,4 @@ typedef struct ptc_lib_sm_settings_type { #ifdef __cplusplus } #endif -#endif \ No newline at end of file +#endif