Mercurial > lcfOS
annotate python/c3/examples/burn2.c3 @ 280:02385f62f250
Rework from str interface to Instruction interface
author | Windel Bouwman |
---|---|
date | Sat, 02 Nov 2013 10:03:26 +0100 |
parents | 2ccd57b1d78c |
children |
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 | |
9 package burn2; | |
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 |
02385f62f250
Rework from str interface to Instruction interface
Windel Bouwman
parents:
279
diff
changeset
|
19 function void init(int pin) |
262 | 20 { |
280
02385f62f250
Rework from str interface to Instruction interface
Windel Bouwman
parents:
279
diff
changeset
|
21 if (pin < 12) |
02385f62f250
Rework from str interface to Instruction interface
Windel Bouwman
parents:
279
diff
changeset
|
22 { |
02385f62f250
Rework from str interface to Instruction interface
Windel Bouwman
parents:
279
diff
changeset
|
23 return; |
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 |
02385f62f250
Rework from str interface to Instruction interface
Windel Bouwman
parents:
279
diff
changeset
|
26 /*if (pin > 15) |
02385f62f250
Rework from str interface to Instruction interface
Windel Bouwman
parents:
279
diff
changeset
|
27 { |
02385f62f250
Rework from str interface to Instruction interface
Windel Bouwman
parents:
279
diff
changeset
|
28 return; |
02385f62f250
Rework from str interface to Instruction interface
Windel Bouwman
parents:
279
diff
changeset
|
29 }*/ |
02385f62f250
Rework from str interface to Instruction interface
Windel Bouwman
parents:
279
diff
changeset
|
30 |
262 | 31 var RCC_Type RCC; |
32 RCC = cast<RCC_Type>(0x40023800); | |
33 | |
34 // Enable the clock to port D: | |
35 RCC->AHB1ENR = RCC->AHB1ENR | (1 << 3); | |
36 // Memory mapped control registers: | |
37 var GPIO_Type GPIOD; | |
38 GPIOD = cast<GPIO_Type>(0x40020C00); | |
39 | |
40 // PD13 == output (01) | |
279 | 41 GPIOD->MODER = (1 << (pin << 1)); |
262 | 42 GPIOD->ODR = (1 << pin); |
43 } | |
44 | |
45 | |
46 function void main() | |
47 { | |
280
02385f62f250
Rework from str interface to Instruction interface
Windel Bouwman
parents:
279
diff
changeset
|
48 // Vary between 12 and 15: |
02385f62f250
Rework from str interface to Instruction interface
Windel Bouwman
parents:
279
diff
changeset
|
49 init(13); |
262 | 50 |
51 var int a; | |
52 a = 0 | |
53 while (a < 1000) | |
54 { | |
280
02385f62f250
Rework from str interface to Instruction interface
Windel Bouwman
parents:
279
diff
changeset
|
55 a = a + 1; |
262 | 56 } |
57 | |
58 while(true) {} | |
59 } | |
60 |