+/*\r
+ FreeRTOS V7.6.0 - Copyright (C) 2013 Real Time Engineers Ltd.\r
+ All rights reserved\r
+\r
+ VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
+\r
+ ***************************************************************************\r
+ * *\r
+ * FreeRTOS provides completely free yet professionally developed, *\r
+ * robust, strictly quality controlled, supported, and cross *\r
+ * platform software that has become a de facto standard. *\r
+ * *\r
+ * Help yourself get started quickly and support the FreeRTOS *\r
+ * project by purchasing a FreeRTOS tutorial book, reference *\r
+ * manual, or both from: http://www.FreeRTOS.org/Documentation *\r
+ * *\r
+ * Thank you! *\r
+ * *\r
+ ***************************************************************************\r
+\r
+ This file is part of the FreeRTOS distribution.\r
+\r
+ FreeRTOS is free software; you can redistribute it and/or modify it under\r
+ the terms of the GNU General Public License (version 2) as published by the\r
+ Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.\r
+\r
+ >>! NOTE: The modification to the GPL is included to allow you to distribute\r
+ >>! a combined work that includes FreeRTOS without being obliged to provide\r
+ >>! the source code for proprietary components outside of the FreeRTOS\r
+ >>! kernel.\r
+\r
+ FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
+ FOR A PARTICULAR PURPOSE. Full license text is available from the following\r
+ link: http://www.freertos.org/a00114.html\r
+\r
+ 1 tab == 4 spaces!\r
+\r
+ ***************************************************************************\r
+ * *\r
+ * Having a problem? Start by reading the FAQ "My application does *\r
+ * not run, what could be wrong?" *\r
+ * *\r
+ * http://www.FreeRTOS.org/FAQHelp.html *\r
+ * *\r
+ ***************************************************************************\r
+\r
+ http://www.FreeRTOS.org - Documentation, books, training, latest versions,\r
+ license and Real Time Engineers Ltd. contact details.\r
+\r
+ http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
+ including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
+ compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
+\r
+ http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High\r
+ Integrity Systems to sell under the OpenRTOS brand. Low cost OpenRTOS\r
+ licenses offer ticketed support, indemnification and middleware.\r
+\r
+ http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
+ engineered and independently SIL3 certified version for use in safety and\r
+ mission critical applications that require provable dependability.\r
+\r
+ 1 tab == 4 spaces!\r
+*/\r
+\r
+/*\r
+ FreeRTOS V7.6.0 - Copyright (C) 2013 Real Time Engineers Ltd.\r
+ All rights reserved\r
+\r
+ VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
+\r
+ ***************************************************************************\r
+ * *\r
+ * FreeRTOS provides completely free yet professionally developed, *\r
+ * robust, strictly quality controlled, supported, and cross *\r
+ * platform software that has become a de facto standard. *\r
+ * *\r
+ * Help yourself get started quickly and support the FreeRTOS *\r
+ * project by purchasing a FreeRTOS tutorial book, reference *\r
+ * manual, or both from: http://www.FreeRTOS.org/Documentation *\r
+ * *\r
+ * Thank you! *\r
+ * *\r
+ ***************************************************************************\r
+\r
+ This file is part of the FreeRTOS distribution.\r
+\r
+ FreeRTOS is free software; you can redistribute it and/or modify it under\r
+ the terms of the GNU General Public License (version 2) as published by the\r
+ Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.\r
+\r
+ >>! NOTE: The modification to the GPL is included to allow you to distribute\r
+ >>! a combined work that includes FreeRTOS without being obliged to provide\r
+ >>! the source code for proprietary components outside of the FreeRTOS\r
+ >>! kernel.\r
+\r
+ FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
+ FOR A PARTICULAR PURPOSE. Full license text is available from the following\r
+ link: http://www.freertos.org/a00114.html\r
+\r
+ 1 tab == 4 spaces!\r
+\r
+ ***************************************************************************\r
+ * *\r
+ * Having a problem? Start by reading the FAQ "My application does *\r
+ * not run, what could be wrong?" *\r
+ * *\r
+ * http://www.FreeRTOS.org/FAQHelp.html *\r
+ * *\r
+ ***************************************************************************\r
+\r
+ http://www.FreeRTOS.org - Documentation, books, training, latest versions,\r
+ license and Real Time Engineers Ltd. contact details.\r
+\r
+ http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
+ including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
+ compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
+\r
+ http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High\r
+ Integrity Systems to sell under the OpenRTOS brand. Low cost OpenRTOS\r
+ licenses offer ticketed support, indemnification and middleware.\r
+\r
+ http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
+ engineered and independently SIL3 certified version for use in safety and\r
+ mission critical applications that require provable dependability.\r
+\r
+ 1 tab == 4 spaces!\r
+*/\r
+\r
+/* Kernel includes. */\r
+#include "FreeRTOS.h"\r
+#include "task.h"\r
+#include "queue.h"\r
+\r
+/* ST library functions. */\r
+#include "stm32l1xx.h"\r
+#include "discover_board.h"\r
+#include "discover_functions.h"\r
+\r
+/* Priorities at which the Rx and Tx tasks are created. */\r
+#define configQUEUE_RECEIVE_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )\r
+#define configQUEUE_SEND_TASK_PRIORITY ( tskIDLE_PRIORITY + 2 )\r
+\r
+/* The number of items the queue can hold. This is 1 as the Rx task will\r
+remove items as they are added so the Tx task should always find the queue\r
+empty. */\r
+#define mainQUEUE_LENGTH ( 1 )\r
+\r
+/* The LED used to indicate that a value has been received on the queue. */\r
+#define mainQUEUE_LED ( 0 )\r
+\r
+/* The rate at which the Tx task sends to the queue. */\r
+#define mainTX_DELAY ( 500UL / portTICK_RATE_MS )\r
+\r
+/* A block time of zero simply means "don't block". */\r
+#define mainDONT_BLOCK ( 0 )\r
+\r
+/* The value that is sent from the Tx task to the Rx task on the queue. */\r
+#define mainQUEUED_VALUE ( 100UL )\r
+\r
+/* The length of time the LED will remain on for. It is on just long enough\r
+to be able to see with the human eye so as not to distort the power readings too\r
+much. */\r
+#define mainLED_TOGGLE_DELAY ( 20 / portTICK_RATE_MS )\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+/*\r
+ * The Rx and Tx tasks as described at the top of this file.\r
+ */\r
+static void prvQueueReceiveTask( void *pvParameters );\r
+static void prvQueueSendTask( void *pvParameters );\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+/* The queue to pass data from the Tx task to the Rx task. */\r
+static xQueueHandle xQueue = NULL;\r
+\r
+/*\r
+ * Set up the hardware ready to run this demo.\r
+ */\r
+static void prvSetupHardware( void );\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+int main( void )\r
+{\r
+ prvSetupHardware();\r
+\r
+ /* Create the queue. */\r
+ xQueue = xQueueCreate( mainQUEUE_LENGTH, sizeof( unsigned long ) );\r
+ configASSERT( xQueue );\r
+\r
+ /* Start the two tasks as described at the top of this file. */\r
+ xTaskCreate( prvQueueReceiveTask, ( const signed char * const ) "Rx", configMINIMAL_STACK_SIZE, NULL, configQUEUE_RECEIVE_TASK_PRIORITY, NULL );\r
+ xTaskCreate( prvQueueSendTask, ( const signed char * const ) "TX", configMINIMAL_STACK_SIZE, NULL, configQUEUE_SEND_TASK_PRIORITY, NULL );\r
+\r
+ /* Start the scheduler running running. */\r
+ vTaskStartScheduler();\r
+\r
+ /* If all is well the next line of code will not be reached as the\r
+ scheduler will be running. If the next line is reached then it is likely\r
+ there was insufficient FreeRTOS heap available for the idle task and/or\r
+ timer task to be created. See http://www.freertos.org/a00111.html. */\r
+ for( ;; );\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvQueueSendTask( void *pvParameters )\r
+{\r
+const unsigned long ulValueToSend = mainQUEUED_VALUE;\r
+\r
+ /* Remove compiler warning about unused parameter. */\r
+ ( void ) pvParameters;\r
+\r
+ for( ;; )\r
+ {\r
+ /* Place this task into the blocked state until it is time to run again.\r
+ The kernel will place the MCU into the Retention low power sleep state\r
+ when the idle task next runs. */\r
+ vTaskDelay( mainTX_DELAY );\r
+\r
+ /* Send to the queue - causing the queue receive task to flash its LED.\r
+ It should not be necessary to block on the queue send because the Rx\r
+ task will already have removed the last queued item. */\r
+ xQueueSend( xQueue, &ulValueToSend, mainDONT_BLOCK );\r
+ }\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvQueueReceiveTask( void *pvParameters )\r
+{\r
+unsigned long ulReceivedValue;\r
+\r
+ /* Remove compiler warning about unused parameter. */\r
+ ( void ) pvParameters;\r
+\r
+ for( ;; )\r
+ {\r
+ /* Wait until something arrives in the queue. */\r
+ xQueueReceive( xQueue, &ulReceivedValue, portMAX_DELAY );\r
+\r
+ /* To get here something must have arrived, but is it the expected\r
+ value? If it is, turn the LED on for a short while. */\r
+ if( ulReceivedValue == mainQUEUED_VALUE )\r
+ {\r
+ GPIO_HIGH( LD_GPIO_PORT, LD_GREEN_GPIO_PIN );\r
+ vTaskDelay( mainLED_TOGGLE_DELAY );\r
+ GPIO_LOW( LD_GPIO_PORT, LD_GREEN_GPIO_PIN );\r
+ }\r
+ }\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvSetupHardware( void )\r
+{\r
+/* GPIO, EXTI and NVIC Init structure declaration */\r
+GPIO_InitTypeDef GPIO_InitStructure;\r
+EXTI_InitTypeDef EXTI_InitStructure;\r
+NVIC_InitTypeDef NVIC_InitStructure;\r
+void SystemCoreClockUpdate( void );\r
+\r
+ SystemCoreClockUpdate();\r
+\r
+ /* Essential on STM32 Cortex-M devices. */\r
+ NVIC_PriorityGroupConfig( NVIC_PriorityGroup_4 );\r
+\r
+ /* Enable HSI Clock */\r
+ RCC_HSICmd(ENABLE);\r
+\r
+ /*!< Wait till HSI is ready */\r
+ while( RCC_GetFlagStatus( RCC_FLAG_HSIRDY ) == RESET );\r
+\r
+ /* Set HSI as sys clock*/\r
+ RCC_SYSCLKConfig( RCC_SYSCLKSource_HSI );\r
+\r
+ /* Set MSI clock range to ~4.194MHz*/\r
+ RCC_MSIRangeConfig( RCC_MSIRange_6 );\r
+\r
+ /* Enable the GPIOs clocks */\r
+ RCC_AHBPeriphClockCmd( RCC_AHBPeriph_GPIOA | RCC_AHBPeriph_GPIOB | RCC_AHBPeriph_GPIOC| RCC_AHBPeriph_GPIOD| RCC_AHBPeriph_GPIOE| RCC_AHBPeriph_GPIOH, ENABLE );\r
+\r
+ /* Enable comparator, PWR mngt clocks */\r
+ RCC_APB1PeriphClockCmd( RCC_APB1Periph_COMP | RCC_APB1Periph_PWR,ENABLE );\r
+\r
+ /* Enable ADC & SYSCFG clocks */\r
+ RCC_APB2PeriphClockCmd( RCC_APB2Periph_SYSCFG , ENABLE );\r
+\r
+ /* Allow access to the RTC */\r
+ PWR_RTCAccessCmd( ENABLE );\r
+\r
+ /* Reset RTC Backup Domain */\r
+ RCC_RTCResetCmd( ENABLE );\r
+ RCC_RTCResetCmd( DISABLE );\r
+\r
+ /* LSE Enable */\r
+ RCC_LSEConfig( RCC_LSE_ON );\r
+\r
+ /* Wait until LSE is ready */\r
+ while( RCC_GetFlagStatus( RCC_FLAG_LSERDY ) == RESET );\r
+\r
+ /* RTC Clock Source Selection */\r
+ RCC_RTCCLKConfig( RCC_RTCCLKSource_LSE );\r
+\r
+ /* Enable the RTC */\r
+ RCC_RTCCLKCmd( ENABLE );\r
+\r
+ /* Disable HSE */\r
+ RCC_HSEConfig( RCC_HSE_OFF );\r
+\r
+ if( RCC_GetFlagStatus( RCC_FLAG_HSERDY ) != RESET )\r
+ {\r
+ /* Stay in infinite loop if HSE is not disabled*/\r
+ while( 1 );\r
+ }\r
+\r
+ /* Set internal voltage regulator to 1.8V */\r
+ PWR_VoltageScalingConfig( PWR_VoltageScaling_Range1 );\r
+\r
+ /* Wait Until the Voltage Regulator is ready */\r
+ while( PWR_GetFlagStatus( PWR_FLAG_VOS ) != RESET );\r
+\r
+ /* Configure User Button pin as input */\r
+ GPIO_InitStructure.GPIO_Pin = USERBUTTON_GPIO_PIN;\r
+ GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;\r
+ GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;\r
+ GPIO_InitStructure.GPIO_Speed = GPIO_Speed_40MHz;\r
+ GPIO_Init( USERBUTTON_GPIO_PORT, &GPIO_InitStructure );\r
+\r
+ /* Select User Button pin as input source for EXTI Line */\r
+ SYSCFG_EXTILineConfig( EXTI_PortSourceGPIOA,EXTI_PinSource0 );\r
+\r
+ /* Configure EXT1 Line 0 in interrupt mode trigged on Rising edge */\r
+ EXTI_InitStructure.EXTI_Line = EXTI_Line0 ; /* PA0 for User button AND IDD_WakeUP */\r
+ EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;\r
+ EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;\r
+ EXTI_InitStructure.EXTI_LineCmd = ENABLE;\r
+ EXTI_Init( &EXTI_InitStructure );\r
+\r
+ /* Enable and set EXTI0 Interrupt to the lowest priority */\r
+ NVIC_InitStructure.NVIC_IRQChannel = EXTI0_IRQn;\r
+ NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = configLIBRARY_LOWEST_INTERRUPT_PRIORITY;\r
+ NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;\r
+ NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;\r
+ NVIC_Init( &NVIC_InitStructure );\r
+\r
+ /* Configure the LED_pin as output push-pull for LD3 & LD4 usage */\r
+ GPIO_InitStructure.GPIO_Pin = LD_GREEN_GPIO_PIN | LD_BLUE_GPIO_PIN;\r
+ GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;\r
+ GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;\r
+ GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;\r
+ GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;\r
+ GPIO_Init( LD_GPIO_PORT, &GPIO_InitStructure );\r
+\r
+ /* Force a low level on LEDs */\r
+ GPIO_LOW( LD_GPIO_PORT, LD_GREEN_GPIO_PIN );\r
+ GPIO_LOW( LD_GPIO_PORT, LD_BLUE_GPIO_PIN );\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void vApplicationMallocFailedHook( void )\r
+{\r
+ /* vApplicationMallocFailedHook() will only be called if\r
+ configUSE_MALLOC_FAILED_HOOK is set to 1 in FreeRTOSConfig.h. It is a hook\r
+ function that will get called if a call to pvPortMalloc() fails.\r
+ pvPortMalloc() is called internally by the kernel whenever a task, queue,\r
+ timer or semaphore is created. It is also called by various parts of the\r
+ demo application. If heap_1.c or heap_2.c are used, then the size of the\r
+ heap available to pvPortMalloc() is defined by configTOTAL_HEAP_SIZE in\r
+ FreeRTOSConfig.h, and the xPortGetFreeHeapSize() API function can be used\r
+ to query the size of free heap space that remains (although it does not\r
+ provide information on how the remaining heap might be fragmented). */\r
+ taskDISABLE_INTERRUPTS();\r
+ for( ;; );\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void vApplicationIdleHook( void )\r
+{\r
+ /* vApplicationIdleHook() will only be called if configUSE_IDLE_HOOK is set\r
+ to 1 in FreeRTOSConfig.h. It will be called on each iteration of the idle\r
+ task. It is essential that code added to this hook function never attempts\r
+ to block in any way (for example, call xQueueReceive() with a block time\r
+ specified, or call vTaskDelay()). If the application makes use of the\r
+ vTaskDelete() API function (as this demo application does) then it is also\r
+ important that vApplicationIdleHook() is permitted to return to its calling\r
+ function, because it is the responsibility of the idle task to clean up\r
+ memory allocated by the kernel to any task that has since been deleted. */\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void vApplicationStackOverflowHook( xTaskHandle pxTask, signed char *pcTaskName )\r
+{\r
+ ( void ) pcTaskName;\r
+ ( void ) pxTask;\r
+\r
+ /* Run time stack overflow checking is performed if\r
+ configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook\r
+ function is called if a stack overflow is detected. */\r
+ taskDISABLE_INTERRUPTS();\r
+ for( ;; );\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void vApplicationTickHook( void )\r
+{\r
+ /* This function will be called by each tick interrupt if\r
+ configUSE_TICK_HOOK is set to 1 in FreeRTOSConfig.h. User code can be\r
+ added here, but the tick hook is called from an interrupt context, so\r
+ code must not attempt to block, and only the interrupt safe FreeRTOS API\r
+ functions can be used (those that end in FromISR()). */\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void vAssertCalled( void )\r
+{\r
+volatile unsigned long ul = 0;\r
+\r
+ taskENTER_CRITICAL();\r
+ {\r
+ /* Set ul to a non-zero value using the debugger to step out of this\r
+ function. */\r
+ while( ul == 0 )\r
+ {\r
+ __asm volatile( "NOP" );\r
+ }\r
+ }\r
+ taskEXIT_CRITICAL();\r
+}\r
+\r
+\r
+#if 0\r
/**\r
******************************************************************************\r
* @file main.c\r
*\r
* <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>\r
*/\r
- \r
+\r
/* Includes ------------------------------------------------------------------*/\r
\r
#include "main.h"\r
extern bool self_test; /* Auto_test activation flag: set by interrupt handler if user button is pressed for a few seconds */\r
extern bool Idd_WakeUP; /* */\r
extern volatile bool KeyPressed; /* */\r
-extern bool UserButton; /* Set by interrupt handler to indicate that user button is pressed */ \r
+extern bool UserButton; /* Set by interrupt handler to indicate that user button is pressed */\r
uint8_t state_machine; /* Machine status used by main() wich indicats the active function, set by user button in interrupt handler */\r
uint16_t Int_CurrentSTBY; /* */\r
\r
* @par Required preconditions: None\r
*/\r
int main(void)\r
-{ \r
+{\r
bool StanbyWakeUp ;\r
float Current_STBY;\r
__IO uint32_t BOROptionBytes = 0;\r
- \r
- /*!< At this stage the microcontroller clock setting is already configured, \r
+\r
+ /*!< At this stage the microcontroller clock setting is already configured,\r
this is done through SystemInit() function which is called from startup\r
file (startup_stm32l1xx_md.s) before to branch to application main.\r
To reconfigure the default setting of SystemInit() function, refer to\r
system_stm32l1xx.c file\r
- */ \r
- \r
+ */\r
+\r
/* store Standby Current*/\r
Int_CurrentSTBY = Current_Measurement();\r
- \r
+\r
/* Check if the StandBy flag is set */\r
if (PWR_GetFlagStatus(PWR_FLAG_SB) != RESET)\r
{\r
/* System resumed from STANDBY mode */\r
/* Clear StandBy flag */\r
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR,ENABLE);\r
- PWR_ClearFlag(PWR_FLAG_SB); \r
+ PWR_ClearFlag(PWR_FLAG_SB);\r
/* set StandbyWakeup indicator*/\r
StanbyWakeUp = TRUE;\r
} else\r
{\r
/* Reset StandbyWakeup indicator*/\r
- StanbyWakeUp = FALSE; \r
- } \r
+ StanbyWakeUp = FALSE;\r
+ }\r
\r
#ifdef BOR_MODIFY\r
/* Get BOR Option Bytes */\r
BOROptionBytes = FLASH_OB_GetBOR();\r
\r
- if((BOROptionBytes & 0x0F) != BOR_LEVEL) \r
+ if((BOROptionBytes & 0x0F) != BOR_LEVEL)\r
{\r
/* Unlocks the option bytes block access */\r
FLASH_OB_Unlock();\r
| FLASH_FLAG_SIZERR | FLASH_FLAG_OPTVERR);\r
\r
/* Select the desired V(BOR) Level ---------------------------------------*/\r
- FLASH_OB_BORConfig(BOR_LEVEL); \r
+ FLASH_OB_BORConfig(BOR_LEVEL);\r
\r
/* Launch the option byte loading */\r
- FLASH_OB_Launch(); \r
+ FLASH_OB_Launch();\r
}\r
-#endif \r
- \r
+#endif\r
+\r
/* Configure Clocks for Application need */\r
RCC_Configuration();\r
- \r
+\r
/* Set internal voltage regulator to 1.8V */\r
PWR_VoltageScalingConfig(PWR_VoltageScaling_Range1);\r
- \r
+\r
/* Wait Until the Voltage Regulator is ready */\r
while (PWR_GetFlagStatus(PWR_FLAG_VOS) != RESET) ;\r
- \r
+\r
/* Init I/O ports */\r
Init_GPIOs();\r
- \r
+\r
/* Initializes ADC */\r
ADC_Icc_Init();\r
- \r
+\r
/* Enable General interrupts */\r
- enableGlobalInterrupts(); \r
- \r
- /* Init Touch Sensing configuration */ \r
+ enableGlobalInterrupts();\r
+\r
+ /* Init Touch Sensing configuration */\r
TSL_user_Init();\r
\r
/* Initializes the LCD glass */\r
LCD_GLASS_Init();\r
- \r
+\r
/* Reset Keypressed flag used in interrupt and Scrollsentence */\r
KeyPressed = FALSE;\r
\r
- /* user button actif */ \r
+ /* user button actif */\r
UserButton = TRUE;\r
- \r
- /* Check if User button press at Power ON */ \r
+\r
+ /* Check if User button press at Power ON */\r
if ((USERBUTTON_GPIO_PORT->IDR & USERBUTTON_GPIO_PIN) != 0x0)\r
{\r
/* Measure operational amplifier bias current and store value in E²Prom for application need*/\r
\r
/* Standard application startup */\r
if ( !StanbyWakeUp )\r
- { \r
+ {\r
/* Reset autotest flag stored in memory */\r
AUTOTEST(FALSE) ;\r
\r
- /* Display Welcome message */ \r
+ /* Display Welcome message */\r
LCD_GLASS_ScrollSentence(message,1,SCROLL_SPEED);\r
if (!KeyPressed)\r
{\r
TEMPO;\r
TEMPO;\r
TEMPO;\r
- LCD_BlinkConfig(LCD_BlinkMode_Off,LCD_BlinkFrequency_Div32); \r
+ LCD_BlinkConfig(LCD_BlinkMode_Off,LCD_BlinkFrequency_Div32);\r
}\r
/* Wake up from Standby or autotest */\r
} else {\r
if (self_test)\r
{\r
/* Wake UP: Return of RESET by Auto test */\r
- auto_test_part2(); \r
+ auto_test_part2();\r
} else {\r
/* Wake UP: Return of RESET by Current STAND BY measurement */\r
LCD_GLASS_ScrollSentence(" STANDBY WAKEUP",1,SCROLL_SPEED);\r
/* Substract bias current from operational amplifier*/\r
if ( Int_CurrentSTBY > Bias_Current )\r
Int_CurrentSTBY -= Bias_Current;\r
- Current_STBY = Int_CurrentSTBY * Vdd_appli()/ADC_CONV; \r
+ Current_STBY = Int_CurrentSTBY * Vdd_appli()/ADC_CONV;\r
Current_STBY *= 20L;\r
display_MuAmp((uint32_t)Current_STBY);\r
/* Wait for user button press to continue */\r
}\r
}\r
/* Reset KeyPress Flag */\r
- KeyPressed = FALSE; \r
+ KeyPressed = FALSE;\r
/* Clear LCD bars */\r
BAR0_OFF;\r
BAR1_OFF;\r
BAR2_OFF;\r
- BAR3_OFF; \r
+ BAR3_OFF;\r
/* Switch off the leds*/\r
- GPIO_HIGH(LD_GPIO_PORT,LD_GREEN_GPIO_PIN); \r
- GPIO_LOW(LD_GPIO_PORT,LD_BLUE_GPIO_PIN); \r
+ GPIO_HIGH(LD_GPIO_PORT,LD_GREEN_GPIO_PIN);\r
+ GPIO_LOW(LD_GPIO_PORT,LD_BLUE_GPIO_PIN);\r
/* Set application state machine to VREF state */\r
state_machine = STATE_VREF ;\r
/*Until application reset*/\r
Vref_measure();\r
TEMPO ;\r
break;\r
- \r
+\r
/* Slider Value State : Display the TS slider value */\r
case STATE_SLIDER_VALUE:\r
\r
ProcessSensors(); // Execute sensors related tasks\r
}\r
break;\r
- \r
+\r
/* Slider button State : Display the curent TS button pressed */\r
- case STATE_SLIDER_BUTTON: \r
+ case STATE_SLIDER_BUTTON:\r
// Execute STMTouch Driver state machine\r
if (TSL_user_Action() == TSL_STATUS_OK)\r
{\r
ProcessSensorsButtons(); // Execute sensors related tasks\r
- } \r
+ }\r
break;\r
- \r
+\r
/* ICC RUN State : ICC mesurements in Run and Sleep modes */\r
case STATE_ICC_RUN:\r
LCD_GLASS_DisplayString(" RUN ");\r
TEMPO;\r
LCD_GLASS_DisplayString(" SLEEP ");\r
TEMPO;\r
- Icc_SLEEP(); \r
+ Icc_SLEEP();\r
TEMPO;\r
TEMPO;\r
TEMPO;\r
TEMPO;\r
break;\r
- \r
+\r
/* ICC LOW POWER RUN State : ICC mesurements in LowPower run and LowPower Sleep modes */\r
case STATE_ICC_LP_RUN:\r
LCD_GLASS_DisplayString("LP RUN");\r
TEMPO;\r
TEMPO;\r
TEMPO;\r
- TEMPO; \r
+ TEMPO;\r
break;\r
- \r
+\r
/* ICC STOP State : ICC mesurements in Stop and STOP NoRTC modes */\r
case STATE_ICC_STOP:\r
LCD_GLASS_DisplayString(" STOP ");\r
TEMPO;\r
TEMPO;\r
TEMPO;\r
- TEMPO; \r
+ TEMPO;\r
LCD_GLASS_DisplayString("SP-NRTC");\r
TEMPO;\r
Icc_Stop_NoRTC();\r
TEMPO;\r
TEMPO;\r
TEMPO;\r
- TEMPO; \r
+ TEMPO;\r
break;\r
- \r
+\r
/* ICC Standby State : ICC mesurements in Standby mode */\r
case STATE_ICC_STBY:\r
LCD_GLASS_DisplayString("STBY ");\r
TEMPO;\r
- TEMPO; \r
+ TEMPO;\r
ADC_Icc_Test(MCU_STBY);\r
- /* Following break never performed dues to software reset in previous function */ \r
+ /* Following break never performed dues to software reset in previous function */\r
break;\r
- \r
- /* for safe: normaly never reaches */ \r
+\r
+ /* for safe: normaly never reaches */\r
default:\r
LCD_GLASS_Clear();\r
LCD_GLASS_DisplayString("ERROR");\r
/* Reset KeyPress flag*/\r
KeyPressed = FALSE;\r
}\r
-} \r
+}\r
\r
/**\r
* @brief Configures the different system clocks.\r
* @retval None\r
*/\r
void RCC_Configuration(void)\r
-{ \r
+{\r
/* Enable HSI Clock */\r
RCC_HSICmd(ENABLE);\r
- \r
+\r
/*!< Wait till HSI is ready */\r
while (RCC_GetFlagStatus(RCC_FLAG_HSIRDY) == RESET);\r
\r
/* Set HSI as sys clock*/\r
RCC_SYSCLKConfig(RCC_SYSCLKSource_HSI);\r
- \r
+\r
/* Set MSI clock range to ~4.194MHz*/\r
RCC_MSIRangeConfig(RCC_MSIRange_6);\r
- \r
+\r
/* Enable the GPIOs clocks */\r
- RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA | RCC_AHBPeriph_GPIOB | RCC_AHBPeriph_GPIOC| RCC_AHBPeriph_GPIOD| RCC_AHBPeriph_GPIOE| RCC_AHBPeriph_GPIOH, ENABLE); \r
+ RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA | RCC_AHBPeriph_GPIOB | RCC_AHBPeriph_GPIOC| RCC_AHBPeriph_GPIOD| RCC_AHBPeriph_GPIOE| RCC_AHBPeriph_GPIOH, ENABLE);\r
\r
/* Enable comparator, LCD and PWR mngt clocks */\r
RCC_APB1PeriphClockCmd(RCC_APB1Periph_COMP | RCC_APB1Periph_LCD | RCC_APB1Periph_PWR,ENABLE);\r
- \r
+\r
/* Enable ADC & SYSCFG clocks */\r
RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1 | RCC_APB2Periph_SYSCFG , ENABLE);\r
\r
\r
/* Wait until LSE is ready */\r
while (RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET);\r
- \r
- /* RTC Clock Source Selection */ \r
- RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE); \r
- \r
+\r
+ /* RTC Clock Source Selection */\r
+ RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE);\r
+\r
/* Enable the RTC */\r
- RCC_RTCCLKCmd(ENABLE); \r
- \r
+ RCC_RTCCLKCmd(ENABLE);\r
+\r
/*Disable HSE*/\r
RCC_HSEConfig(RCC_HSE_OFF);\r
if(RCC_GetFlagStatus(RCC_FLAG_HSERDY) != RESET )\r
{\r
/* Stay in infinite loop if HSE is not disabled*/\r
- while(1); \r
+ while(1);\r
}\r
}\r
\r
GPIO_InitTypeDef GPIO_InitStructure;\r
EXTI_InitTypeDef EXTI_InitStructure;\r
NVIC_InitTypeDef NVIC_InitStructure;\r
- \r
+\r
/* Configure User Button pin as input */\r
GPIO_InitStructure.GPIO_Pin = USERBUTTON_GPIO_PIN;\r
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;\r
/* Configure EXT1 Line 0 in interrupt mode trigged on Rising edge */\r
EXTI_InitStructure.EXTI_Line = EXTI_Line0 ; // PA0 for User button AND IDD_WakeUP\r
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;\r
- EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising; \r
+ EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;\r
EXTI_InitStructure.EXTI_LineCmd = ENABLE;\r
EXTI_Init(&EXTI_InitStructure);\r
\r
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x0F;\r
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x0F;\r
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;\r
- NVIC_Init(&NVIC_InitStructure); \r
+ NVIC_Init(&NVIC_InitStructure);\r
\r
/* Configure the LED_pin as output push-pull for LD3 & LD4 usage*/\r
GPIO_InitStructure.GPIO_Pin = LD_GREEN_GPIO_PIN | LD_BLUE_GPIO_PIN;\r
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;\r
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;\r
GPIO_Init(LD_GPIO_PORT, &GPIO_InitStructure);\r
- \r
- /* Force a low level on LEDs*/ \r
- GPIO_LOW(LD_GPIO_PORT,LD_GREEN_GPIO_PIN); \r
+\r
+ /* Force a low level on LEDs*/\r
+ GPIO_LOW(LD_GPIO_PORT,LD_GREEN_GPIO_PIN);\r
GPIO_LOW(LD_GPIO_PORT,LD_BLUE_GPIO_PIN);\r
- \r
+\r
/* Counter enable: GPIO set in output for enable the counter */\r
GPIO_InitStructure.GPIO_Pin = CTN_CNTEN_GPIO_PIN;\r
GPIO_Init( CTN_GPIO_PORT, &GPIO_InitStructure);\r
- \r
+\r
/* To prepare to start counter */\r
GPIO_HIGH(CTN_GPIO_PORT,CTN_CNTEN_GPIO_PIN);\r
- \r
+\r
/* Configure Port A LCD Output pins as alternate function */\r
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_8 | GPIO_Pin_9 |GPIO_Pin_10 |GPIO_Pin_15;\r
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;\r
GPIO_Init( GPIOA, &GPIO_InitStructure);\r
- \r
+\r
/* Select LCD alternate function for Port A LCD Output pins */\r
GPIO_PinAFConfig(GPIOA, GPIO_PinSource1,GPIO_AF_LCD) ;\r
GPIO_PinAFConfig(GPIOA, GPIO_PinSource2,GPIO_AF_LCD) ;\r
GPIO_PinAFConfig(GPIOA, GPIO_PinSource8,GPIO_AF_LCD) ;\r
GPIO_PinAFConfig(GPIOA, GPIO_PinSource9,GPIO_AF_LCD) ;\r
GPIO_PinAFConfig(GPIOA, GPIO_PinSource10,GPIO_AF_LCD) ;\r
- GPIO_PinAFConfig(GPIOA, GPIO_PinSource15,GPIO_AF_LCD) ; \r
- \r
- /* Configure Port B LCD Output pins as alternate function */ \r
+ GPIO_PinAFConfig(GPIOA, GPIO_PinSource15,GPIO_AF_LCD) ;\r
+\r
+ /* Configure Port B LCD Output pins as alternate function */\r
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_8 | GPIO_Pin_9 \\r
- | GPIO_Pin_10 | GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15; \r
+ | GPIO_Pin_10 | GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15;\r
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;\r
GPIO_Init( GPIOB, &GPIO_InitStructure);\r
- \r
+\r
/* Select LCD alternate function for Port B LCD Output pins */\r
GPIO_PinAFConfig(GPIOB, GPIO_PinSource3,GPIO_AF_LCD) ;\r
GPIO_PinAFConfig(GPIOB, GPIO_PinSource4,GPIO_AF_LCD) ;\r
GPIO_PinAFConfig(GPIOB, GPIO_PinSource8,GPIO_AF_LCD) ;\r
GPIO_PinAFConfig(GPIOB, GPIO_PinSource9,GPIO_AF_LCD) ;\r
GPIO_PinAFConfig(GPIOB, GPIO_PinSource10,GPIO_AF_LCD) ;\r
- GPIO_PinAFConfig(GPIOB, GPIO_PinSource11,GPIO_AF_LCD) ; \r
+ GPIO_PinAFConfig(GPIOB, GPIO_PinSource11,GPIO_AF_LCD) ;\r
GPIO_PinAFConfig(GPIOB, GPIO_PinSource12,GPIO_AF_LCD) ;\r
- GPIO_PinAFConfig(GPIOB, GPIO_PinSource13,GPIO_AF_LCD) ; \r
+ GPIO_PinAFConfig(GPIOB, GPIO_PinSource13,GPIO_AF_LCD) ;\r
GPIO_PinAFConfig(GPIOB, GPIO_PinSource14,GPIO_AF_LCD) ;\r
- GPIO_PinAFConfig(GPIOB, GPIO_PinSource15,GPIO_AF_LCD) ; \r
- \r
- /* Configure Port C LCD Output pins as alternate function */ \r
+ GPIO_PinAFConfig(GPIOB, GPIO_PinSource15,GPIO_AF_LCD) ;\r
+\r
+ /* Configure Port C LCD Output pins as alternate function */\r
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_6 \\r
- | GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 |GPIO_Pin_11 ; \r
+ | GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 |GPIO_Pin_11 ;\r
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;\r
- GPIO_Init( GPIOC, &GPIO_InitStructure); \r
+ GPIO_Init( GPIOC, &GPIO_InitStructure);\r
\r
/* Select LCD alternate function for Port B LCD Output pins */\r
GPIO_PinAFConfig(GPIOC, GPIO_PinSource0,GPIO_AF_LCD) ;\r
- GPIO_PinAFConfig(GPIOC, GPIO_PinSource1,GPIO_AF_LCD) ; \r
+ GPIO_PinAFConfig(GPIOC, GPIO_PinSource1,GPIO_AF_LCD) ;\r
GPIO_PinAFConfig(GPIOC, GPIO_PinSource2,GPIO_AF_LCD) ;\r
GPIO_PinAFConfig(GPIOC, GPIO_PinSource3,GPIO_AF_LCD) ;\r
GPIO_PinAFConfig(GPIOC, GPIO_PinSource6,GPIO_AF_LCD) ;\r
GPIO_PinAFConfig(GPIOC, GPIO_PinSource7,GPIO_AF_LCD) ;\r
GPIO_PinAFConfig(GPIOC, GPIO_PinSource8,GPIO_AF_LCD) ;\r
GPIO_PinAFConfig(GPIOC, GPIO_PinSource9,GPIO_AF_LCD) ;\r
- GPIO_PinAFConfig(GPIOC, GPIO_PinSource10,GPIO_AF_LCD) ; \r
- GPIO_PinAFConfig(GPIOC, GPIO_PinSource11,GPIO_AF_LCD) ; \r
- \r
+ GPIO_PinAFConfig(GPIOC, GPIO_PinSource10,GPIO_AF_LCD) ;\r
+ GPIO_PinAFConfig(GPIOC, GPIO_PinSource11,GPIO_AF_LCD) ;\r
+\r
/* Configure ADC (IDD_MEASURE) pin as Analogue */\r
- GPIO_InitStructure.GPIO_Pin = IDD_MEASURE ; \r
+ GPIO_InitStructure.GPIO_Pin = IDD_MEASURE ;\r
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;\r
GPIO_Init( IDD_MEASURE_PORT, &GPIO_InitStructure);\r
-} \r
+}\r
\r
\r
/**\r
* @retval None\r
*/\r
void assert_failed(uint8_t* file, uint32_t line)\r
-{ \r
+{\r
/* User can add his own implementation to report the file name and line number,\r
ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */\r
/* Infinite loop */\r
\r
#endif\r
\r
+void vApplicationStackOverflowHook( void )\r
+{\r
+}\r
+\r
/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/\r
+\r
+#endif\r
+\r