|
|
|
@ -7,9 +7,11 @@ with LSM303; use LSM303; |
|
|
|
with MicroBit.Display; |
|
|
|
with MicroBit.Display; |
|
|
|
with MicroBit.Accelerometer; |
|
|
|
with MicroBit.Accelerometer; |
|
|
|
with MicroBit.Console; |
|
|
|
with MicroBit.Console; |
|
|
|
|
|
|
|
with MicroBit.Buttons; use MicroBit.Buttons; |
|
|
|
-- with MicroBit.IOs; |
|
|
|
-- with MicroBit.IOs; |
|
|
|
with MicroBit.Time; |
|
|
|
with MicroBit.Time; |
|
|
|
with nRF.GPIO; use nRF.GPIO; |
|
|
|
with nRF.GPIO; use nRF.GPIO; |
|
|
|
|
|
|
|
--with HAL.GPIO; use HAL.GPIO; |
|
|
|
|
|
|
|
|
|
|
|
use MicroBit; |
|
|
|
use MicroBit; |
|
|
|
-- use MicroBit.IOs; |
|
|
|
-- use MicroBit.IOs; |
|
|
|
@ -30,7 +32,9 @@ procedure Main is |
|
|
|
DO_2_Pt : GPIO_Point; |
|
|
|
DO_2_Pt : GPIO_Point; |
|
|
|
DO_3_Pt : GPIO_Point; |
|
|
|
DO_3_Pt : GPIO_Point; |
|
|
|
DO_4_Pt : GPIO_Point; |
|
|
|
DO_4_Pt : GPIO_Point; |
|
|
|
DO_Conf : GPIO_Configuration; |
|
|
|
--DO_Conf : GPIO_Configuration; |
|
|
|
|
|
|
|
DI_Conf_Up : GPIO_Configuration; |
|
|
|
|
|
|
|
DI_Conf_Down : GPIO_Configuration; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
begin |
|
|
|
begin |
|
|
|
@ -47,23 +51,46 @@ begin |
|
|
|
DO_2_Pt := MB_P8; |
|
|
|
DO_2_Pt := MB_P8; |
|
|
|
DO_3_Pt := MB_P9; |
|
|
|
DO_3_Pt := MB_P9; |
|
|
|
DO_4_Pt := MB_P16; |
|
|
|
DO_4_Pt := MB_P16; |
|
|
|
DO_Conf.Mode := Mode_Out; |
|
|
|
--DO_Conf.Mode := Mode_Out; |
|
|
|
DO_Conf.Resistors := No_Pull; |
|
|
|
--DO_Conf.Resistors := No_Pull; |
|
|
|
DO_Conf.Input_Buffer := Input_Buffer_Connect; |
|
|
|
--DO_Conf.Input_Buffer := Input_Buffer_Connect; |
|
|
|
DO_Conf.Sense := Sense_Disabled; |
|
|
|
--DO_Conf.Sense := Sense_Disabled; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DI_Conf_Up.Mode := Mode_In; |
|
|
|
|
|
|
|
DI_Conf_Up.Resistors := Pull_Up; |
|
|
|
|
|
|
|
DI_Conf_Up.Input_Buffer := Input_Buffer_Connect; |
|
|
|
|
|
|
|
DI_Conf_Up.Sense := Sense_Disabled; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DI_Conf_Down.Mode := Mode_In; |
|
|
|
|
|
|
|
DI_Conf_Down.Resistors := Pull_Down; |
|
|
|
|
|
|
|
DI_Conf_Down.Input_Buffer := Input_Buffer_Connect; |
|
|
|
|
|
|
|
DI_Conf_Down.Sense := Sense_Disabled; |
|
|
|
|
|
|
|
|
|
|
|
-- APPLY IO CONFIGURATION |
|
|
|
-- APPLY IO CONFIGURATION |
|
|
|
DO_1_Pt.Configure_IO(DO_Conf); |
|
|
|
DO_1_Pt.Configure_IO(DI_Conf_Down); |
|
|
|
DO_1_Pt.Clear; |
|
|
|
--DO_1_Pt.Clear; |
|
|
|
DO_2_Pt.Configure_IO(DO_Conf); |
|
|
|
DO_2_Pt.Configure_IO(DI_Conf_Down); |
|
|
|
DO_2_Pt.Clear; |
|
|
|
--DO_2_Pt.Clear; |
|
|
|
DO_3_Pt.Configure_IO(DO_Conf); |
|
|
|
DO_3_Pt.Configure_IO(DI_Conf_Down); |
|
|
|
DO_3_Pt.Clear; |
|
|
|
--DO_3_Pt.Clear; |
|
|
|
DO_4_Pt.Configure_IO(DO_Conf); |
|
|
|
DO_4_Pt.Configure_IO(DI_Conf_Down); |
|
|
|
DO_4_Pt.Clear; |
|
|
|
--DO_4_Pt.Set_Pull_Resistor(HAL.GPIO.Pull_Down); |
|
|
|
|
|
|
|
--DO_4_Pt.Clear; |
|
|
|
|
|
|
|
--Set_Pull_Resistor(DO_4_Pt,Pull => Pull_Down); |
|
|
|
|
|
|
|
|
|
|
|
loop |
|
|
|
loop |
|
|
|
|
|
|
|
if Buttons.State (Button_A) = Pressed then |
|
|
|
|
|
|
|
DO_1_Pt.Configure_IO(DI_Conf_Up); |
|
|
|
|
|
|
|
DO_2_Pt.Configure_IO(DI_Conf_Up); |
|
|
|
|
|
|
|
DO_3_Pt.Configure_IO(DI_Conf_Up); |
|
|
|
|
|
|
|
DO_4_Pt.Configure_IO(DI_Conf_Up); |
|
|
|
|
|
|
|
end if; |
|
|
|
|
|
|
|
if Buttons.State (Button_B) = Pressed then |
|
|
|
|
|
|
|
DO_1_Pt.Configure_IO(DI_Conf_Down); |
|
|
|
|
|
|
|
DO_2_Pt.Configure_IO(DI_Conf_Down); |
|
|
|
|
|
|
|
DO_3_Pt.Configure_IO(DI_Conf_Down); |
|
|
|
|
|
|
|
DO_4_Pt.Configure_IO(DI_Conf_Down); |
|
|
|
|
|
|
|
end if; |
|
|
|
-- Read the accelerometer data |
|
|
|
-- Read the accelerometer data |
|
|
|
Data := Accelerometer.Data; |
|
|
|
Data := Accelerometer.Data; |
|
|
|
|
|
|
|
|
|
|
|
@ -97,10 +124,10 @@ begin |
|
|
|
-- Check, wether FreeFallCondition was triggered |
|
|
|
-- Check, wether FreeFallCondition was triggered |
|
|
|
if FreeFallCondition then |
|
|
|
if FreeFallCondition then |
|
|
|
-- set outputs |
|
|
|
-- set outputs |
|
|
|
DO_1_Pt.Set; |
|
|
|
DO_1_Pt.Configure_IO(DI_Conf_Up); |
|
|
|
DO_2_Pt.Set; |
|
|
|
DO_2_Pt.Configure_IO(DI_Conf_Up); |
|
|
|
DO_3_Pt.Set; |
|
|
|
DO_3_Pt.Configure_IO(DI_Conf_Up); |
|
|
|
DO_4_Pt.Set; |
|
|
|
DO_4_Pt.Configure_IO(DI_Conf_Up); |
|
|
|
Display.Display ('X'); |
|
|
|
Display.Display ('X'); |
|
|
|
else |
|
|
|
else |
|
|
|
Display.Display ('0'); |
|
|
|
Display.Display ('0'); |
|
|
|
|