summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.cpp25
1 files changed, 13 insertions, 12 deletions
diff --git a/main.cpp b/main.cpp
index 440cad4..eb36134 100644
--- a/main.cpp
+++ b/main.cpp
@@ -4,21 +4,18 @@
#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.CRL = 0x4434bbbb;
GPIOA.CRH = 0x444444b4;
GPIOA.ODR = 1 << 5;
GPIOB.CRH = 0x4444ff44;
- cnt = 0;
-
I2C i2c;
i2c.enable();
@@ -31,17 +28,21 @@ int main() {
PPMSum ppmsum;
ppmsum.enable();
+ RCC.enable(RCC.TIM2);
+ TIM2.PSC = 72;
+ TIM2.ARR = 20000;
+ TIM2.CCER = 0x1111;
+ TIM2.CCMR1 = 0x6868;
+ TIM2.CCMR2 = 0x6868;
+
+ TIM2.CR1 = 0x05;
+
while(1) {
- cnt++;
- if(cnt & (1 << 20)) {
- //GPIOA.ODR = 1 << 5;
- } else {
- //GPIOA.ODR = 0;
- }
+ // Wait for a new update.
+ while(!(TIM2.SR & 0x01));
+ TIM2.SR = 0;
- if(!(cnt & ((1 << 20) - 1))) {
i2c.read_reg(0x68, 0x1d, 6, buf);
//xbee_send(6, buf);
- }
}
}