test to use function to set pull resistor

devel_freefall
Simon Frei 3 years ago
parent f92eb448e0
commit 3cf4380c91
  1. 41
      ASYD_Safety/Ada_Microbit/examples/MicroBit/jumper/src/main.adb

@ -7,8 +7,9 @@ with LSM303; use LSM303;
with MicroBit.Display;
with MicroBit.Accelerometer;
with MicroBit.Console;
with MicroBit.Buttons; use MicroBit.Buttons;
with MicroBit.Time;
with MicroBit.Buttons; use MicroBit.Buttons;
with HAL.GPIO;
with nRF.GPIO; use nRF.GPIO;
use MicroBit;
@ -29,7 +30,7 @@ procedure Main is
DO_2_Pt : GPIO_Point;
DO_3_Pt : GPIO_Point;
DO_4_Pt : GPIO_Point;
DI_Conf_Up : GPIO_Configuration;
-- DI_Conf_Up : GPIO_Configuration;
DI_Conf_Down : GPIO_Configuration;
@ -48,10 +49,10 @@ begin
DO_3_Pt := MB_P9;
DO_4_Pt := MB_P16;
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_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;
@ -65,6 +66,21 @@ begin
DO_4_Pt.Configure_IO(DI_Conf_Down);
loop
if Buttons.State (Button_A) = Pressed then
DO_1_Pt.Set_Pull_Resistor(Pull => HAL.GPIO.Pull_Up);
DO_2_Pt.Set_Pull_Resistor(Pull => HAL.GPIO.Pull_Up);
DO_3_Pt.Set_Pull_Resistor(Pull => HAL.GPIO.Pull_Up);
DO_4_Pt.Set_Pull_Resistor(Pull => HAL.GPIO.Pull_Up);
end if;
if Buttons.State (Button_B) = Pressed then
DO_1_Pt.Set_Pull_Resistor(Pull => HAL.GPIO.Pull_Down);
DO_2_Pt.Set_Pull_Resistor(Pull => HAL.GPIO.Pull_Down);
DO_3_Pt.Set_Pull_Resistor(Pull => HAL.GPIO.Pull_Down);
DO_4_Pt.Set_Pull_Resistor(Pull => HAL.GPIO.Pull_Down);
end if;
-- Read the accelerometer data
Data := Accelerometer.Data;
@ -98,10 +114,15 @@ begin
-- Check, wether FreeFallCondition was triggered
if FreeFallCondition then
-- set outputs -> motor on
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);
-- 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);
-- use function to set pull up
DO_1_Pt.Set_Pull_Resistor(Pull => HAL.GPIO.Pull_Up);
DO_2_Pt.Set_Pull_Resistor(Pull => HAL.GPIO.Pull_Up);
DO_3_Pt.Set_Pull_Resistor(Pull => HAL.GPIO.Pull_Up);
DO_4_Pt.Set_Pull_Resistor(Pull => HAL.GPIO.Pull_Up);
-- maybe timeout and stop motor
-- deep sleep afterwards
Display.Display ('X');

Loading…
Cancel
Save