/** * @brief TSC Initialization Function * @param None * @retval None */ void MX_TSC_Init(void) { uint32_t del; volatile uint32_t a; /* USER CODE BEGIN TSC_Init 0 */ /* USER CODE END TSC_Init 0 */ /* USER CODE BEGIN TSC_Init 1 */ /** Configure the TSC peripheral */ htsc.Instance = TSC; htsc.Init.CTPulseHighLength = TSC_CTPH_2CYCLES; htsc.Init.CTPulseLowLength = TSC_CTPL_2CYCLES; htsc.Init.SpreadSpectrum = ENABLE; htsc.Init.SpreadSpectrumDeviation = 127; htsc.Init.SpreadSpectrumPrescaler = TSC_SS_PRESC_DIV1; htsc.Init.PulseGeneratorPrescaler = TSC_PG_PRESC_DIV64; htsc.Init.MaxCountValue = TSC_MCV_16383; htsc.Init.IODefaultMode = TSC_IODEF_OUT_PP_LOW; htsc.Init.SynchroPinPolarity = TSC_SYNC_POLARITY_FALLING; htsc.Init.AcquisitionMode = TSC_ACQ_MODE_NORMAL; htsc.Init.MaxCountInterrupt = DISABLE; // Origin, // htsc.Init.ChannelIOs = TSC_GROUP4_IO1; // htsc.Init.SamplingIOs = TSC_GROUP4_IO1 | TSC_GROUP4_IO2; // htsc.Init.ShieldIOs = TSC_GROUP1_IO2; // Current htsc.Init.ChannelIOs = TSC_GROUP2_IO2; htsc.Init.SamplingIOs = TSC_GROUP1_IO2 | TSC_GROUP2_IO3; htsc.Init.ShieldIOs = TSC_GROUP1_IO1; if (HAL_TSC_Init(&htsc) != HAL_OK) { Error_Handler(); } /* USER CODE BEGIN TSC_Init 2 */ /*##-2- Configure the touch-sensing IOs ####################################*/ // IoConfig.ChannelIOs = TSC_GROUP4_IO1; // IoConfig.SamplingIOs = TSC_GROUP4_IO1 | TSC_GROUP4_IO2; // IoConfig.ShieldIOs = TSC_GROUP1_IO2; IoConfig.ChannelIOs = TSC_GROUP2_IO2; IoConfig.SamplingIOs = TSC_GROUP1_IO2 | TSC_GROUP2_IO3; IoConfig.ShieldIOs = TSC_GROUP1_IO1; if (HAL_TSC_IOConfig(&htsc, &IoConfig) != HAL_OK) { /* Initialization Error */ Error_Handler(); } /*##-3- Discharge the touch-sensing IOs ####################################*/ HAL_TSC_IODischarge(&htsc, ENABLE); //ephraim change later add some delay // HAL_Delay(1); /* 1 ms is more than enough to discharge all capacitors */ for(del = 0;del < 100000;del++) a = del; /*##-4- Start the acquisition process ######################################*/ if (HAL_TSC_Start_IT(&htsc) != HAL_OK) { /* Acquisition Error */ Error_Handler(); } /* USER CODE END TSC_Init 2 */ }