Defines

mTouch_macroLibrary_common.h File Reference

Implements non-core-specific acquisition macros. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define MASKBANK(var, bank)
 Masks the bank out of the variable address for ASM code usage. Requires that the actual bank bits being masked equal the bank value provided.
#define NOBANK(var)
 Masks the bank out of the variable address for ASM code usage.
Housekeeping Macros

These macros perform basic ISR and timer module functions such as checking that the interrupt flag is set and reloading the TMR0 counter.

#define SAVE_STATE()
 Executes any required actions to save the current main-loop process.
#define RESTORE_STATE()
 Executes any required actions to save the current main-loop process.
#define MTOUCH_SLEEP_STABILIZE_OSC()
 Causes the system to wait until the oscillator's frequency has stabilized.
#define JITTER_START_TIME()
 Calculates a random value and uses it to seed the mTouch interrupt timer.
#define JITTER_MAIN_LOOP()
 Calculates a random value and uses it to jitter the mTouch scanning routine when operating out of the main loop.
#define MTOUCH_SCANFUNCTIONA(index)   __paste(mTouch_ScanA_, index)
#define MTOUCH_SCANFUNCTIONB(index)   __paste(mTouch_ScanB_, index)
#define CVD_SCANA_GEN(index, indexRef)
 Function-generating macro called by MTOUCH_SCAN_FUNCTION(i). Do not use directly.
#define CVD_SCANB_GEN(index, indexRef)
 Function-generating macro called by MTOUCH_SCAN_FUNCTION(i). Do not use directly.
#define MTOUCH_SCAN_FUNCTION(index)
#define MTOUCH_SCAN_PROTOTYPE(index)
#define PIC_ADC_BITS   10
Polishing/Finishing Macros

These macros perform scaling and final operations before setting the mTouchCVD_dataReady flag and allowing the main loop application to process the new data.

#define STORE_SENSOR_SCALE(index, shift)
 Do not use directly. Expanded utility macro called by STORE_SENSOR(index).
#define STORE_LAST_SENSOR_SCALE(index, shift)
 Do not use directly. Expanded utility macro called by STORE_SENSOR(index).
#define STORE_SINGLE_SENSOR_SCALE(index, shift)
 Do not use directly. Expanded utility macro called by STORE_SENSOR(index) if there is only one sensor in the mTouch application.
#define STORE_SENSOR(index)
 Scales the accumulated result of the CVD acquisition and stores it for main-application access.
#define EXIT_SENSOR(index)
 Increments the given index variable and exits the ISR.
#define EXIT_LAST_SENSOR(index)
 Performs several important functions after all sensors have been scanned.
#define EXIT_LAST_SENSOR_MAIN()
 Do not use directly. Utility macro used by EXIT_LAST_SENSOR() to decrement the oversampling counter.
#define EXIT_LAST_SENSOR_DECINDEX(index)
 Do not use directly. Utility macro used by EXIT_LAST_SENSOR() to reset the index variable.
#define MTOUCH_EXIT_SCAN_FUNCTION(index)   __3paste(MTOUCH_EXIT_SENSOR,index,())
#define MTOUCH_INC_INDEX_AND_STORE_RESULT()
#define SET_DATA_READY_FLAG()
 Sets the dataReady flag to signal the main application of a new reading.

Detailed Description

Implements non-core-specific acquisition macros.

Definition in file mTouch_macroLibrary_common.h.


Define Documentation

#define CVD_SCANA_GEN (   index,
  indexRef 
)

Function-generating macro called by MTOUCH_SCAN_FUNCTION(i). Do not use directly.

Parameters:
[in]indexthe index of the sensor to be scanned
[in]indexRefthe index of the sensor to be used as the reference This macro creates a new CVD 'Scan A' function based on the index value provided. The function's name will be mTouch_ScanA_#().

Definition at line 254 of file mTouch_macroLibrary_common.h.

#define CVD_SCANB_GEN (   index,
  indexRef 
)

Function-generating macro called by MTOUCH_SCAN_FUNCTION(i). Do not use directly.

Parameters:
[in]indexthe index of the sensor to be scanned
[in]indexRefthe index of the sensor to be used as the reference This macro creates a new CVD 'Scan B' function based on the index value provided. The function's name will be mTouch_ScanB_#().

