-
Notifications
You must be signed in to change notification settings - Fork 0
/
HAL.h
54 lines (40 loc) · 1.46 KB
/
HAL.h
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
#ifndef HAL_H
# define HAL_H
# include <avr/io.h>
# include <avr/interrupt.h>
# include <avrlibtypes.h>
# include "avrlibdefs.h"
# include "avrlibtypes.h"
# include "avr/pgmspace.h"
# include <avr/wdt.h>
//System Timer Config
# define Prescaler 64
# define TIMER_TICK_MILLIS 1
# define TimerDivider ((F_CPU/Prescaler + TIMER_TICK_MILLIS*1000 / 2)/(TIMER_TICK_MILLIS*1000)) // 1 mS
//USART Config
# define BAUDRATE 9600L
# define BAUD_DIVIDER ((F_CPU + BAUDRATE * 8)/(16 * BAUDRATE)-1)
# define REAL_BAUDRATE ((F_CPU + (BAUD_DIVIDER + 1) * 8) / ((BAUD_DIVIDER + 1)*16))
# define BAUDRATE_ERROR ((100L * (BAUDRATE - REAL_BAUDRATE) + BAUDRATE/2) / (BAUDRATE))
# if BAUDRATE_ERROR < -2 || BAUDRATE_ERROR > 2
# warning "Неправильно задана константа BAUDRATE"
# endif
# define HI(x) ((x)>>8)
# define LO(x) ((x)& 0xFF)
//PORT Defines
# define BUTTONS_PORT PORTD
# define BUTTONS_DDR DDRD
# define BUTTONS_PIN PIND
# define BUTTON_PLUS PD3
# define BUTTON_MINUS PD4
# define INDICATOR_DIGITS_PORT PORTD
# define INDICATOR_DIGITS_DDR DDRD
# define INDICATOR_SEGMENTS_PORT PORTB
# define INDICATOR_SEGMENTS_DDR DDRB
// Задержки
# define DEBOUNCE_DELAY 5/TIMER_TICK_MILLIS
# define INDICATOR_DELAY 5/TIMER_TICK_MILLIS
# define KEYSCAN_DELAY 5/TIMER_TICK_MILLIS
# define HOLD_KEY_DELAY 500/TIMER_TICK_MILLIS
extern void initAll (void);
#endif /* */