This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

DriverLib missing MSP430F6659 GPIO port 3 and 4 interrupt

Other Parts Discussed in Thread: MSP430F6659

Hello,

I just start to use DriverLib with MSP430F6659 and discovered that interrupt for port 3 and 4 was not managed by the library (see that in file GPIO.c).

Is this a bug or is there a plan to release a new version for support those interrupt?

Thank you for your help.

Max

  • Almost all MSPs only have interrupts on port 1+2. Having interrupts on P3+4 is new and it was probably just forgotten to implement.

    My guess is that the port funcitons in the lib have been written before this MSP was released.

  • Hello,

    Okay so for the moment as a kludge I just copied the interrupt function which not working
    and I corrected it in order to support PORT3 and 4 interrupt:

    7558.gpio_patch.h

    #include "gpio_patch.h"
    
    static uint32_t privateGPIOGetBaseAddress(uint8_t selectedPort)
    {
    	uint32_t baseAddress = 0xFFFF;
    	switch (selectedPort){
    
    #ifdef __MSP430_HAS_PORT1_R__
    		case GPIO_PORT_P1: baseAddress = __MSP430_BASEADDRESS_PORT1_R__; break;
    #endif
    #ifdef __MSP430_HAS_PORT2_R__
    		case GPIO_PORT_P2: baseAddress = __MSP430_BASEADDRESS_PORT2_R__; break;
    #endif
    #ifdef __MSP430_HAS_PORT3_R__
    		case GPIO_PORT_P3: baseAddress = __MSP430_BASEADDRESS_PORT3_R__; break;
    #endif
    #ifdef __MSP430_HAS_PORT4_R__
    		case GPIO_PORT_P4: baseAddress = __MSP430_BASEADDRESS_PORT4_R__; break;
    #endif
    #ifdef __MSP430_HAS_PORT5_R__
    		case GPIO_PORT_P5: baseAddress = __MSP430_BASEADDRESS_PORT5_R__; break;
    #endif
    #ifdef __MSP430_HAS_PORT6_R__
    		case GPIO_PORT_P6: baseAddress = __MSP430_BASEADDRESS_PORT6_R__; break;
    #endif
    #ifdef __MSP430_HAS_PORT7_R__
    		case GPIO_PORT_P7: baseAddress = __MSP430_BASEADDRESS_PORT7_R__; break;
    #endif
    #ifdef __MSP430_HAS_PORT8_R__
    		case GPIO_PORT_P8: baseAddress = __MSP430_BASEADDRESS_PORT8_R__; break;
    #endif
    #ifdef __MSP430_HAS_PORT9_R__
    		case GPIO_PORT_P9: baseAddress = __MSP430_BASEADDRESS_PORT9_R__; break;
    #endif
    #ifdef __MSP430_HAS_PORT10_R__
    		case GPIO_PORT_P10: baseAddress = __MSP430_BASEADDRESS_PORT10_R__; break;
    #endif
    #ifdef __MSP430_HAS_PORT11_R__
    		case GPIO_PORT_P11: baseAddress = __MSP430_BASEADDRESS_PORT11_R__; break;
    #endif
    #ifdef __MSP430_HAS_PORTA_R__
    		case GPIO_PORT_PA: baseAddress = __MSP430_BASEADDRESS_PORTA_R__; break;
    #endif
    #ifdef __MSP430_HAS_PORTB_R__
    		case GPIO_PORT_PB: baseAddress = __MSP430_BASEADDRESS_PORTB_R__; break;
    #endif
    #ifdef __MSP430_HAS_PORTC_R__
    		case GPIO_PORT_PC: baseAddress = __MSP430_BASEADDRESS_PORTC_R__; break;
    #endif
    #ifdef __MSP430_HAS_PORTD_R__
    		case GPIO_PORT_PD: baseAddress = __MSP430_BASEADDRESS_PORTD_R__; break;
    #endif
    #ifdef __MSP430_HAS_PORTE_R__
    		case GPIO_PORT_PE: baseAddress = __MSP430_BASEADDRESS_PORTE_R__; break;
    #endif
    #ifdef __MSP430_HAS_PORTF_R__
    		case GPIO_PORT_PF: baseAddress = __MSP430_BASEADDRESS_PORTF_R__; break;
    #endif
    #ifdef __MSP430_HAS_PORTJ_R__
    		case GPIO_PORT_PJ: baseAddress = __MSP430_BASEADDRESS_PORTJ_R__; break;
    #endif
    
    	}
    	return baseAddress;
    }
    
    
    // THIS IS A PATCH BECAUSE DRIVERLIB DOESNT SUPPORT INTERRUPT ON PORT 3 and 4 FOR THE MOMENT
    void GPIO_enableInterrupt_PATCHED (
        uint8_t selectedPort,
        uint16_t selectedPins
        )
    {
    	assert((GPIO_PORT_P1 == selectedPort) || (GPIO_PORT_P2 == selectedPort) ||
    	        (GPIO_PORT_PA == selectedPort) ||
    	        (GPIO_PORT_P3 == selectedPort) || (GPIO_PORT_P4 == selectedPort) ||
    	        (GPIO_PORT_PB == selectedPort)
    	        );
    
         assert(0x00 != (selectedPins & (GPIO_PIN0 + GPIO_PIN1 + GPIO_PIN2 +
                                         GPIO_PIN3 + GPIO_PIN4 + GPIO_PIN5 +
                                         GPIO_PIN6 + GPIO_PIN7 + GPIO_PIN8 +
                                         GPIO_PIN9 + GPIO_PIN10 + GPIO_PIN11 +
                                         GPIO_PIN12 + GPIO_PIN13 + GPIO_PIN14 +
                                         GPIO_PIN15
                 )));
    
    	uint32_t baseAddress  = privateGPIOGetBaseAddress(selectedPort);
    
    	assert((0xFFFF != baseAddress) );
        if(0xFFFF == baseAddress)
    	{
        	return;
    	}
    
        switch (selectedPort){
            case GPIO_PORT_P1:
                HWREG8(baseAddress + OFS_P1IE) |= (uint8_t) selectedPins;
                break;
            case GPIO_PORT_P2:
                HWREG8(baseAddress + OFS_P2IE) |= (uint8_t) selectedPins;
                break;
            case GPIO_PORT_PA:
                HWREG16(baseAddress + OFS_PAIE) |= selectedPins;
                break;
            case GPIO_PORT_P3:
    		   HWREG8(baseAddress + OFS_P3IE) |= (uint8_t) selectedPins;
    		   break;
    	   case GPIO_PORT_P4:
    		   HWREG8(baseAddress + OFS_P4IE) |= (uint8_t) selectedPins;
    		   break;
    	   case GPIO_PORT_PB:
    		   HWREG16(baseAddress + OFS_PBIE) |= selectedPins;
    		   break;
        }
    }
    
    //*****************************************************************************
    //
    //! This function clears the interrupt flag on the selected pin.
    // THIS IS A PATCH BECAUSE DRIVERLIB DOESNT SUPPORT INTERRUPT ON PORT 3 and 4 FOR THE MOMENT
    //
    //*****************************************************************************
    void GPIO_clearInterruptFlag_PATCHED (
        uint8_t selectedPort,
        uint16_t selectedPins
        )
    {
        assert((GPIO_PORT_P1 == selectedPort) || (GPIO_PORT_P2 == selectedPort) ||
            (GPIO_PORT_PA == selectedPort) ||
            (GPIO_PORT_P3 == selectedPort) || (GPIO_PORT_P4 == selectedPort) ||
            (GPIO_PORT_PB == selectedPort)
            );
    
         assert(0x00 != (selectedPins & (GPIO_PIN0 + GPIO_PIN1 + GPIO_PIN2 +
                                         GPIO_PIN3 + GPIO_PIN4 + GPIO_PIN5 +
                                         GPIO_PIN6 + GPIO_PIN7 + GPIO_PIN8 +
                                         GPIO_PIN9 + GPIO_PIN10 + GPIO_PIN11 +
                                         GPIO_PIN12 + GPIO_PIN13 + GPIO_PIN14 +
                                         GPIO_PIN15
                 )));
    
    	uint32_t baseAddress  = privateGPIOGetBaseAddress(selectedPort);
    
    	assert((0xFFFF != baseAddress) );
        if(0xFFFF == baseAddress)
    	{
    		return;
    	}
    
    
        switch (selectedPort){
            case GPIO_PORT_P1:
                HWREG8(baseAddress + OFS_P1IFG) &= (uint8_t) ~selectedPins;
                break;
            case GPIO_PORT_P2:
                HWREG8(baseAddress + OFS_P2IFG) &= (uint8_t) ~selectedPins;
                break;
            case GPIO_PORT_PA:
                HWREG16(baseAddress + OFS_PAIFG) &= ~selectedPins;
                break;
            case GPIO_PORT_P3:
    			HWREG8(baseAddress + OFS_P3IFG) &= (uint8_t) ~selectedPins;
    			break;
    		case GPIO_PORT_P4:
    			HWREG8(baseAddress + OFS_P4IFG) &= (uint8_t) ~selectedPins;
    			break;
    		case GPIO_PORT_PB:
    			HWREG16(baseAddress + OFS_PBIFG) &= ~selectedPins;
    			break;
        }
    }
    
    void GPIO_interruptEdgeSelect_PATCHED (
        uint8_t selectedPort,
        uint16_t selectedPins,
        uint8_t edgeSelect
        )
    {
        assert((GPIO_PORT_P1 == selectedPort) || (GPIO_PORT_P2 == selectedPort)||
        		(GPIO_PORT_P3 == selectedPort) || (GPIO_PORT_P4 == selectedPort));
    
         assert(0x00 != (selectedPins & (GPIO_PIN0 + GPIO_PIN1 + GPIO_PIN2 +
                                         GPIO_PIN3 + GPIO_PIN4 + GPIO_PIN5 +
                                         GPIO_PIN6 + GPIO_PIN7 + GPIO_PIN8 +
                                         GPIO_PIN9 + GPIO_PIN10 + GPIO_PIN11 +
                                         GPIO_PIN12 + GPIO_PIN13 + GPIO_PIN14 +
                                         GPIO_PIN15
                 )));
    
    	uint32_t baseAddress  = privateGPIOGetBaseAddress(selectedPort);
    
    	assert((0xFFFF != baseAddress) );
        if(0xFFFF == baseAddress)
    	{
    		return;
    	}
    
        assert((edgeSelect == GPIO_HIGH_TO_LOW_TRANSITION) ||
            (edgeSelect == GPIO_LOW_TO_HIGH_TRANSITION)
            );
    
        switch (selectedPort){
            case GPIO_PORT_P1:
                if (GPIO_LOW_TO_HIGH_TRANSITION == edgeSelect){
                    HWREG8(baseAddress + OFS_P1IES) &= (uint8_t) ~selectedPins;
                } else   {
                    HWREG8(baseAddress + OFS_P1IES) |= (uint8_t) selectedPins;
                }
                break;
    
            case GPIO_PORT_P2:
                if (GPIO_LOW_TO_HIGH_TRANSITION == edgeSelect){
                    HWREG8(baseAddress + OFS_P2IES) &= (uint8_t) ~selectedPins;
                } else  {
                    HWREG8(baseAddress + OFS_P2IES) |= (uint8_t) selectedPins;
                }
                break;
            case GPIO_PORT_P3:
    		   if (GPIO_LOW_TO_HIGH_TRANSITION == edgeSelect){
    			   HWREG8(baseAddress + OFS_P3IES) &= (uint8_t) ~selectedPins;
    		   } else   {
    			   HWREG8(baseAddress + OFS_P3IES) |= (uint8_t) selectedPins;
    		   }
    		   break;
    
    	   case GPIO_PORT_P4:
    		   if (GPIO_LOW_TO_HIGH_TRANSITION == edgeSelect){
    			   HWREG8(baseAddress + OFS_P4IES) &= (uint8_t) ~selectedPins;
    		   } else  {
    			   HWREG8(baseAddress + OFS_P4IES) |= (uint8_t) selectedPins;
    		   }
    		   break;
        }
    }
    
    void GPIO_disableInterrupt_PATCHED (
        uint8_t selectedPort,
        uint16_t selectedPins
        )
    {
    	assert((GPIO_PORT_P1 == selectedPort) || (GPIO_PORT_P2 == selectedPort) ||
    		        (GPIO_PORT_PA == selectedPort) ||
    		        (GPIO_PORT_P3 == selectedPort) || (GPIO_PORT_P4 == selectedPort) ||
    		        (GPIO_PORT_PB == selectedPort)
    		        );
    
         assert(0x00 != (selectedPins & (GPIO_PIN0 + GPIO_PIN1 + GPIO_PIN2 +
                                         GPIO_PIN3 + GPIO_PIN4 + GPIO_PIN5 +
                                         GPIO_PIN6 + GPIO_PIN7 + GPIO_PIN8 +
                                         GPIO_PIN9 + GPIO_PIN10 + GPIO_PIN11 +
                                         GPIO_PIN12 + GPIO_PIN13 + GPIO_PIN14 +
                                         GPIO_PIN15
                 )));
    
    	uint32_t baseAddress  = privateGPIOGetBaseAddress(selectedPort);
    
    	assert((0xFFFF != baseAddress) );
        if(0xFFFF == baseAddress)
    	{
    		return;
    	}
        switch (selectedPort){
            case GPIO_PORT_P1:
                HWREG8(baseAddress + OFS_P1IE) &= (uint8_t) ~selectedPins;
                break;
            case GPIO_PORT_P2:
                HWREG8(baseAddress + OFS_P2IE) &= (uint8_t) ~selectedPins;
                break;
            case GPIO_PORT_PA:
                HWREG16(baseAddress + OFS_PAIE) &= ~selectedPins;
                break;
            case GPIO_PORT_P3:
    		   HWREG8(baseAddress + OFS_P3IE) &= (uint8_t) ~selectedPins;
    		   break;
    	   case GPIO_PORT_P4:
    		   HWREG8(baseAddress + OFS_P4IE) &= (uint8_t) ~selectedPins;
    		   break;
    	   case GPIO_PORT_PB:
    		   HWREG16(baseAddress + OFS_PBIE) &= ~selectedPins;
    		   break;
        }
    }
    
    uint16_t GPIO_getInterruptStatus_PATCHED (
        uint8_t selectedPort,
        uint16_t selectedPins
        )
    {
    	assert((GPIO_PORT_P1 == selectedPort) || (GPIO_PORT_P2 == selectedPort) ||
    	        (GPIO_PORT_PA == selectedPort) ||
    	        (GPIO_PORT_P3 == selectedPort) || (GPIO_PORT_P4 == selectedPort) ||
    	        (GPIO_PORT_PB == selectedPort)
    	        );
    
         assert(0x00 != (selectedPins & (GPIO_PIN0 + GPIO_PIN1 + GPIO_PIN2 +
                                         GPIO_PIN3 + GPIO_PIN4 + GPIO_PIN5 +
                                         GPIO_PIN6 + GPIO_PIN7 + GPIO_PIN8 +
                                         GPIO_PIN9 + GPIO_PIN10 + GPIO_PIN11 +
                                         GPIO_PIN12 + GPIO_PIN13 + GPIO_PIN14 +
                                         GPIO_PIN15
                 )));
    
    	uint32_t baseAddress  = privateGPIOGetBaseAddress(selectedPort);
    
    	assert((0xFFFF != baseAddress) );
    
        uint8_t returnValue;
    
        switch (selectedPort){
            case GPIO_PORT_P1:
                returnValue = (HWREG8(baseAddress + OFS_P1IFG) & ((uint8_t) selectedPins));
                break;
            case GPIO_PORT_P2:
                returnValue = (HWREG8(baseAddress + OFS_P2IFG) & ((uint8_t) selectedPins));
                break;
            case GPIO_PORT_PA:
                returnValue = (HWREG16(baseAddress + OFS_PAIFG) & ((uint8_t) selectedPins));
                break;
            case GPIO_PORT_P3:
    		   returnValue = (HWREG8(baseAddress + OFS_P3IFG) & ((uint8_t) selectedPins));
    		   break;
    	   case GPIO_PORT_P4:
    		   returnValue = (HWREG8(baseAddress + OFS_P4IFG) & ((uint8_t) selectedPins));
    		   break;
    	   case GPIO_PORT_PB:
    		   returnValue = (HWREG16(baseAddress + OFS_PBIFG) & ((uint8_t) selectedPins));
    		   break;
        }
    
        return ( returnValue) ;
    }
    
    //This function doesn't exist in current driverlib
    unsigned short GPIO_getInputPortValue_PATCHED (uint8_t selectedPort)
    {
       assert((GPIO_PORT_P1 == selectedPort) || (GPIO_PORT_P2 == selectedPort) ||
            (GPIO_PORT_P3 == selectedPort) || (GPIO_PORT_P4 == selectedPort) ||
            (GPIO_PORT_P5 == selectedPort) || (GPIO_PORT_P6 == selectedPort) ||
            (GPIO_PORT_P7 == selectedPort) || (GPIO_PORT_P8 == selectedPort) ||
            (GPIO_PORT_P9 == selectedPort) || (GPIO_PORT_P10 == selectedPort) ||
            (GPIO_PORT_P11 == selectedPort) || (GPIO_PORT_PA == selectedPort) ||
            (GPIO_PORT_PB == selectedPort) || (GPIO_PORT_PC == selectedPort) ||
            (GPIO_PORT_PD == selectedPort) || (GPIO_PORT_PE == selectedPort) ||
            (GPIO_PORT_PF == selectedPort) || (GPIO_PORT_PJ == selectedPort)
            );
    
    	uint32_t baseAddress  = privateGPIOGetBaseAddress(selectedPort);
    
    	assert((0xFFFF != baseAddress) );
    
    
        uint16_t inputPortValue = 0;
    
        switch (selectedPort){
            case GPIO_PORT_P1:
    		case GPIO_PORT_P3:
    		case GPIO_PORT_P5:
    		case GPIO_PORT_P7:
    		case GPIO_PORT_P9:
    			inputPortValue = HWREG8(baseAddress + OFS_P1IN);
                break;
            case GPIO_PORT_P2:
    		case GPIO_PORT_P4:
    		case GPIO_PORT_P6:
    		case GPIO_PORT_P8:
    		case GPIO_PORT_P10:
    			inputPortValue = HWREG8(baseAddress + OFS_P2IN);
                break;
            case GPIO_PORT_PA:
    		case GPIO_PORT_PB:
    		case GPIO_PORT_PC:
    		case GPIO_PORT_PD:
    		case GPIO_PORT_PE:
    		case GPIO_PORT_PF:
    		case GPIO_PORT_PJ:
    		case GPIO_PORT_P11:
    			inputPortValue = HWREG16(baseAddress + OFS_PAIN);
                break;
        }
        return ( inputPortValue) ;
    }
    
    

    Just add this file to the project and use it as with the lib for example:

    GPIO_clearInterruptFlag_PATCHED(...,...);

    It work on all the 4 port which support interrupt...

    Max

**Attention** This is a public forum