void button_init()
{

    GPIO_setAsInputPin(INPUT1_BASEADDRESS, INPUT1_PORT, INPUT1_PIN);
    GPIO_setAsInputPin(INPUT2_BASEADDRESS, INPUT2_PORT, INPUT2_PIN);
    GPIO_setAsInputPin(INPUT2_BASEADDRESS, INPUT3_PORT, INPUT3_PIN);

}
Esempio n. 2
0
void button_init()
{
    GPIO_setAsInputPinWithPullUpResistor(GPIO_PORT_P1, GPIO_PIN1);	// LaunchPad Button2
    GPIO_setAsInputPinWithPullUpResistor(GPIO_PORT_P2, GPIO_PIN1);	// LaunchPad Button1

    GPIO_setAsInputPin(GPIO_PORT_P6, GPIO_PIN3);		// SernorHub push button 1
    GPIO_setAsInputPin(GPIO_PORT_P6, GPIO_PIN4);		// SernorHub push button 2

    GPIO_setAsInputPinWithPullUpResistor(GPIO_PORT_P6, GPIO_PIN0);  // TI Button RV1
    GPIO_setAsInputPinWithPullUpResistor(GPIO_PORT_P6, GPIO_PIN1);  // TI Button RV2
}
Esempio n. 3
0
/**********************************************************************//**
 * @brief  Initializes the System
 *
 * @param  none
 *
 * @return none
 *************************************************************************/
