Mercurial > lcfOS
annotate test/c3examples/burn2.c3 @ 284:05184b95fa16
Moved tests to seperate folder
author | Windel Bouwman |
---|---|
date | Fri, 15 Nov 2013 13:43:22 +0100 |
parents | python/c3/examples/burn2.c3@02385f62f250 |
children | 1c7c1e619be8 |
rev | line source |
---|---|
262 | 1 /* |
2 | |
3 This file blinks a LED on the STM32F4 discovery board. | |
4 | |
5 the board has 4 leds on PD12, PD13, PD14 and PD15 | |
6 | |
7 */ | |
8 | |
284 | 9 module burn2; |
262 | 10 |
11 import stm32f4xx; | |
12 | |
280
02385f62f250
Rework from str interface to Instruction interface
Windel Bouwman
parents:
279
diff
changeset
|
13 function int add(int a, int b) |
02385f62f250
Rework from str interface to Instruction interface
Windel Bouwman
parents:
279
diff
changeset
|
14 { |
02385f62f250
Rework from str interface to Instruction interface
Windel Bouwman
parents:
279
diff
changeset
|
15 return a + b; |
02385f62f250
Rework from str interface to Instruction interface
Windel Bouwman
parents:
279
diff
changeset
|
16 } |
02385f62f250
Rework from str interface to Instruction interface
Windel Bouwman
parents:
279
diff
changeset
|
17 |
02385f62f250
Rework from str interface to Instruction interface
Windel Bouwman
parents:
279
diff
changeset
|
18 function void init(int pin) |
262 | 19 { |
280
02385f62f250
Rework from str interface to Instruction interface
Windel Bouwman
parents:
279
diff
changeset
|
20 if (pin < 12) |
02385f62f250
Rework from str interface to Instruction interface
Windel Bouwman
parents:
279
diff
changeset
|
21 { |
02385f62f250
Rework from str interface to Instruction interface
Windel Bouwman
parents:
279
diff
changeset
|
22 return; |
02385f62f250
Rework from str interface to Instruction interface
Windel Bouwman
parents:
279
diff
changeset
|
23 } |
02385f62f250
Rework from str interface to Instruction interface
Windel Bouwman
parents:
279
diff
changeset
|
24 |
02385f62f250
Rework from str interface to Instruction interface
Windel Bouwman
parents:
279
diff
changeset
|
25 /*if (pin > 15) |
02385f62f250
Rework from str interface to Instruction interface
Windel Bouwman
parents:
279
diff
changeset
|
26 { |
02385f62f250
Rework from str interface to Instruction interface
Windel Bouwman
parents:
279
diff
changeset
|
27 return; |
02385f62f250
Rework from str interface to Instruction interface
Windel Bouwman
parents:
279
diff
changeset
|
28 }*/ |
02385f62f250
Rework from str interface to Instruction interface
Windel Bouwman
parents:
279
diff
changeset
|
29 |
262 | 30 var RCC_Type RCC; |
31 RCC = cast<RCC_Type>(0x40023800); | |
32 | |
33 // Enable the clock to port D: | |
34 RCC->AHB1ENR = RCC->AHB1ENR | (1 << 3); | |
35 // Memory mapped control registers: | |
36 var GPIO_Type GPIOD; | |
37 GPIOD = cast<GPIO_Type>(0x40020C00); | |
38 | |
39 // PD13 == output (01) | |
279 | 40 GPIOD->MODER = (1 << (pin << 1)); |
262 | 41 GPIOD->ODR = (1 << pin); |
42 } | |
43 | |
44 | |
45 function void main() | |
46 { | |
280
02385f62f250
Rework from str interface to Instruction interface
Windel Bouwman
parents:
279
diff
changeset
|
47 // Vary between 12 and 15: |
02385f62f250
Rework from str interface to Instruction interface
Windel Bouwman
parents:
279
diff
changeset
|
48 init(13); |
262 | 49 |
50 var int a; | |
51 a = 0 | |
52 while (a < 1000) | |
53 { | |
280
02385f62f250
Rework from str interface to Instruction interface
Windel Bouwman
parents:
279
diff
changeset
|
54 a = a + 1; |
262 | 55 } |
56 | |
57 while(true) {} | |
58 } | |
59 |