buttonISR Issue

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

buttonISR Issue

572 Views
Dilip1441
Contributor I

Hi,

I'm facing the issue with buttonISR, In my code i'm checking the Pin Pressed Status like below

uint32_t buttonsPressed = ((PINS_DRV_GetPortIntFlag(BTN_PORT_D) | PINS_DRV_GetPortIntFlag(BTN_PORT)) & ((1 << BTN1_PIN) | (1 << BTN2_PIN) | (1 << BTN3_PIN) | (1 << BTN4_PIN) | (1 << BTN5_PIN) | (1 << BTN6_PIN) | (1 << BTN7_PIN)));

 

1.If i add no.of pins then need to increase the no.of Pin Status check lines->Pease give the Solution without increasing the Lines of code  to check the Pin Status.

2.The Above Logic for Pin Press Status check for 2 Port pins(Port C and Port D)-As per the Above logic it 'll works only there is a difference in the Selected Port Pins(Port C-1,2,3,4,5 and Port D-6,7,8,9,10 ), But It'll not work if i select the Same pins i Different Ports(Port C-1,2,3,4,5 and Port D-1,2,3,4,5)---Please give the Solution for this.

3.I'm Checking the Particular Pin is Pressed or not Status using the Switch case only like below,So it'll check Sequentially--Is there any option to check the Pin Status at a time Parallelly.

4.Is there any Predefined Function to Check the Debounce of the Switch, Please Provide the Debounce

Function or Useful Logic to check the Switch Debounces.

if((buttonsPressed != 0))
{
/* Set FlexCAN TX value according to the button pressed */
switch (buttonsPressed)
{
case (1 << BTN1_PIN):
/* Toggle output value LED1 */
PINS_DRV_TogglePins(GPIO_PORT, (1 << LED1));
Int_flag_1 = 1;

/* Clear interrupt flag */
PINS_DRV_ClearPinIntFlagCmd(BTN_PORT, BTN1_PIN);
break;
case (1 << BTN2_PIN):
/* Toggle output value LED2 */
PINS_DRV_TogglePins(GPIO_PORT, (1 << LED2));
Int_flag_2 = 1;

/* Clear interrupt flag */
PINS_DRV_ClearPinIntFlagCmd(BTN_PORT, BTN2_PIN);
break;

0 Kudos
Reply
0 Replies