void SystemInit(void)
{
    // Set the DCO to 8MHz (it's also the device's power-on setting). Do not change this frequency!
    // It impacts the cap touch scan window.
    CS_setDCOFreq(__MSP430_BASEADDRESS_CS__, CS_DCORSEL_0, CS_DCOFSEL_6);

    // Configure clock source and clock dividers. After this the clock configuration will be as follows:
    // ACLK=LFXT1/1=32,768Hz; SMCLK=DCOCLK/1=8MHz; and MCLK=DCOCLK/1=8MHz.
    CS_clockSignalInit(__MSP430_BASEADDRESS_CS__, CS_ACLK, CS_LFXTCLK_SELECT, CS_CLOCK_DIVIDER_1);
    CS_clockSignalInit(__MSP430_BASEADDRESS_CS__, CS_SMCLK, CS_DCOCLK_SELECT, CS_CLOCK_DIVIDER_1);
    CS_clockSignalInit(__MSP430_BASEADDRESS_CS__, CS_MCLK, CS_DCOCLK_SELECT, CS_CLOCK_DIVIDER_1);

    // Set all GPIO to output low to minimize current draw by eliminating floating pins.
    GPIO_setOutputLowOnPin(GPIO_PORT_PA, 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);
    GPIO_setOutputLowOnPin(GPIO_PORT_PB, 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);
    GPIO_setOutputLowOnPin(GPIO_PORT_PJ, GPIO_PIN0 | GPIO_PIN1 | GPIO_PIN2 | GPIO_PIN3 | GPIO_PIN6 | GPIO_PIN7 | GPIO_PIN8 | GPIO_PIN9 | GPIO_PIN10 | GPIO_PIN11 | GPIO_PIN12 | GPIO_PIN13 | GPIO_PIN14 | GPIO_PIN15);
    GPIO_setAsOutputPin(GPIO_PORT_PA, 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);
    GPIO_setAsOutputPin(GPIO_PORT_PB, 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);
    GPIO_setAsOutputPin(GPIO_PORT_PJ, GPIO_PIN0 | GPIO_PIN1 | GPIO_PIN2 | GPIO_PIN3 | GPIO_PIN6 | GPIO_PIN7 | GPIO_PIN8 | GPIO_PIN9 | GPIO_PIN10 | GPIO_PIN11 | GPIO_PIN12 | GPIO_PIN13 | GPIO_PIN14 | GPIO_PIN15);

    // Configure the left button (S2) connected to P4.6. For this enable the internal pull-up resistor and
    // setup the pin interrupt to trigger on rising edges.
    GPIO_setAsInputPinWithPullUpresistor(GPIO_PORT_P4, GPIO_PIN5);
    GPIO_interruptEdgeSelect(GPIO_PORT_P4, GPIO_PIN5, GPIO_LOW_TO_HIGH_TRANSITION);
    GPIO_clearInterruptFlag(GPIO_PORT_P4, GPIO_PIN5);
    GPIO_enableInterrupt(GPIO_PORT_P4, GPIO_PIN5);

    // Configure the right button (S3) connected to P1.1. For this enable the internal pull-up resistor and
    // setup the pin interrupt to trigger on rising edges.
    GPIO_setAsInputPinWithPullUpresistor(GPIO_PORT_P1, GPIO_PIN1);
    GPIO_interruptEdgeSelect(GPIO_PORT_P1, GPIO_PIN1, GPIO_LOW_TO_HIGH_TRANSITION);
    GPIO_clearInterruptFlag(GPIO_PORT_P1, GPIO_PIN1);
    GPIO_enableInterrupt(GPIO_PORT_P1, GPIO_PIN1);

    // CapSense Setup. GPIO pins P1.3-1.5 and P3.4-3.6 are used for capacitive touch so let's
    // switch them to inputs.
 //   GPIO_setAsInputPin(GPIO_PORT_P1, GPIO_PIN3 | GPIO_PIN4 | GPIO_PIN5);
    GPIO_setAsInputPin(GPIO_PORT_P3, GPIO_PIN4 | GPIO_PIN5 | GPIO_PIN6);

    // Enable LFXT functionality on PJ.4 and PJ.5. For this we only need to configure PJ.4 to
    // LFXIN and the port module logic takes care of the rest.
    GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_PJ, GPIO_PIN4, GPIO_PRIMARY_MODULE_FUNCTION);

    // Disable the GPIO power-on default high-impedance mode to activate previously configured port settings
    PMM_unlockLPM5(__MSP430_BASEADDRESS_PMM_FRAM__);

    // Perform the required LFXT startup procedure now that all of the port pins are configured.
    CS_setExternalClockSource(__MSP430_BASEADDRESS_CS__, 32768, 0);
    CS_LFXTStart(__MSP430_BASEADDRESS_CS__, CS_LFXT_DRIVE0);

    // Initialize LCD driver and the context for the LCD
    Sharp96x96_LCDInit();
    TA0_enableVCOMToggle();
    GrContextInit(&sContext, &g_sharp96x96LCD);
    GrContextForegroundSet(&sContext, ClrBlack);
    GrContextBackgroundSet(&sContext, ClrWhite);


    onLED();                                   //blink LED1
}
__LINK_C error_t hw_gpio_configure_pin(pin_id_t pin_id, cc430_gpio_mode_t mode)
{
    // TODO check if already configured (return EALREADY)

    if(mode == GPIO_MODE_OUTPUT || mode == GPIO_MODE_OUTPUT_FULL_DRIVE_STRENGTH)
    {
        GPIO_setAsOutputPin(pin_id.port, pin_id.pin);
        if(mode == GPIO_MODE_OUTPUT_FULL_DRIVE_STRENGTH)
            GPIO_setDriveStrength(pin_id.port, pin_id.pin, GPIO_FULL_OUTPUT_DRIVE_STRENGTH);
    }
    else if(mode ==GPIO_MODE_INPUT)
        GPIO_setAsInputPin(pin_id.port, pin_id.pin);
    else if(mode == GPIO_MODE_INPUT_PULL_UP)
        GPIO_setAsInputPinWithPullUpResistor(pin_id.port, pin_id.pin);
    else if(mode == GPIO_MODE_INPUT_PULL_DOWN)
        GPIO_setAsInputPinWithPullDownResistor(pin_id.port, pin_id.pin);

    return SUCCESS;
}
Esempio n. 5
0
void Board_init(void)
{
    // Setup XT1 and XT2
  GPIO_setAsPeripheralModuleFunctionInputPin(
        GPIO_PORT_P5,
        GPIO_PIN2 + GPIO_PIN3 + 
        GPIO_PIN4 + GPIO_PIN5
          );

   GPIO_setOutputLowOnPin(
        GPIO_PORT_P1,
        GPIO_PIN0 + GPIO_PIN1 + GPIO_PIN2 + 
        GPIO_PIN3 + GPIO_PIN4 + GPIO_PIN5
        );
   
    // Configure LED ports
    GPIO_setAsOutputPin(
        GPIO_PORT_P1,
        GPIO_PIN0 + GPIO_PIN1 + GPIO_PIN2 + 
        GPIO_PIN3 + GPIO_PIN4 + GPIO_PIN5
        );
    
    GPIO_setOutputLowOnPin(
        GPIO_PORT_P8,
        GPIO_PIN1 + GPIO_PIN2
        );
    
    GPIO_setAsOutputPin(
        GPIO_PORT_P8,
        GPIO_PIN1 + GPIO_PIN2
        );
    
    // Configure button ports
    // Buttons on P1.7/P2.2 are inputs
    GPIO_setAsInputPin(
        GPIO_PORT_PA,
        GPIO_PIN7 + GPIO_PIN10
        );

    // Configure CapTouch ports
    GPIO_setOutputLowOnPin(
        GPIO_PORT_P1,
        GPIO_PIN1 + GPIO_PIN2 + GPIO_PIN3 + 
        GPIO_PIN4 + GPIO_PIN5 + GPIO_PIN6
        );
    GPIO_setAsOutputPin(
        GPIO_PORT_P1,
        GPIO_PIN1 + GPIO_PIN2 + GPIO_PIN3 + 
        GPIO_PIN4 + GPIO_PIN5 + GPIO_PIN6
        );
    
    GPIO_setOutputLowOnPin(
        GPIO_PORT_P6,
        GPIO_PIN0 + GPIO_PIN1 + GPIO_PIN2 + GPIO_PIN3 + 
        GPIO_PIN4 + GPIO_PIN5 + GPIO_PIN6 + GPIO_PIN7
        );
    GPIO_setAsInputPin(
        GPIO_PORT_P6,
        GPIO_PIN0 + GPIO_PIN1 + GPIO_PIN2 + GPIO_PIN3 + 
        GPIO_PIN4 + GPIO_PIN5 + GPIO_PIN6 + GPIO_PIN7
        );

    // Configure Cma3000 ports
    // ACCEL_INT pin is input
    GPIO_setAsInputPin(
        GPIO_PORT_P2,
        GPIO_PIN5
        );
    
    // SCK
    GPIO_setOutputLowOnPin(
        GPIO_PORT_P2,
        GPIO_PIN7
        );
    GPIO_setAsOutputPin(
        GPIO_PORT_P2,
        GPIO_PIN7
        );
    
    // ACCEL_SIMO, ACCEL_CS, ACCEL_PWR to low
    GPIO_setOutputLowOnPin(
        GPIO_PORT_P3,
        GPIO_PIN3 + GPIO_PIN5 + GPIO_PIN6
        );
    
    // ACCEL_SOMI pin is input
    GPIO_setAsInputPin(
        GPIO_PORT_P3,
        GPIO_PIN4
        );
    
    // ACCEL_SIMO, ACCEL_CS, ACCEL_PWR as outp
    GPIO_setAsOutputPin(
        GPIO_PORT_P3,
        GPIO_PIN3 + GPIO_PIN5 + GPIO_PIN6
        );

    // Configure Dogs102x6 ports
    // LCD_C/D, LCD_RST
    GPIO_setOutputLowOnPin(
        GPIO_PORT_P5,
        GPIO_PIN6 + GPIO_PIN7
        );

    GPIO_setAsOutputPin(
        GPIO_PORT_P5,
        GPIO_PIN6 + GPIO_PIN7
        );
    
    // LCD_CS, LCD_BL_EN
    GPIO_setOutputLowOnPin(
        GPIO_PORT_P7,
        GPIO_PIN4 + GPIO_PIN6
        );
   
    GPIO_setAsOutputPin(
        GPIO_PORT_P7,
        GPIO_PIN4 + GPIO_PIN6
        );
    
    // SIMO, SCK
    GPIO_setOutputLowOnPin(
        GPIO_PORT_P4,
        GPIO_PIN1 + GPIO_PIN3
        );
    
    // SOMI pin is input
    GPIO_setAsInputPin(
        GPIO_PORT_P4,
        GPIO_PIN2
        );
    
    GPIO_setAsOutputPin(
        GPIO_PORT_P4,
        GPIO_PIN1 + GPIO_PIN3 
        );


    // Configure SDCard ports
    // SD_CS to high
    GPIO_setOutputHighOnPin(
        GPIO_PORT_P3,
        GPIO_PIN7
        );
    GPIO_setAsOutputPin(
        GPIO_PORT_P3,
        GPIO_PIN7
        );

    // Configure Wheel ports
    // A5 ADC input
    GPIO_setAsInputPin(
        GPIO_PORT_P6,
        GPIO_PIN5
        );
    
    // POT_PWR
    GPIO_setOutputLowOnPin(
        GPIO_PORT_P8,
        GPIO_PIN0
        );
    GPIO_setAsOutputPin(
        GPIO_PORT_P8,
        GPIO_PIN0
        );

    // Configure unused ports for low power
    GPIO_setOutputLowOnPin(
        GPIO_PORT_P2,
        GPIO_PIN0 + GPIO_PIN1 + GPIO_PIN3 + 
        GPIO_PIN4 + GPIO_PIN6
        );
    GPIO_setAsOutputPin(
        GPIO_PORT_P2,
        GPIO_PIN0 + GPIO_PIN1 + GPIO_PIN3 + 
        GPIO_PIN4 + GPIO_PIN6
        );

    GPIO_setOutputLowOnPin(
        GPIO_PORT_P3,
        GPIO_PIN0 + GPIO_PIN1 + GPIO_PIN2
        );
    GPIO_setAsOutputPin(
        GPIO_PORT_P3,
        GPIO_PIN0 + GPIO_PIN1 + GPIO_PIN2
        );

    GPIO_setOutputLowOnPin(
        GPIO_PORT_P4,
        GPIO_PIN0 + GPIO_PIN6 + GPIO_PIN7
        );
    GPIO_setAsOutputPin(
        GPIO_PORT_P4,
        GPIO_PIN0 + GPIO_PIN6 + GPIO_PIN7
        );
    

    GPIO_setOutputLowOnPin(
        GPIO_PORT_P5,
        GPIO_PIN1
        );
    GPIO_setAsOutputPin(
        GPIO_PORT_P5,
        GPIO_PIN1
        );

    GPIO_setOutputLowOnPin(
        GPIO_PORT_P6,
        GPIO_PIN6 + GPIO_PIN7
        );
    GPIO_setAsOutputPin(
        GPIO_PORT_P6,
        GPIO_PIN6 + GPIO_PIN7
        );

   GPIO_setOutputLowOnPin(
        GPIO_PORT_P7,
        GPIO_PIN0 + GPIO_PIN1 + GPIO_PIN2 + 
        GPIO_PIN3 + GPIO_PIN5+ GPIO_PIN7
        );
    GPIO_setAsOutputPin(
        GPIO_PORT_P7,
        GPIO_PIN0 + GPIO_PIN1 + GPIO_PIN2 + 
        GPIO_PIN3 + GPIO_PIN5+ GPIO_PIN7
        );
}
uint8_t CYC_SYS_UART1_Initialize()
{
//	Set the values
UINT32	__IO lu32ACLKValue = 0;

uint8_t	lsReturnValue = SUCCESS;

//	Get Auxiliary Clock Source value
lu32ACLKValue = UCS_getACLK(UCS_BASE);

#ifdef TARGET_MSP430F5438A_EXPERIMENTER_BOARD
//P3.4,5 = USCI_A0 TXD/RXD
GPIO_setAsPeripheralModuleFunctionOutputPin(
    GPIO_PORT_P3,
    GPIO_PIN4
    );

GPIO_setAsPeripheralModuleFunctionInputPin(
        GPIO_PORT_P3,
        GPIO_PIN5
        );
#endif

#ifdef TARGET_CYCLOPS_GAME
//P3.3 = USCI_A0 TXD
GPIO_setAsPeripheralModuleFunctionOutputPin(
    GPIO_PORT_P4,
    GPIO_PIN4
    );

//P3.4 = USCI_A0 RXD
GPIO_setAsPeripheralModuleFunctionInputPin(
        GPIO_PORT_P4,
        GPIO_PIN5
        );
#endif

/*
Call the MSP43Ware function to initialize the UART port with the following configurations
	1. PORT 1
	2. Use SMCLK as Source
	3. Value of SMCLK is 12MHz
	4. Prescalar value to generate 57600 is 208
	5. First stage modulator value is 5
	6. Second stage modulator is ignored and value is set to 0
	7. No Parity bits

 */
USCI_UART_initAdvance ( UART_PORT_1_BASE_ADDRESS,
						USCI_UART_CLOCKSOURCE_SMCLK,
						BAUDRATE_CLK_PRESCALER,
						FIRST_STAGE_MODULATOR_VALUE,
						SECOND_STAGE_MODULATOR_VALUE,
						USCI_UART_NO_PARITY,
						USCI_UART_LSB_FIRST,
						USCI_UART_ONE_STOP_BIT,
						USCI_UART_MODE,
						USCI_UART_OVERSAMPLING_BAUDRATE_GENERATION
    				);


//Enable UART module for operation
USCI_UART_enable(USCI_A1_BASE);

//Enable Receive Interrupt
USCI_UART_clearInterruptFlag(USCI_A1_BASE,
		USCI_UART_RECEIVE_INTERRUPT
    );
USCI_UART_enableInterrupt(USCI_A1_BASE,
		USCI_UART_RECEIVE_INTERRUPT
    );


GPIO_setAsOutputPin(GPIO_PORT_P4, GPIO_PIN3);   /*CTS line. Should be HIGH when we are processing received data.  should be LOW when we are Ready to receive data*/
GPIO_setAsInputPin(GPIO_PORT_P4, GPIO_PIN0);   /*RTS line. Should be LOW if it is OK to send data.  Will be HIGH when it is not ok to send data*/
GPIO_setOutputLowOnPin(GPIO_PORT_P4,GPIO_PIN3 );  /*make it low because we are ready to receive data*/





return lsReturnValue;
}