Welcome to mirror list, hosted at ThFree Co, Russian Federation.

ibutton.h - github.com/ClusterM/ibutton.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e0783041e18149897b25fda4e27bc967115d4c0d (plain)
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
#include "defines.h"

#define GLUE(a,b) a##b
#define DDR(p) GLUE(DDR,p)
#define PORT(p) GLUE(PORT,p)
#define PIN(p) GLUE(PIN,p)

#define LED1_DDR DDR(LED_TOP_PORT)
#define LED2_DDR DDR(LED_TOP_RIGHT_PORT)
#define LED3_DDR DDR(LED_BOTTOM_RIGHT_PORT)
#define LED4_DDR DDR(LED_BOTTOM_PORT)
#define LED5_DDR DDR(LED_BOTTOM_LEFT_PORT)
#define LED6_DDR DDR(LED_TOP_LEFT_PORT)
#define LED7_DDR DDR(LED_CENTER_PORT)
#define LED1_PORT PORT(LED_TOP_PORT)
#define LED2_PORT PORT(LED_TOP_RIGHT_PORT)
#define LED3_PORT PORT(LED_BOTTOM_RIGHT_PORT)
#define LED4_PORT PORT(LED_BOTTOM_PORT)
#define LED5_PORT PORT(LED_BOTTOM_LEFT_PORT)
#define LED6_PORT PORT(LED_TOP_LEFT_PORT)
#define LED7_PORT PORT(LED_CENTER_PORT)
#define LED1_PIN LED_TOP_PIN
#define LED2_PIN LED_TOP_RIGHT_PIN
#define LED3_PIN LED_BOTTOM_RIGHT_PIN
#define LED4_PIN LED_BOTTOM_PIN
#define LED5_PIN LED_BOTTOM_LEFT_PIN
#define LED6_PIN LED_TOP_LEFT_PIN
#define LED7_PIN LED_CENTER_PIN

#define BUTTON_DDR DDR(BUTTON_PORT)
#define BUTTON_OUT PORT(BUTTON_PORT)
#define BUTTON_IN PIN(BUTTON_PORT)
#define USB_DETECT_DDR DDR(USB_DETECT_PORT)
#define USB_DETECT_OUT PORT(USB_DETECT_PORT)
#define USB_DETECT_IN PIN(USB_DETECT_PORT)

#define LINE_ENABLE_DDR DDR(LINE_ENABLE_PORT)
#define LINE_ENABLE_OUT PORT(LINE_ENABLE_PORT)
#define LINE_ENABLE_IN PIN(LINE_ENABLE_PORT)

#define CYFRAL_PULLUP_DDR DDR(CYFRAL_PULLUP_PORT)
#define CYFRAL_PULLUP_OUT PORT(CYFRAL_PULLUP_PORT)
#define CYFRAL_PULLUP_IN PIN(CYFRAL_PULLUP_PORT)

#define CYFRAL_REFERENCE_DDR DDR(CYFRAL_REFERENCE_PORT)
#define CYFRAL_REFERENCE_OUT PORT(CYFRAL_REFERENCE_PORT)
#define CYFRAL_REFERENCE_IN PIN(CYFRAL_REFERENCE_PORT)

#define LINE_ENABLE set_bit(LINE_ENABLE_OUT, LINE_ENABLE_PIN)
#define LINE_DISABLE unset_bit(LINE_ENABLE_OUT, LINE_ENABLE_PIN)
#define CYFRAL_PULLUP_ENABLE { set_bit(CYFRAL_PULLUP_OUT, CYFRAL_PULLUP_PIN); set_bit(CYFRAL_PULLUP_DDR, CYFRAL_PULLUP_PIN); }
#define CYFRAL_PULLUP_DISABLE { unset_bit(CYFRAL_PULLUP_DDR, CYFRAL_PULLUP_PIN); unset_bit(CYFRAL_PULLUP_OUT, CYFRAL_PULLUP_PIN); }
#define CYFRAL_REFERENCE_ENABLE set_bit(CYFRAL_REFERENCE_OUT, CYFRAL_REFERENCE_PIN)
#define CYFRAL_REFERENCE_DISABLE unset_bit(CYFRAL_REFERENCE_OUT, CYFRAL_REFERENCE_PIN)

#define BUTTON_PRESSED !(BUTTON_IN & (1<<BUTTON_PIN))
#define USB_POWERED !(USB_DETECT_IN & (1<<USB_DETECT_PIN))

void set_leds(unsigned char leds_mask);
void update_leds(void);
void speedup_leds(void);