]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Demo/CORTEX_M4F_MSP432_LaunchPad_IAR_CCS_Keil/SimplyBlinkyDemo/main_blinky.c
Enable button interrupts in the MSP432 demos in order to test code paths when an...
[freertos] / FreeRTOS / Demo / CORTEX_M4F_MSP432_LaunchPad_IAR_CCS_Keil / SimplyBlinkyDemo / main_blinky.c
index 267e00ff564f53faeaa38fb1e44611b4812fa737..0d817e532b48d01b598115571c31e3b822da86fa 100644 (file)
 #include "task.h"\r
 #include "semphr.h"\r
 \r
+/* TI includes. */\r
+#include "gpio.h"\r
+\r
 /* Priorities at which the tasks are created. */\r
 #define mainQUEUE_RECEIVE_TASK_PRIORITY                ( tskIDLE_PRIORITY + 2 )\r
 #define        mainQUEUE_SEND_TASK_PRIORITY            ( tskIDLE_PRIORITY + 1 )\r
@@ -159,6 +162,13 @@ void main_blinky( void );
  */\r
 static void prvConfigureClocks( void );\r
 \r
+/* \r
+ * Configure a button to generate interrupts (for test purposes).  This is done\r
+ * to test waking on an interrupt other than the systick interrupt in tickless\r
+ * idle mode.\r
+ */\r
+static void prvConfigureButton( void );\r
+\r
 /*-----------------------------------------------------------*/\r
 \r
 /* The queue used by both tasks. */\r
@@ -177,6 +187,9 @@ void main_blinky( void )
        /* The full demo configures the clocks for maximum frequency, wheras this\r
        blinky demo uses a slower clock as it also uses low power features. */\r
        prvConfigureClocks();\r
+       \r
+       /* Configure a button to generate interrupts (for test purposes). */\r
+       prvConfigureButton();\r
 \r
        /* Create the queue. */\r
        xQueue = xQueueCreate( mainQUEUE_LENGTH, sizeof( uint32_t ) );\r
@@ -286,9 +299,37 @@ static void prvConfigureClocks( void )
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-void vPreSleepProcessing( uint32_t ulExpectedIdleTime )\r
+static void prvConfigureButton( void )\r
+{\r
+volatile uint8_t ucPin;\r
+\r
+       /* Configure button S1 to generate interrupts.  This is done to test the\r
+       code path were low power mode is exited for a reason other than a tick\r
+       interrupt. */\r
+       GPIO_setAsInputPinWithPullUpResistor( GPIO_PORT_P1, GPIO_PIN1 );\r
+       GPIO_enableInterrupt( GPIO_PORT_P1, GPIO_PIN1 );\r
+       Interrupt_enableInterrupt( INT_PORT1 );\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void PORT1_IRQHandler( void )\r
 {\r
+static volatile uint32_t ux = 0;\r
+       \r
+       /* This is the handler for interrupt generated by the button.  The \r
+       interrupt is only used to bring the MCU out of low power mode.  It\r
+       doesn't perform any other function.  The ux increment is just to\r
+       have something to set breakpoints on and check the interrupt is\r
+       executing. */\r
+       ux++;\r
+       \r
+       /* Clear the interrupt. */\r
+       ( void ) P1->IV;\r
+}\r
+/*-----------------------------------------------------------*/\r
 \r
+void vPreSleepProcessing( uint32_t ulExpectedIdleTime )\r
+{\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r