CMSIS2000  0.0.7
 Указатель Структуры данных Файлы Функции Переменные Определения типов Перечисления Элементы перечислений Макросы Группы Страницы
led.h
См. документацию.
1 /**
2  * Copyright (c) 2012, Roy van Dam <roy@vandam-innovations.com>
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice, this
9  * list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright notice,
11  * this list of conditions and the following disclaimer in the documentation
12  * and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
18  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
23  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 
26 #ifndef _LED_H_
27 #define _LED_H_
28 
29 #include <stdbool.h>
30 
31 #include <misc.h>
32 #include <stm32f10x.h>
33 #include <stm32f10x_gpio.h>
34 #include <stm32f10x_rcc.h>
35 
36 void assert_param(bool value);
37 
38 extern void SysTick_Handler(void);
39 extern void SysTick_Delay(unsigned long ms);
40 
41 typedef enum {
42  LED0 = 0,
43  LED1 = 1
44 } LedId;
45 
46 struct LedContext {
49  GPIO_TypeDef* port;
50 };
51 
52 const struct LedContext led_context[] = {
53  { .pin = GPIO_Pin_9,
54  .port = GPIOC,
55  .clock = RCC_APB2Periph_GPIOC },
56 
57  { .pin = GPIO_Pin_8,
58  .port = GPIOC,
59  .clock = RCC_APB2Periph_GPIOC },
60 };
61 
62 extern void Led_Init(LedId led);
63 extern void Led_Enable(LedId led);
64 extern void Led_Disable(LedId led);
65 
66 #endif /* _LED_H_ */