summaryrefslogtreecommitdiff
path: root/main.cpp
blob: 440cad4ef368545be20dbd8db24432ddd1fe8e9a (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
#include "stm32.h"
#include "interrupt.h"

#include "ppmsum.h"
#include "i2c.h"

volatile unsigned int cnt;

int main() {
	RCC.enable(RCC.AFIO);
	RCC.enable(RCC.IOPA);
	RCC.enable(RCC.IOPB);
	
	GPIOA.CRL = 0x44344444;
	GPIOA.CRH = 0x444444b4;
	GPIOA.ODR = 1 << 5;
	
	GPIOB.CRH = 0x4444ff44;
	
	cnt = 0;
	
	I2C i2c;
	
	i2c.enable();
	
	i2c.write_reg(0x68, 0x3e, 0x03);
	i2c.write_reg(0x68, 0x16, 0x18 | 0x02);
	
	uint8_t buf[6];
	
	PPMSum ppmsum;
	ppmsum.enable();
	
	while(1) {
		cnt++;
		if(cnt & (1 << 20)) {
			//GPIOA.ODR = 1 << 5;
		} else {
			//GPIOA.ODR = 0;
		}
		
		if(!(cnt & ((1 << 20) - 1))) {
			i2c.read_reg(0x68, 0x1d, 6, buf);
			//xbee_send(6, buf);
		}
	}
}