Files
@ dc0c251991cc
Branch filter:
Location: therm/main.c - annotation
dc0c251991cc
4.5 KiB
text/plain
Added CMSIS and periph libraries to make a self-contained project
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 | 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 970a161634a0 | /**
******************************************************************************
* @file main.c
* @author MCD Application Team
* @version V1.0.0
* @date 29-July-2013
* @brief Main program body
******************************************************************************
* @attention
*
* <h2><center>© COPYRIGHT 2013 STMicroelectronics</center></h2>
*
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.st.com/software_license_agreement_liberty_v2
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "main.h"
#include "stm32l100c_discovery.h"
/** @addtogroup STM32L100C-Discovery_Demo
* @{
*/
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
static __IO uint32_t TimingDelay;
uint8_t BlinkSpeed = 0;
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/
/**
* @brief Main program.
* @param None
* @retval None
*/
int main(void)
{
RCC_ClocksTypeDef RCC_Clocks;
/* Configure LED3 and LED4 on STM32L100C-Discovery */
STM_EVAL_LEDInit(LED3);
STM_EVAL_LEDInit(LED4);
/* Initialize User_Button on STM32L100C-Discovery */
STM_EVAL_PBInit(BUTTON_USER, BUTTON_MODE_GPIO);
/* SysTick end of count event each 1ms */
RCC_GetClocksFreq(&RCC_Clocks);
SysTick_Config(RCC_Clocks.HCLK_Frequency / 1000);
/* Initiate Blink Speed variable */
BlinkSpeed = 1;
while(1)
{
/* Check if the user button is pressed */
if(STM_EVAL_PBGetState(BUTTON_USER)== SET)
{
/* BlinkSpeed: 1 -> 2 -> 0, then re-cycle */
/* Turn on LD4 Blue LED during 1s each time User button is pressed */
STM_EVAL_LEDOn(LED4);
/* wait for 1s */
Delay(1000);
/* Turn off LD4 Blue LED after 1s each time User button is pressed */
STM_EVAL_LEDOff(LED4);
/* Increment the blink speed counter */
BlinkSpeed++;
/* Default value for blink speed counter */
if(BlinkSpeed == 3)
{
BlinkSpeed = 0;
}
}
/* Test on blink speed */
if(BlinkSpeed == 2)
{
/* LED3 toggles each 100 ms */
STM_EVAL_LEDToggle(LED3);
/* maintain LED3 status for 100ms */
Delay(100);
}
else if(BlinkSpeed == 1)
{
/* LED3 toggles each 200 ms */
STM_EVAL_LEDToggle(LED3);
/* maintain LED3 status for 200ms */
Delay(200);
}
else
{
/* LED3 Off */
STM_EVAL_LEDOff(LED3);
}
}
}
/**
* @brief Inserts a delay time.
* @param nTime: specifies the delay time length, in 1 ms.
* @retval None
*/
void Delay(__IO uint32_t nTime)
{
TimingDelay = nTime;
while(TimingDelay != 0);
}
/**
* @brief Decrements the TimingDelay variable.
* @param None
* @retval None
*/
void TimingDelay_Decrement(void)
{
if (TimingDelay != 0x00)
{
TimingDelay--;
}
}
#ifdef USE_FULL_ASSERT
/**
* @brief Reports the name of the source file and the source line number
* where the assert_param error has occurred.
* @param file: pointer to the source file name
* @param line: assert_param error line source number
* @retval None
*/
void assert_failed(uint8_t* file, uint32_t line)
{
/* User can add his own implementation to report the file name and line number,
ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
/* Infinite loop */
while (1)
{}
}
#endif
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|