-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.asm
106 lines (77 loc) · 2.12 KB
/
main.asm
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
;
; ATtiny25_AS__SPI_Master_BMx280_.asm
;
; Created: 28.06.2017 10:33:57
; Author : setup
;
; Important!
; ATtiny DO -> BMx280 SDI (SDA, DI)
; ATtiny DI -> BMx280 SDO (DO)
.include "tn25def.inc"
.def dClock = R12
.def dRate = R13
.def cntHL = R14
.def cntd = R15
.def tmp = R16
.def _EREG_ = R17
.def txByte = R18
.def rxByte = R19
.def tcntL = R20
.def tcntH = R21
.def tmpL = R22
.def tmpH = R23
.def cntLL = R24
.def cntLH = R25
.equ LEDDDR = DDRB
.equ LEDPORT = PORTB
.equ LEDPIN = PINB
.equ LED0PIN = PB3
.equ SPIDDR = DDRB
.equ SPIPORT = PORTB
.equ SPIPIN = PINB
.equ DI = PB0
.equ DO = PB1
.equ SCK = PB2
.equ SS_1 = PB4 ; CSB pin BMx280
;/******************************* Event REGistry *********************************/
.equ _MIF_ = 0 ; Timer Measure Interval Flag
.equ _SPIRWF_ = 1 ; SPI Read/Write Flag, 0 - write (m->s), 1 - read (m<-s)
.equ _SPIERF_ = 3 ; SPI ERror Flag
.cseg
.org 0
.include "./inc/vectors.inc"
.include "./inc/macroses.inc"
.include "./inc/init.inc"
;/*********************************** MAIN LOOP **********************************/
MAIN:
sbrs _EREG_, _MIF_
rjmp _GO_TO_SLEEP
cbr _EREG_, (1<<_MIF_)
rcall MAKE_MEASURE
_RESTORE_TIMER:
rcall CLEAR_TIMER
rcall INIT_TIMER
_GO_TO_SLEEP:
in tmp, MCUCR
sbr tmp, (1<<SE)
out MCUCR, tmp
sei
sleep
rjmp MAIN
rjmp THE_END
.include "./inc/spi.inc"
.include "./inc/bmx280.inc"
.include "./inc/interrupts.inc"
.include "./inc/utils.inc"
;/*********************************** MEASURMENT *********************************/
MAKE_MEASURE:
sbrc _EREG_, _SPIERF_
rcall INIT_BMx280
rcall BMx280_WRITE_F4 ; Datasheet 3.3.3 Forced mode. For a next measurement, forced mode needs to be selected again.
BMx280_READ_MACRO BMx280_data, 0xf7, 0x06 ; Read data registers, count 0x08 for BME280 or 0x06 for BMP280
ret
;/************************************ THE END ***********************************/
THE_END:
cli
rjmp 0
.include "./inc/var.inc"