mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-28 09:58:23 +08:00
Merge branch 'master' into stm_i2c
This commit is contained in:
@@ -154,12 +154,6 @@
|
||||
<define name="DEFAULT_PITCH" value="0.5" unit="rad"/>
|
||||
</section>
|
||||
|
||||
<section name="DATALINK" prefix="DATALINK_">
|
||||
<define name="DEVICE_TYPE" value="XBEE"/>
|
||||
<define name="DEVICE_ADDRESS" value="...."/>
|
||||
</section>
|
||||
|
||||
|
||||
<section name="SIMU">
|
||||
<define name="JSBSIM_MODEL" value=""Malolo1""/>
|
||||
<define name="JSBSIM_IR_ROLL_NEUTRAL" value="RadOfDeg(0.)"/>
|
||||
|
||||
@@ -210,10 +210,6 @@ on<!DOCTYPE airframe SYSTEM "airframe.dtd">
|
||||
<define name="HOME_RADIUS" value="100" unit="m"/>
|
||||
</section>
|
||||
|
||||
<section name="DATALINK" prefix="DATALINK_">
|
||||
<define name="DEVICE_TYPE" value="XBEE"/>
|
||||
<define name="DEVICE_ADDRESS" value="...."/>
|
||||
</section>
|
||||
<makefile>
|
||||
CONFIG = \"tiny_2_1.h\"
|
||||
|
||||
|
||||
@@ -188,13 +188,6 @@
|
||||
<define name="HOME_RADIUS" value="100" unit="m"/>
|
||||
</section>
|
||||
|
||||
<!--
|
||||
<section name="DATALINK" prefix="DATALINK_">
|
||||
<define name="DEVICE_TYPE" value="AEROCOMM"/>
|
||||
<define name="DEVICE_ADDRESS" value="...."/>
|
||||
</section>
|
||||
-->
|
||||
|
||||
|
||||
<makefile>
|
||||
include $(PAPARAZZI_SRC)/conf/autopilot/tiny.makefile
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
|
||||
<modules>
|
||||
<load name="baro_board.xml"/>
|
||||
<load name="airspeed_ads1114.xml"/>
|
||||
<!--load name="mcp355x.xml"/-->
|
||||
</modules>
|
||||
|
||||
<firmware name="fixedwing">
|
||||
@@ -40,6 +42,8 @@
|
||||
<subsystem name="navigation"/>
|
||||
<!-- Sensors -->
|
||||
<subsystem name="gps" type="ublox"/>
|
||||
|
||||
<!--subsystem name="spi"/-->
|
||||
</firmware>
|
||||
|
||||
|
||||
|
||||
@@ -192,14 +192,7 @@
|
||||
<define name="DEFAULT_ROLL" value="0.3" unit="rad"/>
|
||||
<define name="DEFAULT_PITCH" value="0.5" unit="rad"/>
|
||||
<define name="HOME_RADIUS" value="100" unit="m"/>
|
||||
</section>
|
||||
|
||||
<!--
|
||||
<section name="DATALINK" prefix="DATALINK_">
|
||||
<define name="DEVICE_TYPE" value="XBEE"/>
|
||||
<define name="DEVICE_ADDRESS" value="...."/>
|
||||
</section>
|
||||
-->
|
||||
|
||||
<section name="SIMU">
|
||||
<!--define name="JSBSIM_MODEL" value=""fulmar""/-->
|
||||
|
||||
@@ -1,205 +0,0 @@
|
||||
<!DOCTYPE airframe SYSTEM "airframe.dtd">
|
||||
|
||||
<!--
|
||||
Multiplex EasyStar, using rudder
|
||||
TWOG v1 board
|
||||
Tilted infrared sensor
|
||||
XBee 2.4GHz modem in transparent mode
|
||||
-->
|
||||
|
||||
<!-- commands section -->
|
||||
<servos>
|
||||
<servo name="THROTTLE" no="0" min="1120" neutral="1120" max="1920"/>
|
||||
<servo name="ELEVATOR" no="6" min="1100" neutral="1514" max="1900"/>
|
||||
<servo name="RUDDER" no="7" min="2050" neutral="1612" max="950"/>
|
||||
</servos>
|
||||
|
||||
<commands>
|
||||
<axis name="THROTTLE" failsafe_value="0"/>
|
||||
<axis name="ROLL" failsafe_value="0"/>
|
||||
<axis name="PITCH" failsafe_value="0"/>
|
||||
</commands>
|
||||
|
||||
<rc_commands>
|
||||
<set command="ROLL" value="@ROLL"/>
|
||||
<set command="PITCH" value="@PITCH"/>
|
||||
<set command="THROTTLE" value="@THROTTLE"/>
|
||||
</rc_commands>
|
||||
|
||||
<command_laws>
|
||||
<set servo="THROTTLE" value="@THROTTLE"/>
|
||||
<set servo="RUDDER" value="@ROLL"/>
|
||||
<set servo="ELEVATOR" value="@PITCH"/>
|
||||
</command_laws>
|
||||
|
||||
<section name="AUTO1" prefix="AUTO1_">
|
||||
<define name="MAX_ROLL" value="RadOfDeg(50)"/>
|
||||
<define name="MAX_PITCH" value="RadOfDeg(40)"/>
|
||||
</section>
|
||||
|
||||
<section name="adc" prefix="ADC_CHANNEL_">
|
||||
<define name="IR1" value="ADC_1"/>
|
||||
<define name="IR2" value="ADC_2"/>
|
||||
<define name="IR_TOP" value="ADC_0"/>
|
||||
<define name="IR_NB_SAMPLES" value="16"/>
|
||||
</section>
|
||||
|
||||
<section name="INFRARED" prefix="IR_">
|
||||
<define name="ADC_IR1_NEUTRAL" value="512"/>
|
||||
<define name="ADC_IR2_NEUTRAL" value="510"/>
|
||||
<define name="ADC_TOP_NEUTRAL" value="516"/>
|
||||
|
||||
<define name="LATERAL_CORRECTION" value="0.7"/>
|
||||
<define name="LONGITUDINAL_CORRECTION" value="0.7"/>
|
||||
<define name="VERTICAL_CORRECTION" value="1."/>
|
||||
|
||||
<define name="HORIZ_SENSOR_TILTED" value="1"/>
|
||||
<define name="IR1_SIGN" value="1"/>
|
||||
<define name="IR2_SIGN" value="-1"/>
|
||||
<define name="TOP_SIGN" value="1"/>
|
||||
|
||||
<define name="ROLL_NEUTRAL_DEFAULT" value="-5.3" unit="deg"/>
|
||||
<define name="PITCH_NEUTRAL_DEFAULT" value="-3" unit="deg"/>
|
||||
|
||||
<define name="CORRECTION_UP" value="1."/>
|
||||
<define name="CORRECTION_DOWN" value="1."/>
|
||||
<define name="CORRECTION_LEFT" value="1."/>
|
||||
<define name="CORRECTION_RIGHT" value="1."/>
|
||||
</section>
|
||||
|
||||
<section name="BAT">
|
||||
<define name="CATASTROPHIC_BAT_LEVEL" value="8.0" unit="V"/>
|
||||
<define name="CRITIC_BAT_LEVEL" value="8.5" unit="V"/>
|
||||
<define name="LOW_BAT_LEVEL" value="9.5" unit="V"/>
|
||||
<define name="MAX_BAT_LEVEL" value="12.5" unit="V"/>
|
||||
</section>
|
||||
|
||||
<section name="MISC">
|
||||
<define name="NOMINAL_AIRSPEED" value="15." unit="m/s"/>
|
||||
<define name="CARROT" value="4." unit="s"/>
|
||||
<define name="KILL_MODE_DISTANCE" value="(2.0*MAX_DIST_FROM_HOME)"/>
|
||||
<define name="CONTROL_RATE" value="60" unit="Hz"/>
|
||||
<define name="NO_XBEE_API_INIT" value="TRUE"/>
|
||||
<define name="ALT_KALMAN_ENABLED" value="TRUE"/>
|
||||
<define name="TRIGGER_DELAY" value="1."/>
|
||||
<define name="DEFAULT_CIRCLE_RADIUS" value="90."/>
|
||||
</section>
|
||||
|
||||
<section name="VERTICAL CONTROL" prefix="V_CTL_">
|
||||
<define name="POWER_CTL_BAT_NOMINAL" value="11.0" unit="volt"/>
|
||||
<!-- outer loop -->
|
||||
<define name="ALTITUDE_PGAIN" value="-0.075" unit="(m/s)/m"/>
|
||||
<define name="ALTITUDE_MAX_CLIMB" value="4." unit="m/s"/>
|
||||
<!-- auto throttle inner loop -->
|
||||
<define name="AUTO_THROTTLE_NOMINAL_CRUISE_THROTTLE" value="0.5" unit="%"/>
|
||||
<define name="AUTO_THROTTLE_MIN_CRUISE_THROTTLE" value="0.4" unit="%"/>
|
||||
<define name="AUTO_THROTTLE_MAX_CRUISE_THROTTLE" value="0.8" unit="%"/>
|
||||
<define name="AUTO_THROTTLE_LOITER_TRIM" value="1500" unit="pprz_t"/>
|
||||
<define name="AUTO_THROTTLE_DASH_TRIM" value="-1000" unit="pprz_t"/>
|
||||
<define name="AUTO_THROTTLE_CLIMB_THROTTLE_INCREMENT" value="0.1" unit="%/(m/s)"/>
|
||||
<define name="AUTO_THROTTLE_PGAIN" value="-0.02" unit="%/(m/s)"/>
|
||||
<define name="AUTO_THROTTLE_IGAIN" value="0.1"/>
|
||||
<define name="AUTO_THROTTLE_PITCH_OF_VZ_PGAIN" value="0.05" unit="rad/(m/s)"/>
|
||||
<define name="AUTO_PITCH_PGAIN" value="-0.125"/>
|
||||
<define name="AUTO_PITCH_IGAIN" value="0.025"/>
|
||||
<define name="AUTO_PITCH_MAX_PITCH" value="RadOfDeg(25)"/>
|
||||
<define name="AUTO_PITCH_MIN_PITCH" value="RadOfDeg(-25)"/>
|
||||
<define name="THROTTLE_SLEW" value="1.0"/>
|
||||
</section>
|
||||
|
||||
<section name="HORIZONTAL CONTROL" prefix="H_CTL_">
|
||||
<define name="COURSE_PGAIN" value="-0.7"/>
|
||||
<define name="ROLL_MAX_SETPOINT" value="RadOfDeg(35)" unit="radians"/>
|
||||
<define name="PITCH_MAX_SETPOINT" value="RadOfDeg(25)" unit="radians"/>
|
||||
<define name="PITCH_MIN_SETPOINT" value="RadOfDeg(-25)" unit="radians"/>
|
||||
<define name="PITCH_PGAIN" value="-20000."/>
|
||||
<define name="PITCH_DGAIN" value="1.5"/>
|
||||
<define name="ELEVATOR_OF_ROLL" value="2500"/>
|
||||
<define name="ROLL_ATTITUDE_GAIN" value="-7400"/>
|
||||
<define name="ROLL_RATE_GAIN" value="-200"/>
|
||||
</section>
|
||||
|
||||
<section name="NAV">
|
||||
<define name="NAV_PITCH" value="0."/>
|
||||
<define name="NAV_GLIDE_PITCH_TRIM" value="0"/>
|
||||
</section>
|
||||
|
||||
<section name="AGGRESSIVE" prefix="AGR_">
|
||||
<define name="BLEND_START" value="20"/><!-- Altitude Error to Initiate Aggressive Climb CANNOT BE ZERO!!-->
|
||||
<define name="BLEND_END" value="10"/><!-- Altitude Error to Blend Aggressive to Regular Climb Modes CANNOT BE ZERO!!-->
|
||||
<define name="CLIMB_THROTTLE" value="0.9"/><!-- Gaz for Aggressive Climb -->
|
||||
<define name="CLIMB_PITCH" value="RadOfDeg(18)"/><!-- Pitch for Aggressive Climb -->
|
||||
<define name="DESCENT_THROTTLE" value="0.1"/><!-- Gaz for Aggressive Decent -->
|
||||
<define name="DESCENT_PITCH" value="RadOfDeg(-20)"/><!-- Pitch for Aggressive Decent -->
|
||||
<define name="CLIMB_NAV_RATIO" value="0.8"/><!-- Percent Navigation for Altitude Error Equal to Start Altitude -->
|
||||
<define name="DESCENT_NAV_RATIO" value="1.0"/>
|
||||
</section>
|
||||
|
||||
<section name="FAILSAFE" prefix="FAILSAFE_">
|
||||
<define name="DELAY_WITHOUT_GPS" value="3" unit="s"/>
|
||||
<define name="DEFAULT_THROTTLE" value="0.4" unit="%"/>
|
||||
<define name="DEFAULT_ROLL" value="RadOfDeg(15)" unit="rad"/>
|
||||
<define name="DEFAULT_PITCH" value="RadOfDeg(0)" unit="rad"/>
|
||||
<define name="HOME_RADIUS" value="90" unit="m"/>
|
||||
</section>
|
||||
|
||||
<section name="DATALINK" prefix="DATALINK_">
|
||||
<define name="DEVICE_TYPE" value="PPRZ"/>
|
||||
<define name="DEVICE_ADDRESS" value="...."/>
|
||||
</section>
|
||||
|
||||
<makefile>
|
||||
CONFIG = \"tiny_2_1_1.h\"
|
||||
|
||||
# Target configuration
|
||||
include $(PAPARAZZI_SRC)/conf/autopilot/tiny.makefile
|
||||
|
||||
FLASH_MODE=IAP
|
||||
|
||||
ap.CFLAGS += -DFBW -DAP -DBOARD_CONFIG=$(CONFIG) -DUSE_LED -DTIME_LED=1 -DUSE_MODULES
|
||||
ap.srcs = sys_time.c $(SRC_ARCH)/sys_time_hw.c $(SRC_ARCH)/armVIC.c main_fbw.c main_ap.c main.c
|
||||
|
||||
ap.srcs += commands.c
|
||||
|
||||
# Servo driver
|
||||
ap.CFLAGS += -DACTUATORS=\"servos_4017_hw.h\" -DSERVOS_4017
|
||||
ap.srcs += $(SRC_ARCH)/servos_4017_hw.c actuators.c
|
||||
|
||||
# Radio configuration
|
||||
ap.CFLAGS += -DRADIO_CONTROL
|
||||
ap.srcs += radio_control.c $(SRC_ARCH)/ppm_hw.c
|
||||
|
||||
# Telemetry configuration
|
||||
ap.CFLAGS += -DDOWNLINK -DUSE_UART1 -DDOWNLINK_TRANSPORT=PprzTransport -DDOWNLINK_FBW_DEVICE=Uart1 -DDOWNLINK_AP_DEVICE=Uart1 -DPPRZ_UART=Uart1 -DDATALINK=PPRZ -DUART1_BAUD=B57600
|
||||
ap.srcs += downlink.c $(SRC_ARCH)/mcu_periph/uart_arch.c datalink.c pprz_transport.c
|
||||
|
||||
ap.CFLAGS += -DINTER_MCU
|
||||
ap.srcs += inter_mcu.c
|
||||
|
||||
# ADC configuration
|
||||
ap.CFLAGS += -DADC -DUSE_ADC_0 -DUSE_ADC_1 -DUSE_ADC_2
|
||||
ap.srcs += $(SRC_ARCH)/adc_hw.c
|
||||
|
||||
# USE_GPS configuration
|
||||
ap.CFLAGS += -DUSE_GPS -DUBX -DUSE_UART0 -DGPS_LINK=Uart0 -DUART0_BAUD=B38400 -DGPS_USE_LATLONG -DGPS_LED=2
|
||||
ap.srcs += gps_ubx.c gps.c latlong.c
|
||||
|
||||
ap.CFLAGS += -DUSE_INFRARED -DALT_KALMAN
|
||||
ap.srcs += infrared.c estimator.c
|
||||
|
||||
# Control loops
|
||||
ap.CFLAGS += -DNAV -DLOITER_TRIM
|
||||
ap.srcs += subsystems/nav.c fw_h_ctl.c fw_v_ctl.c
|
||||
|
||||
ap.srcs += subsystems/navigation/nav_line.c
|
||||
ap.srcs += subsystems/navigation/nav_survey_rectangle.c
|
||||
|
||||
|
||||
|
||||
# Config for SITL simulation
|
||||
include $(PAPARAZZI_SRC)/conf/autopilot/sitl.makefile
|
||||
sim.CFLAGS += -DBOARD_CONFIG=\"tiny.h\" -DLOITER_TRIM -DALT_KALMAN -DUSE_MODULES
|
||||
sim.srcs += subsystems/navigation/nav_line.c subsystems/navigation/nav_survey_rectangle.c
|
||||
|
||||
</makefile>
|
||||
</airframe>
|
||||
@@ -184,11 +184,6 @@
|
||||
<define name="DEFAULT_PITCH" value="0.5" unit="rad"/>
|
||||
</section>
|
||||
|
||||
<section name="DATALINK" prefix="DATALINK_">
|
||||
<define name="DEVICE_TYPE" value="XBEE"/>
|
||||
<define name="DEVICE_ADDRESS" value="...."/>
|
||||
</section>
|
||||
|
||||
<firmware name="fixedwing">
|
||||
<target name="ap" board="tiny_1.1">
|
||||
<configure name="PERIODIC_FREQUENCY" value="960"/> <!-- IMU FREQ -->
|
||||
|
||||
@@ -231,13 +231,6 @@ inline static void h_ctl_roll_loop( void ) {
|
||||
<define name="DEFAULT_PITCH" value="0.5" unit="rad"/>
|
||||
</section>
|
||||
|
||||
<!--
|
||||
<section name="DATALINK" prefix="DATALINK_">
|
||||
<define name="DEVICE_TYPE" value="XBEE"/>
|
||||
<define name="DEVICE_ADDRESS" value="0x005067361851"/>
|
||||
</section>
|
||||
-->
|
||||
|
||||
<section name="SIMU">
|
||||
<define name="YAW_RESPONSE_FACTOR" value="0.5"/>
|
||||
</section>
|
||||
|
||||
@@ -236,13 +236,6 @@ inline static void h_ctl_roll_loop( void ) {
|
||||
<define name="DEFAULT_PITCH" value="0.5" unit="rad"/>
|
||||
</section>
|
||||
|
||||
<!--
|
||||
<section name="DATALINK" prefix="DATALINK_">
|
||||
<define name="DEVICE_TYPE" value="XBEE"/>
|
||||
<define name="DEVICE_ADDRESS" value="0x005067361851"/>
|
||||
</section>
|
||||
-->
|
||||
|
||||
<section name="SIMU">
|
||||
<define name="YAW_RESPONSE_FACTOR" value="0.5"/>
|
||||
</section>
|
||||
|
||||
@@ -231,13 +231,6 @@ inline static void h_ctl_roll_loop( void ) {
|
||||
<define name="DEFAULT_PITCH" value="0.5" unit="rad"/>
|
||||
</section>
|
||||
|
||||
<!--
|
||||
<section name="DATALINK" prefix="DATALINK_">
|
||||
<define name="DEVICE_TYPE" value="AEROCOMM"/>
|
||||
<define name="DEVICE_ADDRESS" value="0x005067361851"/>
|
||||
</section>
|
||||
-->
|
||||
|
||||
<section name="SIMU">
|
||||
<define name="YAW_RESPONSE_FACTOR" value="0.5"/>
|
||||
</section>
|
||||
|
||||
@@ -164,9 +164,4 @@
|
||||
<define name="HOME_RADIUS" value="90" unit="m"/>
|
||||
</section>
|
||||
|
||||
<section name="DATALINK" prefix="DATALINK_">
|
||||
<define name="DEVICE_TYPE" value="PPRZ"/>
|
||||
<define name="DEVICE_ADDRESS" value="...."/>
|
||||
</section>
|
||||
|
||||
</airframe>
|
||||
|
||||
@@ -208,13 +208,6 @@
|
||||
<define name="HOME_RADIUS" value="70" unit="m"/>
|
||||
</section>
|
||||
|
||||
<!--
|
||||
<section name="DATALINK" prefix="DATALINK_">
|
||||
<define name="DEVICE_TYPE" value="PPRZ"/>
|
||||
<define name="DEVICE_ADDRESS" value="...."/>
|
||||
</section>
|
||||
-->
|
||||
|
||||
<section name="SIMU">
|
||||
<define name="JSBSIM_MODEL" value=""Malolo1""/>
|
||||
<define name="JSBSIM_IR_ROLL_NEUTRAL" value="RadOfDeg(0.)"/>
|
||||
|
||||
@@ -157,12 +157,6 @@
|
||||
<define name="DEFAULT_PITCH" value="0.5" unit="rad"/>
|
||||
</section>
|
||||
|
||||
<section name="DATALINK" prefix="DATALINK_">
|
||||
<define name="DEVICE_TYPE" value="XBEE"/>
|
||||
<define name="DEVICE_ADDRESS" value="...."/>
|
||||
</section>
|
||||
|
||||
|
||||
<section name="SIMU">
|
||||
<define name="JSBSIM_MODEL" value=""Malolo1""/>
|
||||
<define name="JSBSIM_IR_ROLL_NEUTRAL" value="RadOfDeg(0.)"/>
|
||||
|
||||
@@ -174,11 +174,6 @@
|
||||
<define name="DEFAULT_ROLL" value="0.3" unit="rad"/>
|
||||
<define name="DEFAULT_PITCH" value="0.5" unit="rad"/>
|
||||
<define name="HOME_RADIUS" value="100" unit="m"/>
|
||||
</section>
|
||||
|
||||
<section name="DATALINK" prefix="DATALINK_">
|
||||
<define name="DEVICE_TYPE" value="XBEE"/>
|
||||
<define name="DEVICE_ADDRESS" value="...."/>
|
||||
</section>
|
||||
|
||||
<section name="SIMU">
|
||||
|
||||
@@ -194,11 +194,6 @@
|
||||
<define name="DEFAULT_ROLL" value="0.3" unit="rad"/>
|
||||
<define name="DEFAULT_PITCH" value="0.5" unit="rad"/>
|
||||
<define name="HOME_RADIUS" value="100" unit="m"/>
|
||||
</section>
|
||||
|
||||
<section name="DATALINK" prefix="DATALINK_">
|
||||
<define name="DEVICE_TYPE" value="XBEE"/>
|
||||
<define name="DEVICE_ADDRESS" value="...."/>
|
||||
</section>
|
||||
|
||||
<section name="MAX11040">
|
||||
|
||||
@@ -19,11 +19,6 @@
|
||||
<define name="VoltageOfAdc(adc)" value="(0.02454*adc)"/>
|
||||
</section>
|
||||
|
||||
<section name="DATALINK" prefix="DATALINK_">
|
||||
<define name="DEVICE_TYPE" value="XBEE"/>
|
||||
<define name="DEVICE_ADDRESS" value="...."/>
|
||||
</section>
|
||||
|
||||
<makefile>
|
||||
|
||||
CONFIG = \"tiny_2_1.h\"
|
||||
|
||||
@@ -170,11 +170,6 @@
|
||||
<define name="DEFAULT_ROLL" value="0.3" unit="rad"/>
|
||||
<define name="DEFAULT_PITCH" value="0.5" unit="rad"/>
|
||||
<define name="HOME_RADIUS" value="100" unit="m"/>
|
||||
</section>
|
||||
|
||||
<section name="DATALINK" prefix="DATALINK_">
|
||||
<define name="DEVICE_TYPE" value="XBEE"/>
|
||||
<define name="DEVICE_ADDRESS" value="...."/>
|
||||
</section>
|
||||
|
||||
<section name="MICROMAG">
|
||||
|
||||
@@ -171,11 +171,6 @@
|
||||
<define name="DEFAULT_ROLL" value="0.3" unit="rad"/>
|
||||
<define name="DEFAULT_PITCH" value="0.5" unit="rad"/>
|
||||
<define name="HOME_RADIUS" value="100" unit="m"/>
|
||||
</section>
|
||||
|
||||
<section name="DATALINK" prefix="DATALINK_">
|
||||
<define name="DEVICE_TYPE" value="XBEE"/>
|
||||
<define name="DEVICE_ADDRESS" value="...."/>
|
||||
</section>
|
||||
|
||||
<section name="MICROMAG">
|
||||
|
||||
@@ -169,11 +169,6 @@
|
||||
<define name="DEFAULT_ROLL" value="0.3" unit="rad"/>
|
||||
<define name="DEFAULT_PITCH" value="0.5" unit="rad"/>
|
||||
<define name="HOME_RADIUS" value="100" unit="m"/>
|
||||
</section>
|
||||
|
||||
<section name="DATALINK" prefix="DATALINK_">
|
||||
<define name="DEVICE_TYPE" value="XBEE"/>
|
||||
<define name="DEVICE_ADDRESS" value="...."/>
|
||||
</section>
|
||||
|
||||
<section name="SIMU">
|
||||
|
||||
@@ -170,11 +170,6 @@
|
||||
<define name="HOME_RADIUS" value="100" unit="m"/>
|
||||
</section>
|
||||
|
||||
<section name="DATALINK" prefix="DATALINK_">
|
||||
<define name="DEVICE_TYPE" value="XBEE"/>
|
||||
<define name="DEVICE_ADDRESS" value="...."/>
|
||||
</section>
|
||||
|
||||
<section name="SIMU">
|
||||
<define name="YAW_RESPONSE_FACTOR" value="0.5"/>
|
||||
</section>
|
||||
|
||||
@@ -168,11 +168,6 @@
|
||||
<define name="DEFAULT_ROLL" value="0.3" unit="rad"/>
|
||||
<define name="DEFAULT_PITCH" value="0.5" unit="rad"/>
|
||||
<define name="HOME_RADIUS" value="100" unit="m"/>
|
||||
</section>
|
||||
|
||||
<section name="DATALINK" prefix="DATALINK_">
|
||||
<define name="DEVICE_TYPE" value="XBEE"/>
|
||||
<define name="DEVICE_ADDRESS" value="...."/>
|
||||
</section>
|
||||
|
||||
<section name="SIMU">
|
||||
|
||||
@@ -168,11 +168,6 @@
|
||||
<define name="HOME_RADIUS" value="100" unit="m"/>
|
||||
</section>
|
||||
|
||||
<section name="DATALINK" prefix="DATALINK_">
|
||||
<define name="DEVICE_TYPE" value="XBEE"/>
|
||||
<define name="DEVICE_ADDRESS" value="...."/>
|
||||
</section>
|
||||
|
||||
<section name="SIMU">
|
||||
<define name="YAW_RESPONSE_FACTOR" value="0.5"/>
|
||||
</section>
|
||||
|
||||
@@ -186,11 +186,6 @@
|
||||
<define name="HOME_RADIUS" value="100" unit="m"/>
|
||||
</section>
|
||||
|
||||
<section name="DATALINK" prefix="DATALINK_">
|
||||
<define name="DEVICE_TYPE" value="XBEE"/>
|
||||
<define name="DEVICE_ADDRESS" value="...."/>
|
||||
</section>
|
||||
|
||||
<makefile>
|
||||
include $(PAPARAZZI_SRC)/conf/autopilot/tiny.makefile
|
||||
|
||||
|
||||
@@ -169,11 +169,6 @@
|
||||
<define name="HOME_RADIUS" value="100" unit="m"/>
|
||||
</section>
|
||||
|
||||
<section name="DATALINK" prefix="DATALINK_">
|
||||
<define name="DEVICE_TYPE" value="XBEE"/>
|
||||
<define name="DEVICE_ADDRESS" value="...."/>
|
||||
</section>
|
||||
|
||||
<section name="SIMU">
|
||||
<define name="YAW_RESPONSE_FACTOR" value="0.5"/>
|
||||
</section>
|
||||
|
||||
@@ -168,11 +168,6 @@
|
||||
<define name="DEFAULT_ROLL" value="0.3" unit="rad"/>
|
||||
<define name="DEFAULT_PITCH" value="0.5" unit="rad"/>
|
||||
<define name="HOME_RADIUS" value="100" unit="m"/>
|
||||
</section>
|
||||
|
||||
<section name="DATALINK" prefix="DATALINK_">
|
||||
<define name="DEVICE_TYPE" value="XBEE"/>
|
||||
<define name="DEVICE_ADDRESS" value="...."/>
|
||||
</section>
|
||||
|
||||
<section name="SIMU">
|
||||
|
||||
@@ -170,11 +170,6 @@
|
||||
<define name="HOME_RADIUS" value="100" unit="m"/>
|
||||
</section>
|
||||
|
||||
<section name="DATALINK" prefix="DATALINK_">
|
||||
<define name="DEVICE_TYPE" value="XBEE"/>
|
||||
<define name="DEVICE_ADDRESS" value="...."/>
|
||||
</section>
|
||||
|
||||
<section name="SIMU">
|
||||
<define name="YAW_RESPONSE_FACTOR" value="0.5"/>
|
||||
</section>
|
||||
|
||||
@@ -170,11 +170,6 @@
|
||||
<define name="HOME_RADIUS" value="100" unit="m"/>
|
||||
</section>
|
||||
|
||||
<section name="DATALINK" prefix="DATALINK_">
|
||||
<define name="DEVICE_TYPE" value="XBEE"/>
|
||||
<define name="DEVICE_ADDRESS" value="...."/>
|
||||
</section>
|
||||
|
||||
<section name="SIMU">
|
||||
<define name="YAW_RESPONSE_FACTOR" value="0.5"/>
|
||||
</section>
|
||||
|
||||
@@ -168,11 +168,6 @@
|
||||
<define name="DEFAULT_ROLL" value="0.3" unit="rad"/>
|
||||
<define name="DEFAULT_PITCH" value="0.5" unit="rad"/>
|
||||
<define name="HOME_RADIUS" value="100" unit="m"/>
|
||||
</section>
|
||||
|
||||
<section name="DATALINK" prefix="DATALINK_">
|
||||
<define name="DEVICE_TYPE" value="XBEE"/>
|
||||
<define name="DEVICE_ADDRESS" value="...."/>
|
||||
</section>
|
||||
|
||||
<section name="SIMU">
|
||||
|
||||
@@ -176,11 +176,6 @@
|
||||
<define name="HOME_RADIUS" value="100" unit="m"/>
|
||||
</section>
|
||||
|
||||
<section name="DATALINK" prefix="DATALINK_">
|
||||
<define name="DEVICE_TYPE" value="XBEE"/>
|
||||
<define name="DEVICE_ADDRESS" value="...."/>
|
||||
</section>
|
||||
|
||||
<section name="SIMU">
|
||||
<define name="YAW_RESPONSE_FACTOR" value="0.5"/>
|
||||
</section>
|
||||
|
||||
@@ -168,11 +168,6 @@
|
||||
<define name="HOME_RADIUS" value="100" unit="m"/>
|
||||
</section>
|
||||
|
||||
<section name="DATALINK" prefix="DATALINK_">
|
||||
<define name="DEVICE_TYPE" value="XBEE"/>
|
||||
<define name="DEVICE_ADDRESS" value="...."/>
|
||||
</section>
|
||||
|
||||
<makefile>
|
||||
CONFIG = \"tiny_2_1.h\"
|
||||
|
||||
|
||||
@@ -217,11 +217,6 @@
|
||||
<define name="ROLL_RATE_DGAIN" value="0.0"/>
|
||||
</section>
|
||||
|
||||
<section name="DATALINK" prefix="DATALINK_">
|
||||
<define name="DEVICE_TYPE" value="XBEE"/>
|
||||
<define name="DEVICE_ADDRESS" value="...."/>
|
||||
</section>
|
||||
|
||||
|
||||
<!--
|
||||
<makefile>
|
||||
|
||||
@@ -192,10 +192,6 @@
|
||||
<define name="HOME_RADIUS" value="100" unit="m"/>
|
||||
</section>
|
||||
|
||||
<!--section name="DATALINK" prefix="DATALINK_">
|
||||
<define name="DEVICE_TYPE" value="XBEE"/>
|
||||
<define name="DEVICE_ADDRESS" value="...."/>
|
||||
</section-->
|
||||
<makefile>
|
||||
CONFIG = \"tiny_2_1.h\"
|
||||
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
<airframe name="TEST_I2C">
|
||||
|
||||
<section name="DATALINK" prefix="DATALINK_">
|
||||
<define name="DEVICE_TYPE" value="PPRZ"/>
|
||||
<define name="DEVICE_ADDRESS" value="...."/>
|
||||
</section>
|
||||
|
||||
<makefile>
|
||||
|
||||
ARCH=lpc21
|
||||
|
||||
@@ -101,7 +101,9 @@ ap.srcs += mcu_periph/uart.c
|
||||
ap.srcs += $(SRC_ARCH)/mcu_periph/uart_arch.c
|
||||
|
||||
# I2C is needed for speed controllers and barometers on lisa
|
||||
include $(CFG_SHARED)/i2c_select.makefile
|
||||
ifeq ($(TARGET), ap)
|
||||
include $(CFG_SHARED)/i2c_select.makefile
|
||||
endif
|
||||
|
||||
ap.srcs += $(SRC_FIRMWARE)/commands.c
|
||||
|
||||
|
||||
@@ -15,6 +15,4 @@ endif
|
||||
# Simulator
|
||||
sim.srcs += $(SRC_FIRMWARE)/actuators/actuators_asctec.c
|
||||
sim.CFLAGS += -DUSE_I2C0 -DI2C0_SCLL=150 -DI2C0_SCLH=150 -DI2C0_VIC_SLOT=11
|
||||
sim.srcs += mcu_periph/i2c.c
|
||||
sim.srcs += $(SRC_ARCH)/mcu_periph/i2c_arch.c
|
||||
|
||||
|
||||
@@ -51,5 +51,3 @@ endif
|
||||
sim.srcs += $(SRC_FIRMWARE)/actuators/supervision.c
|
||||
sim.srcs += $(SRC_FIRMWARE)/actuators/actuators_mkk.c
|
||||
sim.CFLAGS += -DUSE_I2C0 -DI2C0_SCLL=$(MKK_I2C_SCL_TIME) -DI2C0_SCLH=$(MKK_I2C_SCL_TIME) -DI2C0_VIC_SLOT=10 -DACTUATORS_MKK_DEVICE=i2c1
|
||||
sim.srcs += mcu_periph/i2c.c
|
||||
sim.srcs += $(SRC_ARCH)/mcu_periph/i2c_arch.c
|
||||
|
||||
@@ -50,6 +50,4 @@ endif
|
||||
sim.srcs += $(SRC_FIRMWARE)/actuators/supervision.c
|
||||
sim.srcs += $(SRC_FIRMWARE)/actuators/actuators_skiron.c
|
||||
sim.CFLAGS += -DUSE_I2C0 -DI2C0_SCLL=$(SKIRON_I2C_SCL_TIME) -DI2C0_SCLH=$(SKIRON_I2C_SCL_TIME) -DI2C0_VIC_SLOT=10 -DACTUATORS_MKK_DEVICE=i2c0
|
||||
sim.srcs += mcu_periph/i2c.c
|
||||
sim.srcs += $(SRC_ARCH)/mcu_periph/i2c_arch.c
|
||||
|
||||
|
||||
@@ -63,6 +63,11 @@ sim.srcs += firmwares/rotorcraft/main.c
|
||||
sim.srcs += mcu.c
|
||||
sim.srcs += $(SRC_ARCH)/mcu_arch.c
|
||||
|
||||
ifeq ($(TARGET), sim)
|
||||
include $(CFG_SHARED)/i2c_select.makefile
|
||||
endif
|
||||
|
||||
|
||||
sim.CFLAGS += -DPERIODIC_TASK_PERIOD='SYS_TICS_OF_SEC((1./512.))'
|
||||
# -DTIME_LED=1
|
||||
#sim.CFLAGS += -DUSE_LED
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
<!DOCTYPE module SYSTEM "module.dtd">
|
||||
<!-- Module to extend the baro_board module with an airspeed sensor using ads1114 adc -->
|
||||
|
||||
<module name="airspeed_ads1114" dir="sensors">
|
||||
<depend require="baro_board.xml"/>
|
||||
<header>
|
||||
<file name="airspeed_ads1114.h"/>
|
||||
</header>
|
||||
<periodic fun="airspeed_periodic()" freq="60."/>
|
||||
<makefile target="ap">
|
||||
<file name="airspeed_ads1114.c"/>
|
||||
<define name="USE_BARO_DIFF"/>
|
||||
<define name="USE_ADS1114_2"/>
|
||||
<define name="ADS1114_2_PGA" value="0x1"/> <!-- PGA gain = 1 (+/- 4.096V) -->
|
||||
</makefile>
|
||||
</module>
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
<define name="USE_BARO_AS_ALTIMETER"/>
|
||||
<file name="baro_board.c" dir="boards/$(BOARD)"/>
|
||||
<define name="ADS1114_I2C_DEVICE" value="i2c1"/>
|
||||
<define name="USE_ADS1114_1"/>
|
||||
<file name="ads1114.c" dir="peripherals"/>
|
||||
</makefile>
|
||||
</module>
|
||||
|
||||
@@ -55,7 +55,7 @@ void baro_init( void ) {
|
||||
ads1114_init();
|
||||
baro.status = BS_UNINITIALIZED;
|
||||
baro.absolute = 0;
|
||||
baro.differential = 0; /* not handled on this board */
|
||||
baro.differential = 0; /* not handled on this board, use extra module (ex: airspeed_ads1114) */
|
||||
#ifdef USE_BARO_AS_ALTIMETER
|
||||
baro_alt = 0.;
|
||||
baro_alt_offset = 0.;
|
||||
@@ -66,7 +66,7 @@ void baro_init( void ) {
|
||||
void baro_periodic( void ) {
|
||||
|
||||
#ifdef USE_BARO_AS_ALTIMETER
|
||||
if (baro.status == BS_UNINITIALIZED && ads1114_data_available) {
|
||||
if (baro.status == BS_UNINITIALIZED && BARO_ABS_ADS.data_available) {
|
||||
// IIR filter to compute an initial offset
|
||||
baro_alt_offset = (OFFSET_FILTER * baro_alt_offset + (float)baro.absolute) / (OFFSET_FILTER + 1);
|
||||
// decrease init counter
|
||||
@@ -75,7 +75,7 @@ void baro_periodic( void ) {
|
||||
}
|
||||
#endif
|
||||
// Read the ADC
|
||||
ads1114_read();
|
||||
ads1114_read(&BARO_ABS_ADS);
|
||||
}
|
||||
|
||||
void baro_downlink_raw( void )
|
||||
|
||||
@@ -35,6 +35,11 @@
|
||||
|
||||
#define BARO_FILTER_GAIN 5
|
||||
|
||||
/* There is no differential pressure on the board but
|
||||
* it can be available from an external sensor
|
||||
* */
|
||||
#define DIFF_FILTER_GAIN 5
|
||||
|
||||
#ifdef USE_BARO_AS_ALTIMETER
|
||||
extern float baro_alt;
|
||||
extern float baro_alt_offset;
|
||||
@@ -43,15 +48,45 @@ extern float baro_alt_offset;
|
||||
|
||||
extern void baro_downlink_raw( void );
|
||||
|
||||
#define BARO_ABS_ADS ads1114_1
|
||||
|
||||
#define BaroAbs(_ads, _handler) { \
|
||||
if (_ads.data_available) { \
|
||||
baro.absolute = (baro.absolute + BARO_FILTER_GAIN*Ads1114GetValue(_ads)) / (BARO_FILTER_GAIN+1); \
|
||||
if (baro.status == BS_RUNNING) { \
|
||||
_handler(); \
|
||||
_ads.data_available = FALSE; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
#ifndef BaroDiff // Allow custom redefinition ?
|
||||
|
||||
#if USE_BARO_DIFF
|
||||
|
||||
#ifndef BARO_DIFF_ADS
|
||||
#define BARO_DIFF_ADS ads1114_2
|
||||
#endif
|
||||
#define BaroDiff(_ads, _handler) { \
|
||||
if (_ads.data_available) { \
|
||||
baro.differential = (baro.differential + DIFF_FILTER_GAIN*Ads1114GetValue(_ads)) / (DIFF_FILTER_GAIN+1); \
|
||||
if (baro.status == BS_RUNNING) { \
|
||||
_handler(); \
|
||||
_ads.data_available = FALSE; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
#else // Not using differential with ADS1114
|
||||
#define BaroDiff(_a, _h) {}
|
||||
#endif
|
||||
|
||||
#endif // ifndef BaroDiff
|
||||
|
||||
#define BaroEvent(_b_abs_handler, _b_diff_handler) { \
|
||||
Ads1114Event(); \
|
||||
if (ads1114_data_available) { \
|
||||
baro.absolute = (baro.absolute + BARO_FILTER_GAIN*Ads1114GetValue()) / (BARO_FILTER_GAIN+1); \
|
||||
if (baro.status == BS_RUNNING) { \
|
||||
_b_abs_handler(); \
|
||||
ads1114_data_available = FALSE; \
|
||||
} \
|
||||
} \
|
||||
BaroAbs(BARO_ABS_ADS,_b_abs_handler); \
|
||||
BaroDiff(BARO_DIFF_ADS,_b_diff_handler); \
|
||||
}
|
||||
|
||||
#endif // BOARDS_UMARIM_BARO_H
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 2011 Gautier Hattenberger
|
||||
*
|
||||
* This file is part of paparazzi.
|
||||
*
|
||||
* paparazzi is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* paparazzi is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with paparazzi; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Module to extend the baro_board module with an airspeed sensor
|
||||
* Init and event functions are handled by the baro_board module
|
||||
*/
|
||||
|
||||
#include "modules/sensors/airspeed_ads1114.h"
|
||||
#include "subsystems/sensors/baro.h"
|
||||
#include "baro_board.h"
|
||||
|
||||
void airspeed_periodic(void) {
|
||||
ads1114_read(&BARO_DIFF_ADS);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (C) 2011 Gautier Hattenberger
|
||||
*
|
||||
* This file is part of paparazzi.
|
||||
*
|
||||
* paparazzi is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* paparazzi is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with paparazzi; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Module to extend the baro_board module with an airspeed sensor
|
||||
*/
|
||||
|
||||
#ifndef AIRSPEED_ADS1114_H
|
||||
#define AIRSPEED_ADS1114_H
|
||||
|
||||
extern void airspeed_periodic(void);
|
||||
|
||||
#endif
|
||||
@@ -27,28 +27,44 @@
|
||||
|
||||
#include "peripherals/ads1114.h"
|
||||
|
||||
struct i2c_transaction ads1114_trans;
|
||||
|
||||
bool_t ads1114_config_done;
|
||||
bool_t ads1114_data_available;
|
||||
#if USE_ADS1114_1
|
||||
struct ads1114_periph ads1114_1;
|
||||
#endif
|
||||
#if USE_ADS1114_2
|
||||
struct ads1114_periph ads1114_2;
|
||||
#endif
|
||||
|
||||
void ads1114_init( void ) {
|
||||
/* configure the ads1114 */
|
||||
ads1114_trans.buf[0] = ADS1114_POINTER_CONFIG_REG;
|
||||
ads1114_trans.buf[1] = ADS1114_CONFIG_MSB;
|
||||
ads1114_trans.buf[2] = ADS1114_CONFIG_LSB;
|
||||
I2CTransmit(ADS1114_I2C_DEVICE, ads1114_trans, ADS1114_I2C_ADDR, 3);
|
||||
ads1114_config_done = FALSE;
|
||||
ads1114_data_available = FALSE;
|
||||
/* configure the ads1114_1 */
|
||||
#if USE_ADS1114_1
|
||||
ads1114_1.i2c_addr = ADS1114_1_I2C_ADDR;
|
||||
ads1114_1.trans.buf[0] = ADS1114_POINTER_CONFIG_REG;
|
||||
ads1114_1.trans.buf[1] = ADS1114_1_CONFIG_MSB;
|
||||
ads1114_1.trans.buf[2] = ADS1114_1_CONFIG_LSB;
|
||||
I2CTransmit(ADS1114_I2C_DEVICE, ads1114_1.trans, ADS1114_1_I2C_ADDR, 3);
|
||||
ads1114_1.config_done = FALSE;
|
||||
ads1114_1.data_available = FALSE;
|
||||
#endif
|
||||
|
||||
/* configure the ads1114_2 */
|
||||
#if USE_ADS1114_2
|
||||
ads1114_2.i2c_addr = ADS1114_2_I2C_ADDR;
|
||||
ads1114_2.trans.buf[0] = ADS1114_POINTER_CONFIG_REG;
|
||||
ads1114_2.trans.buf[1] = ADS1114_2_CONFIG_MSB;
|
||||
ads1114_2.trans.buf[2] = ADS1114_2_CONFIG_LSB;
|
||||
I2CTransmit(ADS1114_I2C_DEVICE, ads1114_2.trans, ADS1114_2_I2C_ADDR, 3);
|
||||
ads1114_2.config_done = FALSE;
|
||||
ads1114_2.data_available = FALSE;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void ads1114_read( void ) {
|
||||
void ads1114_read( struct ads1114_periph * p ) {
|
||||
// Config done with success
|
||||
// start new reading when previous is done (and read if success)
|
||||
if (ads1114_config_done && ads1114_trans.status == I2CTransDone) {
|
||||
ads1114_trans.buf[0] = ADS1114_POINTER_CONV_REG;
|
||||
I2CTransceive(ADS1114_I2C_DEVICE, ads1114_trans, ADS1114_I2C_ADDR, 1, 2);
|
||||
if (p->config_done && p->trans.status == I2CTransDone) {
|
||||
p->trans.buf[0] = ADS1114_POINTER_CONV_REG;
|
||||
I2CTransceive(ADS1114_I2C_DEVICE, p->trans, p->i2c_addr, 1, 2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,66 +32,136 @@
|
||||
|
||||
|
||||
/* I2C slave address */
|
||||
#define ADS1114_I2C_ADDR 0x90 // slave address byte (I2c address(7bits) + R/W @ 0)
|
||||
#ifndef ADS1114_1_I2C_ADDR
|
||||
#define ADS1114_1_I2C_ADDR 0x90 // slave address byte (I2c address(7bits) + R/W @ 0)
|
||||
#endif
|
||||
#ifndef ADS1114_2_I2C_ADDR
|
||||
#define ADS1114_2_I2C_ADDR 0x92 // slave address byte (I2c address(7bits) + R/W @ 0)
|
||||
#endif
|
||||
|
||||
/* I2C conf register */
|
||||
#define ADS1114_POINTER_CONV_REG 0x00 // access to the Conversion register (16bits)
|
||||
#define ADS1114_POINTER_CONFIG_REG 0x01 // access to the Configuration register (16bits)
|
||||
|
||||
/* ADS1114 default conf */
|
||||
#ifndef ADS1114_OS
|
||||
#define ADS1114_OS 0x0 // Operational status
|
||||
/* ADS1114_1 default conf */
|
||||
#ifndef ADS1114_1_OS
|
||||
#define ADS1114_1_OS 0x0 // Operational status
|
||||
#endif
|
||||
#ifndef ADS1114_MUX
|
||||
#define ADS1114_MUX 0x0 // Input multiplexer
|
||||
#ifndef ADS1114_1_MUX
|
||||
#define ADS1114_1_MUX 0x0 // Input multiplexer
|
||||
#endif
|
||||
#ifndef ADS1114_PGA
|
||||
#define ADS1114_PGA 0x3 // Programable gain amplifier (= 4 with a Full Scale of +/- 1.024V)
|
||||
#ifndef ADS1114_1_PGA
|
||||
#define ADS1114_1_PGA 0x3 // Programable gain amplifier (= 4 with a Full Scale of +/- 1.024V)
|
||||
#endif
|
||||
#ifndef ADS1114_MODE
|
||||
#define ADS1114_MODE 0x0 // Continuous conversion mode
|
||||
#ifndef ADS1114_1_MODE
|
||||
#define ADS1114_1_MODE 0x0 // Continuous conversion mode
|
||||
#endif
|
||||
#ifndef ADS1114_DR
|
||||
#define ADS1114_DR 0x4 // Data rate (128 SPS)
|
||||
#ifndef ADS1114_1_DR
|
||||
#define ADS1114_1_DR 0x4 // Data rate (128 SPS)
|
||||
#endif
|
||||
#ifndef ADS1114_COMP_MODE
|
||||
#define ADS1114_COMP_MODE 0x0 // Comparator mode
|
||||
#ifndef ADS1114_1_COMP_MODE
|
||||
#define ADS1114_1_COMP_MODE 0x0 // Comparator mode
|
||||
#endif
|
||||
#ifndef ADS1114_COMP_POL
|
||||
#define ADS1114_COMP_POL 0x0 // Comparator polarity
|
||||
#ifndef ADS1114_1_COMP_POL
|
||||
#define ADS1114_1_COMP_POL 0x0 // Comparator polarity
|
||||
#endif
|
||||
#ifndef ADS1114_COMP_LAT
|
||||
#define ADS1114_COMP_LAT 0x0 // Latching comparator
|
||||
#ifndef ADS1114_1_COMP_LAT
|
||||
#define ADS1114_1_COMP_LAT 0x0 // Latching comparator
|
||||
#endif
|
||||
#ifndef ADS1114_COMP_QUE
|
||||
#define ADS1114_COMP_QUE 0x3 // Comparator queue (disable)
|
||||
#ifndef ADS1114_1_COMP_QUE
|
||||
#define ADS1114_1_COMP_QUE 0x3 // Comparator queue (disable)
|
||||
#endif
|
||||
|
||||
#define ADS1114_CONFIG_MSB ((ADS1114_OS<<7)|(ADS1114_MUX<<4)|(ADS1114_PGA<<1)|(ADS1114_MODE))
|
||||
#define ADS1114_CONFIG_LSB ((ADS1114_DR<<5)|(ADS1114_COMP_MODE<<4)|(ADS1114_COMP_POL<<3)|(ADS1114_COMP_LAT<<2)|(ADS1114_COMP_QUE))
|
||||
#define ADS1114_1_CONFIG_MSB ((ADS1114_1_OS<<7)|(ADS1114_1_MUX<<4)|(ADS1114_1_PGA<<1)|(ADS1114_1_MODE))
|
||||
#define ADS1114_1_CONFIG_LSB ((ADS1114_1_DR<<5)|(ADS1114_1_COMP_MODE<<4)|(ADS1114_1_COMP_POL<<3)|(ADS1114_1_COMP_LAT<<2)|(ADS1114_1_COMP_QUE))
|
||||
|
||||
/* ADS1114_1 default conf */
|
||||
#ifndef ADS1114_2_OS
|
||||
#define ADS1114_2_OS 0x0 // Operational status
|
||||
#endif
|
||||
#ifndef ADS1114_2_MUX
|
||||
#define ADS1114_2_MUX 0x0 // Input multiplexer
|
||||
#endif
|
||||
#ifndef ADS1114_2_PGA
|
||||
#define ADS1114_2_PGA 0x3 // Programable gain amplifier (= 4 with a Full Scale of +/- 1.024V)
|
||||
#endif
|
||||
#ifndef ADS1114_2_MODE
|
||||
#define ADS1114_2_MODE 0x0 // Continuous conversion mode
|
||||
#endif
|
||||
#ifndef ADS1114_2_DR
|
||||
#define ADS1114_2_DR 0x4 // Data rate (128 SPS)
|
||||
#endif
|
||||
#ifndef ADS1114_2_COMP_MODE
|
||||
#define ADS1114_2_COMP_MODE 0x0 // Comparator mode
|
||||
#endif
|
||||
#ifndef ADS1114_2_COMP_POL
|
||||
#define ADS1114_2_COMP_POL 0x0 // Comparator polarity
|
||||
#endif
|
||||
#ifndef ADS1114_2_COMP_LAT
|
||||
#define ADS1114_2_COMP_LAT 0x0 // Latching comparator
|
||||
#endif
|
||||
#ifndef ADS1114_2_COMP_QUE
|
||||
#define ADS1114_2_COMP_QUE 0x3 // Comparator queue (disable)
|
||||
#endif
|
||||
|
||||
#define ADS1114_2_CONFIG_MSB ((ADS1114_2_OS<<7)|(ADS1114_2_MUX<<4)|(ADS1114_2_PGA<<1)|(ADS1114_2_MODE))
|
||||
#define ADS1114_2_CONFIG_LSB ((ADS1114_2_DR<<5)|(ADS1114_2_COMP_MODE<<4)|(ADS1114_2_COMP_POL<<3)|(ADS1114_2_COMP_LAT<<2)|(ADS1114_2_COMP_QUE))
|
||||
|
||||
/* Default I2C device */
|
||||
// FIXME all ads on the same device for now
|
||||
#ifndef ADS1114_I2C_DEVICE
|
||||
#define ADS1114_I2C_DEVICE i2c1
|
||||
#endif
|
||||
|
||||
extern struct i2c_transaction ads1114_trans;
|
||||
extern bool_t ads1114_config_done;
|
||||
extern bool_t ads1114_data_available;
|
||||
struct ads1114_periph {
|
||||
struct i2c_transaction trans;
|
||||
uint8_t i2c_addr;
|
||||
bool_t config_done;
|
||||
bool_t data_available;
|
||||
};
|
||||
|
||||
#if USE_ADS1114_1
|
||||
extern struct ads1114_periph ads1114_1;
|
||||
#endif
|
||||
|
||||
#if USE_ADS1114_2
|
||||
extern struct ads1114_periph ads1114_2;
|
||||
#endif
|
||||
|
||||
extern void ads1114_init(void);
|
||||
extern void ads1114_read(void);
|
||||
extern void ads1114_read(struct ads1114_periph * p);
|
||||
|
||||
#define Ads1114Event() { \
|
||||
if (!ads1114_config_done) { \
|
||||
if (ads1114_trans.status == I2CTransSuccess) { ads1114_config_done = TRUE; ads1114_trans.status = I2CTransDone; } \
|
||||
if (ads1114_trans.status == I2CTransFailed) { ads1114_trans.status = I2CTransDone; } \
|
||||
// Generic Event Macro
|
||||
#define _Ads1114Event(_p) {\
|
||||
if (!_p.config_done) { \
|
||||
if (_p.trans.status == I2CTransSuccess) { _p.config_done = TRUE; _p.trans.status = I2CTransDone; } \
|
||||
if (_p.trans.status == I2CTransFailed) { _p.trans.status = I2CTransDone; } \
|
||||
} else { \
|
||||
if (ads1114_trans.status == I2CTransSuccess) { ads1114_data_available = TRUE; ads1114_trans.status = I2CTransDone; } \
|
||||
if (ads1114_trans.status == I2CTransFailed) { ads1114_trans.status = I2CTransDone; } \
|
||||
}\
|
||||
if (_p.trans.status == I2CTransSuccess) { _p.data_available = TRUE; _p.trans.status = I2CTransDone; } \
|
||||
if (_p.trans.status == I2CTransFailed) { _p.trans.status = I2CTransDone; } \
|
||||
} \
|
||||
}
|
||||
|
||||
#define Ads1114GetValue() ((int16_t)(((int16_t)ads1114_trans.buf[0]<<8)|ads1114_trans.buf[1]))
|
||||
#if USE_ADS1114_1
|
||||
#define Ads1114_1Event() _Ads1114Event(ads1114_1)
|
||||
#else
|
||||
#define Ads1114_1Event() {}
|
||||
#endif
|
||||
|
||||
#if USE_ADS1114_2
|
||||
#define Ads1114_2Event() _Ads1114Event(ads1114_2)
|
||||
#else
|
||||
#define Ads1114_2Event() {}
|
||||
#endif
|
||||
|
||||
// Final event macro
|
||||
#define Ads1114Event() { \
|
||||
Ads1114_1Event(); \
|
||||
Ads1114_2Event(); \
|
||||
}
|
||||
|
||||
// Get value macro
|
||||
// @param ads1114 periph
|
||||
#define Ads1114GetValue(_p) ((int16_t)(((int16_t)_p.trans.buf[0]<<8)|_p.trans.buf[1]))
|
||||
|
||||
#endif // ADS_1114_H
|
||||
|
||||
Reference in New Issue
Block a user