/* ** =================================================================== ** Method : TSS1_Configure (component TSS_Library) ** This method can be used also under name "Configure" ** ** Description : ** Whole TSS initialization and configuration of registers. ** Contains main TSS_Init() function, TSS System Config ** registers and all Control Config registers initialization ** according to setting of Component properties. The user have ** to place this function into the proper location in the ** source code. ** Parameters : None ** Returns : ** --- - Error status code of Configure method. If ** the configuration is successful the ** TSS_STATUS_OK is reported, otherwise is ** reported one of error status codes ** described in TSSAPIRM document. ** =================================================================== */ byte TSS1_Configure(void) { byte u8Result = TSS_STATUS_OK; /* Main TSS Initialization */ (void) TSS_Init(); /* Configure the Analog Slider Control to report the touch and release events */ u8Result |= TSS_SetASliderConfig(AnalogSlider.ControlId, ASlider_Events_Register, TSS_ASLIDER_MOVEMENT_EVENT_EN_MASK | TSS_ASLIDER_INITIAL_TOUCH_EVENT_EN_MASK); /* Configure the Analog Slider Auto-Repeat Rate Register */ u8Result |= TSS_SetASliderConfig(AnalogSlider.ControlId, ASlider_AutoRepeatRate_Register, 0x00); /* Configure the Analog Slider Movement Timeout Register */ u8Result |= TSS_SetASliderConfig(AnalogSlider.ControlId, ASlider_MovementTimeout_Register, 0x02); /* Configure the Analog Slider Range Register */ u8Result |= TSS_SetASliderConfig(AnalogSlider.ControlId, ASlider_Range_Register, 0x20); /* Configure ASlider Control configuration registers */ u8Result |= TSS_SetASliderConfig(AnalogSlider.ControlId, ASlider_ControlConfig_Register, TSS_ASLIDER_CONTROL_EN_MASK | TSS_ASLIDER_CALLBACK_EN_MASK | 0x00); /* Enables all electrodes */ u8Result |= TSS_SetSystemConfig(System_ElectrodeEnablers_Register+0, 0x03); /* Sets Trigger Mode */ u8Result |= TSS_SetSystemConfig(System_SystemTrigger_Register, TSS_TRIGGER_MODE_ALWAYS); /* Sets the Number of samples for all electrodes */ u8Result |= TSS_SetSystemConfig(System_NSamples_Register, 0x08); /* Configures the DC Tracker value */ u8Result |= TSS_SetSystemConfig(System_DCTrackerRate_Register, 0x64); /* Configures the Response Time */ u8Result |= TSS_SetSystemConfig(System_ResponseTime_Register, 0x04); /* Configures the Stuck-key Timeout */ u8Result |= TSS_SetSystemConfig(System_StuckKeyTimeout_Register, 0x00); /* Configures System SystemConfig Register */ u8Result |= TSS_SetSystemConfig(System_SystemConfig_Register, TSS_SYSTEM_EN_MASK); return u8Result; }
/* ** =================================================================== ** Method : TSS1_Configure (component TSS_Library) ** This method can be used also under name "Configure" ** ** Description : ** Whole TSS initialization and configuration of registers. ** Contains main TSS_Init() function, TSS System Config ** registers and all Control Config registers initialization ** according to setting of Component properties. The user have ** to place this function into the proper location in the ** source code. ** Parameters : None ** Returns : ** --- - Error status code of Configure method. If ** the configuration is successful the ** TSS_STATUS_OK is reported, otherwise is ** reported one of error status codes ** described in TSSAPIRM document. ** =================================================================== */ byte TSS1_Configure(void) { byte u8Result = TSS_STATUS_OK; /* Main TSS Initialization */ u8Result |= TSS_Init(); /* Electrode dc-tracker enablers */ u8Result |= TSS_SetSystemConfig(System_DCTrackerEnablers_Register+0, 0x03); /* Sets Trigger Mode */ u8Result |= TSS_SetSystemConfig(System_SystemTrigger_Register, TSS_TRIGGER_MODE_ALWAYS); /* Sets the Number of samples for all electrodes */ u8Result |= TSS_SetSystemConfig(System_NSamples_Register, 0x08); /* Configures the DC Tracker value */ u8Result |= TSS_SetSystemConfig(System_DCTrackerRate_Register, 0x64); /* Configures the Slow DC Tracker Factor value */ u8Result |= TSS_SetSystemConfig(System_SlowDCTrackerFactor_Register, 0x64); /* Configures the Response Time */ u8Result |= TSS_SetSystemConfig(System_ResponseTime_Register, 0x04); /* Configures the Stuck-key Timeout */ u8Result |= TSS_SetSystemConfig(System_StuckKeyTimeout_Register, 0x00); /* Configures System SystemConfig Register */ u8Result |= TSS_SetSystemConfig(System_SystemConfig_Register, TSS_SYSTEM_EN_MASK | TSS_DC_TRACKER_EN_MASK); return u8Result; }
TSSSystem::TSSSystem() { if (TSS_Init() != TSS_STATUS_OK) { callbackSysFaults(SYSTEM_FAULT, SYSTEM_INITIALIZATION_FAULT); return; } #if (TSS_USE_AUTO_SENS_CALIBRATION == 0) for (uint8_t i = 0u; i < TSS_N_ELECTRODES; i++) { setSensitivity(i, 0x1A); /* Sensitivity set if AUTOCALIB is OFF */ } #endif set(TSS_TRIGGER, TSS_TRIGGER_MODE_ALWAYS); enable(TSS_SYSTEM); enable(TSS_DC_TRACK); }
/* ** =================================================================== ** Method : TSS1_Configure (component TSS_Library) ** This method can be used also under name "Configure" ** ** Description : ** Whole TSS initialization and configuration of registers. ** Contains main TSS_Init() function, TSS System Config ** registers and all Control Config registers initialization ** according to setting of Component properties. The user have ** to place this function into the proper location in the ** source code. ** Parameters : None ** Returns : ** --- - Error status code of Configure method. If ** the configuration is successful the ** TSS_STATUS_OK is reported, otherwise is ** reported one of error status codes ** described in TSSAPIRM document. ** =================================================================== */ byte TSS1_Configure(void) { byte u8Temp; byte u8Result = TSS_STATUS_OK; /* Main TSS Initialization */ u8Result |= TSS_Init(); /* Configure the Keypad Control to report the touch and release events */ u8Result |= TSS_SetKeypadConfig(TSS1_cKey0.ControlId, Keypad_Events_Register, TSS_KEYPAD_TOUCH_EVENT_EN_MASK); /* Configure the Keypad Max Touches Register */ u8Result |= TSS_SetKeypadConfig(TSS1_cKey0.ControlId, Keypad_MaxTouches_Register, 0x08); /* Configure the Auto-Repeat Rate Register */ u8Result |= TSS_SetKeypadConfig(TSS1_cKey0.ControlId, Keypad_AutoRepeatRate_Register, 0x00); /* Configure the Auto-Repeat Start Register */ u8Result |= TSS_SetKeypadConfig(TSS1_cKey0.ControlId, Keypad_AutoRepeatStart_Register, 0x00); /* Configure Keypad Control configuration registers */ u8Result |= TSS_SetKeypadConfig(TSS1_cKey0.ControlId, Keypad_ControlConfig_Register, TSS_KEYPAD_CONTROL_EN_MASK | TSS_KEYPAD_CALLBACK_EN_MASK); /* Enables electrodes */ u8Temp = (byte) TSS_GetSystemConfig(System_ElectrodeEnablers_Register+0); u8Result |= TSS_SetSystemConfig(System_ElectrodeEnablers_Register+0, (u8Temp | 0xFF) & ~0x00); /* Electrode dc-tracker enablers */ u8Result |= TSS_SetSystemConfig(System_DCTrackerEnablers_Register+0, 0xFF); /* Sets Trigger Mode */ u8Result |= TSS_SetSystemConfig(System_SystemTrigger_Register, TSS_TRIGGER_MODE_ALWAYS); /* Sets the Number of samples for all electrodes */ u8Result |= TSS_SetSystemConfig(System_NSamples_Register, 0x08); /* Configures the DC Tracker value */ u8Result |= TSS_SetSystemConfig(System_DCTrackerRate_Register, 0x64); /* Configures the Slow DC Tracker Factor value */ u8Result |= TSS_SetSystemConfig(System_SlowDCTrackerFactor_Register, 0x64); /* Configures the Response Time */ u8Result |= TSS_SetSystemConfig(System_ResponseTime_Register, 0x04); /* Configures the Stuck-key Timeout */ u8Result |= TSS_SetSystemConfig(System_StuckKeyTimeout_Register, 0x00); /* Configures System SystemConfig Register */ u8Result |= TSS_SetSystemConfig(System_SystemConfig_Register, TSS_SYSTEM_EN_MASK | TSS_DC_TRACKER_EN_MASK | TSS_WATER_TOLERANCE_EN_MASK | TSS_LOWPOWER_EN_MASK); return u8Result; }
void InitPickGuardTSS() { BYTE lcv; SIM_SCGC5 |= SIM_SCGC5_TSI_MASK; TSS_Init(); /* Set Number of Samples */ (void)TSS_SetSystemConfig(System_NSamples_Register, 0x08); /* Sets the Sensitivity value for each electrode */ for (lcv =0; lcv < TSS_N_ELECTRODES; lcv++) { (void)TSS_SetSystemConfig(System_Sensitivity_Register + lcv, 0x3F); } (void)TSS_SetSystemConfig(System_Sensitivity_Register + 6, 0x18); (void)TSS_SetSystemConfig(System_Sensitivity_Register + 7, 0x20); (void)TSS_SetSystemConfig(System_Sensitivity_Register + 8, 0x40); (void)TSS_SetSystemConfig(System_Sensitivity_Register + 8, 0x40); (void)TSS_SetSystemConfig(System_Sensitivity_Register + 9, 0x40); (void)TSS_SetSystemConfig(System_Sensitivity_Register + 10, 0x40); /* Enablers Settings */ (void)TSS_SetSystemConfig(System_ElectrodeEnablers_Register + 0u, 0xFF); (void)TSS_SetSystemConfig(System_ElectrodeEnablers_Register + 1u, 0xFF); (void)TSS_SetSystemConfig(System_ElectrodeEnablers_Register + 2u, 0xFF); /* Auto Trigger Config */ TSS_SetSystemConfig(System_SystemTrigger_Register, TSS_TRIGGER_MODE_ALWAYS); /* TSS_TRIGGER_MODE_AUTO/TSS_TRIGGER_MODE_ALWAYS/TSS_TRIGGER_MODE_SW */ TSS_SetSystemConfig(System_AutoTriggerModuloValue_Register, 0xFF); (void)TSS_KeypadConfig(ToneVolumeSelect.ControlId,Keypad_Events_Register,(TSS_KEYPAD_TOUCH_EVENT_EN_MASK)); (void)TSS_KeypadConfig(ToneVolumeSelect.ControlId,Keypad_ControlConfig_Register,(TSS_KEYPAD_CALLBACK_EN_MASK | TSS_KEYPAD_CONTROL_EN_MASK)); (void)TSS_KeypadConfig(Mute.ControlId,Keypad_Events_Register,(TSS_KEYPAD_TOUCH_EVENT_EN_MASK)); (void)TSS_KeypadConfig(Mute.ControlId,Keypad_ControlConfig_Register,(TSS_KEYPAD_CALLBACK_EN_MASK | TSS_KEYPAD_CONTROL_EN_MASK)); (void)TSS_KeypadConfig(Delta.ControlId,Keypad_Events_Register,(TSS_KEYPAD_TOUCH_EVENT_EN_MASK)); (void)TSS_KeypadConfig(Delta.ControlId,Keypad_ControlConfig_Register,(TSS_KEYPAD_CALLBACK_EN_MASK | TSS_KEYPAD_CONTROL_EN_MASK)); (void)TSS_KeypadConfig(Alpha.ControlId,Keypad_Events_Register,(TSS_KEYPAD_TOUCH_EVENT_EN_MASK)); (void)TSS_KeypadConfig(Alpha.ControlId,Keypad_ControlConfig_Register,(TSS_KEYPAD_CALLBACK_EN_MASK | TSS_KEYPAD_CONTROL_EN_MASK)); (void)TSS_KeypadConfig(Beta.ControlId,Keypad_Events_Register,(TSS_KEYPAD_TOUCH_EVENT_EN_MASK)); (void)TSS_KeypadConfig(Beta.ControlId,Keypad_ControlConfig_Register,(TSS_KEYPAD_CALLBACK_EN_MASK | TSS_KEYPAD_CONTROL_EN_MASK)); (void)TSS_KeypadConfig(Gamma.ControlId,Keypad_Events_Register,(TSS_KEYPAD_TOUCH_EVENT_EN_MASK)); (void)TSS_KeypadConfig(Gamma.ControlId,Keypad_ControlConfig_Register,(TSS_KEYPAD_CALLBACK_EN_MASK | TSS_KEYPAD_CONTROL_EN_MASK)); /* Rotary Electrode Group */ /* Configure the TSS to report the touch, release and movement events */ (void)TSS_RotaryConfig(VolumeWheel.ControlId,Rotary_Events_Register,TSS_ROTARY_MOVEMENT_EVENT_EN_MASK); /* Enables Callback function. Enables the control */ (void)TSS_RotaryConfig(VolumeWheel.ControlId,Rotary_ControlConfig_Register,(TSS_ROTARY_CONTROL_EN_MASK|TSS_ROTARY_CALLBACK_EN_MASK)); /* Enables the TSS. Enables the DC Tracking feature. Default DC Tracking value is 0x64 */ (void)TSS_SetSystemConfig(System_SystemConfig_Register,(TSS_SYSTEM_EN_MASK | TSS_DC_TRACKER_EN_MASK)); }