Definition at line 278 of file mTouch_macroLibrary_common.h.

#define EXIT_LAST_SENSOR_DECINDEX (   index )

Do not use directly. Utility macro used by EXIT_LAST_SENSOR() to reset the index variable.

Parameters:
[in]indexthe index variable to reset to 0

Definition at line 678 of file mTouch_macroLibrary_common.h.

#define EXIT_LAST_SENSOR_MAIN (  )

Do not use directly. Utility macro used by EXIT_LAST_SENSOR() to decrement the oversampling counter.

Definition at line 670 of file mTouch_macroLibrary_common.h.

#define JITTER_MAIN_LOOP (  )
Value:
do {                                                                                                            \
                asm("BANKSEL    _mTouch_jitter"                 );  /* Make sure we're starting in the correct bank     */  \
                asm("bcf    "   ___mkstr(_STATUS)           ",0");  /* Clear the carry bit                              */  \
                asm("rrf    "   ___mkstr(_mTouch_jitter)    ",W");  /* Right shift the current jitter seed value        */  \
                asm("btfsc  "   ___mkstr(_STATUS)           ",0");  /* Check the carry bit - if set, perform XOR        */  \
                asm("xorlw      0xB4"                           );  /* (cond) XOR the jitter seed with 0xB4             */  \
                asm("movwf  "   ___mkstr(_mTouch_jitter)        );  /* Store the result as the new jitter seed value    */  \
                for (uint8_t i = (mTouch_jitter & MTOUCH_JITTER_MASK); i > 0; i--); /* Delay loop                       */  \
            } while (0)

Calculates a random value and uses it to jitter the mTouch scanning routine when operating out of the main loop.

Implements a linear feedback shift register algorithm to increase the randomness of the jitter function. This implementation costs one byte of RAM.

Definition at line 196 of file mTouch_macroLibrary_common.h.

#define JITTER_START_TIME (  )
Value:
do {                                                                                                                \
                asm("BANKSEL    _mTouch_jitter"                     );  /* Make sure we're starting in the correct bank     */  \
                asm("bcf    "   ___mkstr(_STATUS)           ",0"    );  /* Clear the carry bit                              */  \
                asm("rrf    "   ___mkstr(_mTouch_jitter)    ",W"    );  /* Right shift the current jitter seed value        */  \
                asm("btfsc  "   ___mkstr(_STATUS)           ",0"    );  /* Check the carry bit - if set, perform XOR        */  \
                asm("xorlw      0xB4"                               );  /* (cond) XOR the jitter seed with 0xB4             */  \
                asm("movwf  "   ___mkstr(_mTouch_jitter)            );  /* Store the result as the new jitter seed value    */  \
                asm("andlw  "   ___mkstr(MTOUCH_JITTER_MASK)        );  /* Mask the seed value to limit the number of bits  */  \
                asm("BANKSEL "  ___mkstr(MTOUCH_ISR_TMR_ASM)        );  /* Move to Bank 0 to access timer SFR               */  \
                asm("clrf   "   ___mkstr(NOBANK(MTOUCH_ISR_TMR_ASM)));  /* Clear timer                                      */  \
                asm("addwf  "   ___mkstr(NOBANK(MTOUCH_ISR_TMR_ASM)));  /* Add the masked LFSR value as an offset to timer  */  \
            } while (0)

Calculates a random value and uses it to seed the mTouch interrupt timer.

Implements a linear feedback shift register algorithm to increase the randomness of the jitter function. This implementation costs one byte of RAM.

Definition at line 171 of file mTouch_macroLibrary_common.h.

#define MASKBANK (   var,
  bank 
)

Masks the bank out of the variable address for ASM code usage. Requires that the actual bank bits being masked equal the bank value provided.

Parameters:
varthe variable address to mask
bankthe bank location of the variable

Definition at line 68 of file mTouch_macroLibrary_common.h.

#define MTOUCH_EXIT_SCAN_FUNCTION (   index )    __3paste(MTOUCH_EXIT_SENSOR,index,())

Definition at line 680 of file mTouch_macroLibrary_common.h.

