/* * ======== main ======== */ int main(void) { /* Call board init functions */ Board_initGeneral(); Board_initGPIO(); /* Turn on user LED */ GPIO_write(Board_LED0, Board_LED_ON); System_printf("Starting the SMS Door Bell example\nSystem provider is set" " to SysMin. Halt the target to view any SysMin contents in" " ROV.\n\n"); /* SysMin will only print to the console when you call flush or exit */ System_flush(); /* Turn off All LEDs. It will be used as a connection indicator */ GPIO_write(Board_LED0, Board_LED_ON); //Red //GPIO_write(Board_LED1, Board_LED_ON); //Orange //GPIO_write(Board_LED2, Board_LED_ON); //Green /* install Button callback */ GPIO_setCallback(Board_BUTTON0, gpioButtonFxn0); /* Enable interrupts */ GPIO_enableInt(Board_BUTTON0); /* * If more than one input pin is available for your device, interrupts * will be enabled on Board_BUTTON1. */ // if (Board_BUTTON0 != Board_BUTTON1) { // /* install Button callback */ // GPIO_setCallback(Board_BUTTON1, gpioButtonFxn1); // GPIO_enableInt(Board_BUTTON1); // } /* * The SimpleLink Host Driver requires a mechanism to allow functions to * execute in temporary context. The SpawnTask is created to handle such * situations. This task will remain blocked until the host driver * posts a function. If the SpawnTask priority is higher than other tasks, * it will immediately execute the function and return to a blocked state. * Otherwise, it will remain ready until it is scheduled. */ VStartSimpleLinkSpawnTask(SPAWN_TASK_PRI); /* Start BIOS */ BIOS_start(); return (0); }
void buttonInit(void){ GPIO_setCallback(Board_BUTTON0, gpioButton0); GPIO_enableInt(Board_BUTTON0); /* Configure RGB LED pins */ GPIO_setAsOutputPin(GPIO_PORT_P2, GPIO_PIN4 | GPIO_PIN6); GPIO_setAsOutputPin(GPIO_PORT_P5, GPIO_PIN6); /* Set RGB LED to red */ P2OUT |= BIT6; P2OUT &= ~BIT4; P5OUT &= ~BIT6; /* Setup Button */ GPIO_setAsInputPinWithPullUpResistor(GPIO_PORT_P5,GPIO_PIN1); GPIO_clearInterruptFlag(GPIO_PORT_P5, GPIO_PIN1); GPIO_enableInterrupt(GPIO_PORT_P5, GPIO_PIN1); GPIO_interruptEdgeSelect(GPIO_PORT_P5, GPIO_PIN1, GPIO_HIGH_TO_LOW_TRANSITION); Interrupt_enableInterrupt(INT_PORT5); }
void HWI::begin(uint8_t pinNumber, void (*functionHWI)(void), int mode) { // Error_Block eb; // Error_init(&eb); // // Hwi_Params hwiParams; // Hwi_Params_init(&hwiParams); // // HWIHandle = Hwi_create(interruptNumber, (Hwi_FuncPtr)functionHWI, &hwiParams, &eb); // from msp432/cores/msp432/WInterrupts.c HWIpin = pinNumber; GPIO_PinConfig intType; switch (mode) { case LOW: intType = GPIO_CFG_IN_INT_LOW; break; case CHANGE: intType = GPIO_CFG_IN_INT_BOTH_EDGES; break; case RISING: intType = GPIO_CFG_IN_INT_RISING; break; case FALLING: intType = GPIO_CFG_IN_INT_FALLING; break; case HIGH: intType = GPIO_CFG_IN_INT_HIGH; break; } GPIO_setConfig(pinNumber, GPIO_CFG_IN_INT_ONLY | intType); GPIO_setCallback(pinNumber, (GPIO_CallbackFxn)functionHWI); GPIO_enableInt(pinNumber); }
//***************************************************************************** // //! Main application function. //! //! This function is meant to initialize all devices and tasks used in this //! application. After the initialization is complete, the tasks start running. //! //! \return None. // //***************************************************************************** int main(void) { // Initialize General configurations Board_initGeneral(); // Initialize GPIO Board_initGPIO(); // Turn off all LEDS GPIO_write(Board_LED0, Board_LED_OFF); GPIO_write(Board_LED1, Board_LED_OFF); GPIO_write(Board_LED2, Board_LED_OFF); // Initializes interrupts GPIO_setCallback(Board_BUTTON0, _callback_Button_Select); GPIO_setCallback(Board_BUTTON1, _callback_Button_Up); GPIO_setCallback(Board_BUTTON2, _callback_Button_Down); GPIO_setCallback(Board_SENSE_RISER_DOWN, _callback_Festo_Riser_Down); GPIO_setCallback(Board_SENSE_RISER_UP, _callback_Festo_Riser_Up); GPIO_setCallback(Board_SENSE_SAMPLE_IN_PLACE, _callback_Festo_Piece_In); // Enable Interrupts GPIO_enableInt(Board_BUTTON0); GPIO_enableInt(Board_BUTTON1); GPIO_enableInt(Board_BUTTON2); GPIO_enableInt(Board_SENSE_RISER_DOWN); GPIO_enableInt(Board_SENSE_RISER_UP); GPIO_enableInt(Board_SENSE_SAMPLE_IN_PLACE); Seconds_set(1432639800); // Start BIOS BIOS_start(); return (0); }
void HWI::clearInterrupt() { GPIO_setCallback(HWIpin, NULL); }