cancel
Showing results for 
Search instead for 
Did you mean: 

Stm8 touch library

puneet271178
Associate
Posted on May 07, 2014 at 09:18

I intend to implement a single touch key using stm8 touch library. I am having few issues regarding this.

I haven't used the shield concept for noise immunity, so what does a need to define for : SCKEY_P2_DRIVEN_SHIELD_MASK in the configuration file.

&sharpinclude''stm8s.h''

&sharpinclude''stm8_tsl_api.h''

&sharpdefine LED1_GPIO_PORT             (GPIOB)

&sharpdefine LED1_GPIO_PIN             (GPIO_PIN_4)

void main()

{

  LED1_GPIO_PORT->ODR |= (uint8_t)(LED1_GPIO_PIN);

  LED1_GPIO_PORT->DDR |= (uint8_t)(LED1_GPIO_PIN);

  LED1_GPIO_PORT->CR1 |= (uint8_t)(LED1_GPIO_PIN);

  LED1_GPIO_PORT->CR2 &= (uint8_t)(~(LED1_GPIO_PIN));

  

  TSL_Init();

  sSCKeyInfo[0].Setting.b.IMPLEMENTED = 1;

  sSCKeyInfo[0].Setting.b.ENABLED = 1;

  sSCKeyInfo[0].DxSGroup = 0x01;

  while(1)

  {

    TSL_Action();

    if (sSCKeyInfo[0].Setting.b.DETECTED)

    {

    LED1_GPIO_PORT->ODR &= ~(uint8_t)(LED1_GPIO_PIN);  

    }

    

    else

    {

    LED1_GPIO_PORT->ODR |= (uint8_t)(LED1_GPIO_PIN);  

    }

    

  }

}

Also here is the main file code , I am not too clear about the validity of this code too. Please provide me help on this issue.

Thank you.

#stm8s-touch-sensing
0 REPLIES 0