2f54c7de00
git-svn-id: svn://kolibrios.org@8097 a494cfbc-eb01-0410-851d-a64ba20cac60
57 lines
1.1 KiB
Plaintext
57 lines
1.1 KiB
Plaintext
(*
|
||
Пример для STM32L152C-DISCO
|
||
|
||
В зависимости от значения константы LED,
|
||
мигает синий или зеленый светодиод.
|
||
*)
|
||
|
||
MODULE Blink;
|
||
|
||
IMPORT SYSTEM;
|
||
|
||
|
||
CONST
|
||
|
||
GPIOB = 40020400H;
|
||
GPIOB_MODER = GPIOB;
|
||
GPIOB_BSRR = GPIOB + 18H;
|
||
|
||
RCC = 40023800H;
|
||
RCC_AHBENR = RCC + 1CH;
|
||
|
||
Blue = 6; (* PB6 *)
|
||
Green = 7; (* PB7 *)
|
||
|
||
LED = Blue;
|
||
|
||
VAR
|
||
|
||
x: SET;
|
||
state: BOOLEAN;
|
||
|
||
|
||
PROCEDURE Delay (x: INTEGER);
|
||
BEGIN
|
||
REPEAT
|
||
DEC(x)
|
||
UNTIL x = 0
|
||
END Delay;
|
||
|
||
|
||
BEGIN
|
||
(* подключить GPIOB *)
|
||
SYSTEM.GET(RCC_AHBENR, x);
|
||
SYSTEM.PUT(RCC_AHBENR, x + {1});
|
||
|
||
(* настроить PB6 или PB7 на выход *)
|
||
SYSTEM.GET(GPIOB_MODER, x);
|
||
SYSTEM.PUT(GPIOB_MODER, x - {LED * 2 - 1} + {LED * 2});
|
||
|
||
state := FALSE;
|
||
REPEAT
|
||
(* включить или выключить светодиод *)
|
||
SYSTEM.PUT(GPIOB_BSRR, {LED + 16 * ORD(state)});
|
||
state := ~state;
|
||
Delay(200000)
|
||
UNTIL FALSE
|
||
END Blink. |