#define MTOUCH_INC_INDEX_AND_STORE_RESULT (  )
Value:
mTouch_currentSensor++;                                         \
                mTouch_prevSensor    = &mTouch_acqData[mTouch_currentSensor];   \
                WAIT_FOR_GODONE_BIT();                                          \
                MTOUCH_STORE_SCAN_B();

Definition at line 682 of file mTouch_macroLibrary_common.h.

#define MTOUCH_SCAN_FUNCTION (   index )
Value:
CVD_SCANA_GEN(index, __paste(CVD_REFSENSOR_, index));  \
                                                CVD_SCANB_GEN(index, __paste(CVD_REFSENSOR_, index))

Definition at line 292 of file mTouch_macroLibrary_common.h.

#define MTOUCH_SCAN_PROTOTYPE (   index )
Value:
void MTOUCH_SCANFUNCTIONA(index)(void);   \
                                                void MTOUCH_SCANFUNCTIONB(index)(void);

Definition at line 295 of file mTouch_macroLibrary_common.h.

#define MTOUCH_SCANFUNCTIONA (   index )    __paste(mTouch_ScanA_, index)

Definition at line 240 of file mTouch_macroLibrary_common.h.

#define MTOUCH_SCANFUNCTIONB (   index )    __paste(mTouch_ScanB_, index)

Definition at line 241 of file mTouch_macroLibrary_common.h.

#define MTOUCH_SLEEP_STABILIZE_OSC (  )
Value:
do {                                        \
        while (!HFIOFL);                        \
    } while(0)

Causes the system to wait until the oscillator's frequency has stabilized.

Definition at line 153 of file mTouch_macroLibrary_common.h.

#define NOBANK (   var )

Masks the bank out of the variable address for ASM code usage.

Parameters:
varthe variable address to mask

Definition at line 75 of file mTouch_macroLibrary_common.h.

#define PIC_ADC_BITS   10

Definition at line 514 of file mTouch_macroLibrary_common.h.

#define RESTORE_STATE (  )
Value:
do {                                \
        asm("movf   _int_fsr,W");       \
        asm("movwf  _FSR");             \
        asm("movf   _int_pclath,W");    \
        asm("movwf  _PCLATH");          \
        asm("movf   _int_status,W");    \
        asm("movwf  _STATUS");          \
        asm("swapf  _int_w, W");        \
    } while (0)

Executes any required actions to save the current main-loop process.

Definition at line 134 of file mTouch_macroLibrary_common.h.

#define SAVE_STATE (  )
Value:
do {                                \
        asm("movwf  _int_w");           \
        asm("swapf  _int_w, F");        \
        asm("movf   _STATUS, W");       \
        asm("clrf   _STATUS");          \
        asm("movwf  _int_status");      \
        asm("movf   _PCLATH, W");       \
        asm("clrf   _PCLATH");          \
        asm("movwf  _int_pclath");      \
        asm("movf   _FSR, W");          \
        asm("movwf  _int_fsr");         \
    } while (0)

Executes any required actions to save the current main-loop process.

Definition at line 112 of file mTouch_macroLibrary_common.h.

#define STORE_LAST_SENSOR_SCALE (   index,
  shift 
)

Do not use directly. Expanded utility macro called by STORE_SENSOR(index).

Parameters:
[in]indexthe index of the sensor to be scaled and stored
[in]shiftthe number of times to shift the accumulator value to the right before storing its value in the mTouch_sensorData array

Definition at line 559 of file mTouch_macroLibrary_common.h.

#define STORE_SENSOR_SCALE (   index,
  shift 
)

Do not use directly. Expanded utility macro called by STORE_SENSOR(index).

Parameters:
[in]indexthe index of the sensor to be scaled and stored
[in]shiftthe number of times to shift the accumulator value to the right before storing its value in the mTouch_sensorData array

Definition at line 545 of file mTouch_macroLibrary_common.h.

#define STORE_SINGLE_SENSOR_SCALE (   index,
  shift 
)

Do not use directly. Expanded utility macro called by STORE_SENSOR(index) if there is only one sensor in the mTouch application.

Parameters:
[in]indexthe index of the sensor to be scaled and stored
[in]shiftthe number of times to shift the accumulator value to the right before storing its value in the mTouch_sensorData array

Definition at line 573 of file mTouch_macroLibrary_common.h.