/** * @brief Main program. * @param None * @retval None */ int main(void) { tsl_user_status_t tsl_status; /* STM32F0xx HAL library initialization: - Configure the Flash prefetch - Systick timer is configured by default as source of time base, but user can eventually implement his proper time base source (a general purpose timer for example or other time source), keeping in mind that Time base duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and handled in milliseconds basis. - Low Level Initialization */ HAL_Init(); /* Configure the system clock to 48 MHz */ SystemClock_Config(); /* Configure LEDs */ BSP_LED_Init(LED4); BSP_LED_Init(LED5); BSP_LED_Init(LED3); /* Configure the TSC peripheral */ TscHandle.Instance = TSCx; TscHandle.Init.AcquisitionMode = TSC_ACQ_MODE_NORMAL; TscHandle.Init.CTPulseHighLength = TSC_CTPH_2CYCLES; TscHandle.Init.CTPulseLowLength = TSC_CTPL_2CYCLES; TscHandle.Init.IODefaultMode = TSC_IODEF_OUT_PP_LOW; TscHandle.Init.MaxCountInterrupt = DISABLE; TscHandle.Init.MaxCountValue = TSC_MCV_8191; TscHandle.Init.PulseGeneratorPrescaler = TSC_PG_PRESC_DIV64; TscHandle.Init.SpreadSpectrum = DISABLE; TscHandle.Init.SpreadSpectrumDeviation = 127; TscHandle.Init.SpreadSpectrumPrescaler = TSC_SS_PRESC_DIV1; TscHandle.Init.SynchroPinPolarity = TSC_SYNC_POLARITY_FALLING; /* All channel, shield and sampling IOs must be declared below */ TscHandle.Init.ChannelIOs = (TSC_GROUP1_IO3 | TSC_GROUP2_IO3 | TSC_GROUP3_IO2); TscHandle.Init.SamplingIOs = (TSC_GROUP1_IO4 | TSC_GROUP2_IO4 | TSC_GROUP3_IO3); TscHandle.Init.ShieldIOs = 0; if (HAL_TSC_Init(&TscHandle) != HAL_OK) { /* Initialization Error */ Error_Handler(); } /* Initialize the STMTouch driver */ tsl_user_Init(); /* Infinite loop */ while (1) { /* Execute STMTouch Driver state machine */ tsl_status = tsl_user_Exec(); if (tsl_status != TSL_USER_STATUS_BUSY) { Process_Sensors(tsl_status); } } }
/** * @brief Main program * @param None * @retval None */ int main(void) { tsl_user_status_t tsl_status; /* STM32L0xx HAL library initialization: - Configure the Flash prefetch, Flash preread and Buffer caches - Systick timer is configured by default as source of time base, but user can eventually implement his proper time base source (a general purpose timer for example or other time source), keeping in mind that Time base duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and handled in milliseconds basis. - Low Level Initialization */ HAL_Init(); /* Configure the system clock to get correspondent USB clock source */ SystemClock_Config(); /* Configure Key button for remote wakeup */ BSP_PB_Init(BUTTON_KEY, BUTTON_MODE_EXTI); /* Init Device Library */ USBD_Init(&USBD_Device, &HID_Desc, 0); /* Register the HID class */ USBD_RegisterClass(&USBD_Device, &USBD_HID); /* Start Device Process */ USBD_Start(&USBD_Device); /* Configure the TSL */ TSL_Config(); /* In an infinite loop, send periodically host mouse pointer position (emulated) */ while (1) { /* Execute STMTouch Driver state machine */ tsl_status = tsl_user_Exec(); if (tsl_status != TSL_USER_STATUS_BUSY) { Process_Sensors(tsl_status); } } }
/** * @brief Main program. * @param None * @retval None */ int main(void) { tsl_user_status_t tsl_status; /* STM32F0xx HAL library initialization: - Configure the Flash prefetch - Systick timer is configured by default as source of time base, but user can eventually implement his proper time base source (a general purpose timer for example or other time source), keeping in mind that Time base duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and handled in milliseconds basis. - Low Level Initialization */ HAL_Init(); /* Configure LEDs */ BSP_LED_Init(LED2); BSP_LED_Init(LED1); BSP_LED_Init(LED4); BSP_LED_Init(LED3); /* Configure the system clock to 48 MHz */ SystemClock_Config(); /* Configure the TSC peripheral */ TscHandle.Instance = TSCx; TscHandle.Init.AcquisitionMode = TSC_ACQ_MODE_NORMAL; TscHandle.Init.CTPulseHighLength = TSC_CTPH_2CYCLES; TscHandle.Init.CTPulseLowLength = TSC_CTPL_2CYCLES; TscHandle.Init.IODefaultMode = TSC_IODEF_OUT_PP_LOW; TscHandle.Init.MaxCountInterrupt = DISABLE; TscHandle.Init.MaxCountValue = TSC_MCV_8191; TscHandle.Init.PulseGeneratorPrescaler = TSC_PG_PRESC_DIV64; TscHandle.Init.SpreadSpectrum = DISABLE; TscHandle.Init.SpreadSpectrumDeviation = 127; TscHandle.Init.SpreadSpectrumPrescaler = TSC_SS_PRESC_DIV1; TscHandle.Init.SynchroPinPolarity = TSC_SYNC_POLARITY_FALLING; /* All channel, shield and sampling IOs must be declared below */ TscHandle.Init.ChannelIOs = (TSC_GROUP8_IO2 | TSC_GROUP8_IO1); TscHandle.Init.SamplingIOs = (TSC_GROUP8_IO3 | TSC_GROUP8_IO3 | TSC_GROUP6_IO1); TscHandle.Init.ShieldIOs = TSC_GROUP6_IO2; if (HAL_TSC_Init(&TscHandle) != HAL_OK) { /* Initialization Error */ Error_Handler(); } /* Just to indicate the fw is alive... */ BSP_LED_On(LED2); BSP_LED_On(LED1); BSP_LED_On(LED4); BSP_LED_On(LED3); /* Configure LCD */ #if USE_LCD > 0 BSP_LCD_Init(); BSP_LCD_SetFont(&LCD_DEFAULT_FONT); BSP_LCD_SetBackColor(LCD_COLOR_WHITE); BSP_LCD_Clear(LCD_COLOR_WHITE); BSP_LCD_SetTextColor(LCD_COLOR_DARKBLUE); BSP_LCD_DisplayStringAt(0, 10, (uint8_t *)"STM32F091xx", CENTER_MODE); BSP_LCD_DisplayStringAt(0, 35, (uint8_t *)"TouchSensing", CENTER_MODE); BSP_LCD_DisplayStringAt(0, 55, (uint8_t *)"Example", CENTER_MODE); #endif BSP_LED_Off(LED2); BSP_LED_Off(LED1); BSP_LED_Off(LED4); BSP_LED_Off(LED3); /* Initialize the STMTouch driver */ tsl_user_Init(); /* Infinite loop */ while (1) { /* Execute STMTouch Driver state machine */ tsl_status = tsl_user_Exec(); if (tsl_status != TSL_USER_STATUS_BUSY) { Process_Sensors(tsl_status); } } }