mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-06-05 23:49:00 +08:00
big I2C rework - LPC users please don't update for now
This commit is contained in:
@@ -159,56 +159,53 @@
|
|||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
|
||||||
<section name="GUIDANCE_H" prefix="BOOZ2_GUIDANCE_H_">
|
<section name="GUIDANCE_H" prefix="BOOZ2_GUIDANCE_H_">
|
||||||
<define name="PGAIN" value="-100"/>
|
<define name="PGAIN" value="-100"/>
|
||||||
<define name="DGAIN" value="-100"/>
|
<define name="DGAIN" value="-100"/>
|
||||||
<define name="IGAIN" value="-0"/>
|
<define name="IGAIN" value="-0"/>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section name="MISC">
|
<section name="MISC">
|
||||||
<define name="BOOZ2_FACE_REINJ_1" value="1024"/>
|
<define name="BOOZ2_FACE_REINJ_1" value="1024"/>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
|
||||||
<makefile>
|
<firmware name="rotorcraft">
|
||||||
|
<target name="ap" board="lisa_l_1.0">
|
||||||
|
<!-- <define name="BOOZ_START_DELAY" value="1"/> -->
|
||||||
|
<subsystem name="radio_control" type="spektrum"/>
|
||||||
|
<subsystem name="actuators" type="mkk"/>
|
||||||
|
</target>
|
||||||
|
<target name="sim" board="pc">
|
||||||
|
<subsystem name="fdm" type="nps"/>
|
||||||
|
<subsystem name="radio_control" type="ppm"/>
|
||||||
|
<subsystem name="actuators" type="mkk"/>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<subsystem name="imu" type="b2_v1.1"/>
|
||||||
|
<subsystem name="gps" type="ublox"/>
|
||||||
|
<subsystem name="ahrs" type="cmpl"/>
|
||||||
|
</firmware>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
USER =
|
|
||||||
#HOST = 10.31.4.22
|
|
||||||
HOST = overo
|
|
||||||
#HOST = beth
|
|
||||||
TARGET_DIR = ~
|
|
||||||
|
|
||||||
SRC_FMS=fms
|
|
||||||
|
|
||||||
|
|
||||||
ARCH=stm32
|
<firmware name="lisa_l_test_progs">
|
||||||
ARCHI=stm32
|
<target name="test_telemetry" board="lisa_l_1.0"/>
|
||||||
BOARD_CFG=\"boards/lisa_0.99.h\"
|
<target name="test_baro" board="lisa_l_1.0"/>
|
||||||
FLASH_MODE = JTAG
|
<target name="test_imu_b2" board="lisa_l_1.0"/>
|
||||||
|
<target name="test_imu_aspirin" board="lisa_l_1.0"/>
|
||||||
ap.CFLAGS += -DMODEM_BAUD=B57600
|
<target name="test_rc_spektrum" board="lisa_l_1.0"/>
|
||||||
ap.CFLAGS += -DRADIO_CONTROL_SPEKTRUM_MODEL_H=\"radio_control/booz_radio_control_spektrum_dx7se.h\"
|
<target name="test_rc_ppm" board="lisa_l_1.0"/>
|
||||||
|
<target name="test_adc" board="lisa_l_1.0"/>
|
||||||
include $(PAPARAZZI_SRC)/conf/autopilot/booz2_common.makefile
|
<target name="test_hmc5843" board="lisa_l_1.0"/>
|
||||||
include $(CFG_BOOZ)/booz2_autopilot.makefile
|
<target name="test_itg3200" board="lisa_l_1.0"/>
|
||||||
|
<target name="test_adxl345" board="lisa_l_1.0"/>
|
||||||
include $(CFG_BOOZ)/subsystems/booz2_radio_control_spektrum.makefile
|
<target name="test_esc_mkk_simple" board="lisa_l_1.0"/>
|
||||||
include $(CFG_BOOZ)/subsystems/booz2_actuators_mkk.makefile
|
<target name="test_esc_asctecv1_simple" board="lisa_l_1.0"/>
|
||||||
include $(CFG_BOOZ)/subsystems/booz2_imu_b2v1_1.makefile
|
<target name="test_actuators_mkk" board="lisa_l_1.0"/>
|
||||||
#include $(CFG_BOOZ)/subsystems/booz2_gps.makefile
|
<target name="test_actuators_asctecv1" board="lisa_l_1.0"/>
|
||||||
include $(CFG_BOOZ)/subsystems/booz2_ahrs_cmpl.makefile
|
</firmware>
|
||||||
|
|
||||||
|
|
||||||
include $(PAPARAZZI_SRC)/conf/autopilot/lisa_test_progs.makefile
|
|
||||||
|
|
||||||
#
|
|
||||||
#
|
|
||||||
#
|
|
||||||
|
|
||||||
include $(PAPARAZZI_SRC)/conf/autopilot/lisa_passthrough.makefile
|
|
||||||
|
|
||||||
</makefile>
|
|
||||||
|
|
||||||
</airframe>
|
</airframe>
|
||||||
|
|||||||
@@ -211,7 +211,11 @@
|
|||||||
<target name="test_adc" board="lisa_l_1.0"/>
|
<target name="test_adc" board="lisa_l_1.0"/>
|
||||||
<target name="test_hmc5843" board="lisa_l_1.0"/>
|
<target name="test_hmc5843" board="lisa_l_1.0"/>
|
||||||
<target name="test_itg3200" board="lisa_l_1.0"/>
|
<target name="test_itg3200" board="lisa_l_1.0"/>
|
||||||
<target name="test_adxl345" board="lisa_l_1.0"/>
|
<target name="test_adxl345" board="lisa_l_1.0"/>
|
||||||
|
<target name="test_esc_mkk_simple" board="lisa_l_1.0"/>
|
||||||
|
<target name="test_esc_asctecv1_simple" board="lisa_l_1.0"/>
|
||||||
|
<target name="test_actuators_mkk" board="lisa_l_1.0"/>
|
||||||
|
<target name="test_actuators_asctecv1" board="lisa_l_1.0"/>
|
||||||
</firmware>
|
</firmware>
|
||||||
|
|
||||||
<firmware name="lisa_passthrough">
|
<firmware name="lisa_passthrough">
|
||||||
@@ -229,10 +233,5 @@
|
|||||||
<subsystem name="imu" type="b2_v1.1"/>
|
<subsystem name="imu" type="b2_v1.1"/>
|
||||||
</firmware>
|
</firmware>
|
||||||
|
|
||||||
<makefile>
|
|
||||||
|
|
||||||
#include $(PAPARAZZI_SRC)/conf/autopilot/lisa_test_progs.makefile
|
|
||||||
|
|
||||||
</makefile>
|
|
||||||
|
|
||||||
</airframe>
|
</airframe>
|
||||||
|
|||||||
@@ -414,3 +414,106 @@ test_adxl345.CFLAGS += -DUSE_DMA1_C4_IRQ # SPI2 Rx DMA
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# simple test of mikrokopter motor controllers
|
||||||
|
#
|
||||||
|
test_esc_mkk_simple.ARCHDIR = $(ARCHI)
|
||||||
|
test_esc_mkk_simple.TARGET = test_esc_mkk_simple
|
||||||
|
test_esc_mkk_simple.TARGETDIR = test_esc_mkk_simple
|
||||||
|
test_esc_mkk_simple.CFLAGS = -I$(SRC_LISA) -I$(ARCHI) -DPERIPHERALS_AUTO_INIT
|
||||||
|
test_esc_mkk_simple.CFLAGS += -DBOARD_CONFIG=$(BOARD_CFG)
|
||||||
|
test_esc_mkk_simple.srcs = test/test_esc_mkk_simple.c \
|
||||||
|
$(SRC_ARCH)/stm32_exceptions.c \
|
||||||
|
$(SRC_ARCH)/stm32_vector_table.c
|
||||||
|
test_esc_mkk_simple.CFLAGS += -DUSE_LED
|
||||||
|
test_esc_mkk_simple.srcs += $(SRC_ARCH)/led_hw.c
|
||||||
|
test_esc_mkk_simple.CFLAGS += -DUSE_SYS_TIME -DSYS_TIME_LED=1
|
||||||
|
test_esc_mkk_simple.CFLAGS += -DPERIODIC_TASK_PERIOD='SYS_TICS_OF_SEC(1./512.)'
|
||||||
|
test_esc_mkk_simple.srcs += sys_time.c $(SRC_ARCH)/sys_time_hw.c
|
||||||
|
test_esc_mkk_simple.CFLAGS += -DUSE_I2C1
|
||||||
|
test_esc_mkk_simple.srcs += i2c.c $(SRC_ARCH)/i2c_hw.c
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# simple test of asctec v1 motor controllers
|
||||||
|
#
|
||||||
|
test_esc_asctecv1_simple.ARCHDIR = $(ARCHI)
|
||||||
|
test_esc_asctecv1_simple.TARGET = test_esc_asctecv1_simple
|
||||||
|
test_esc_asctecv1_simple.TARGETDIR = test_esc_asctecv1_simple
|
||||||
|
test_esc_asctecv1_simple.CFLAGS = -I$(SRC_LISA) -I$(ARCHI) -DPERIPHERALS_AUTO_INIT
|
||||||
|
test_esc_asctecv1_simple.CFLAGS += -DBOARD_CONFIG=$(BOARD_CFG)
|
||||||
|
test_esc_asctecv1_simple.srcs = test/test_esc_asctecv1_simple.c \
|
||||||
|
$(SRC_ARCH)/stm32_exceptions.c \
|
||||||
|
$(SRC_ARCH)/stm32_vector_table.c
|
||||||
|
test_esc_asctecv1_simple.CFLAGS += -DUSE_LED
|
||||||
|
test_esc_asctecv1_simple.srcs += $(SRC_ARCH)/led_hw.c
|
||||||
|
test_esc_asctecv1_simple.CFLAGS += -DUSE_SYS_TIME -DSYS_TIME_LED=1
|
||||||
|
test_esc_asctecv1_simple.CFLAGS += -DPERIODIC_TASK_PERIOD='SYS_TICS_OF_SEC(1./512.)'
|
||||||
|
test_esc_asctecv1_simple.srcs += sys_time.c $(SRC_ARCH)/sys_time_hw.c
|
||||||
|
test_esc_asctecv1_simple.CFLAGS += -DUSE_I2C1
|
||||||
|
test_esc_asctecv1_simple.srcs += i2c.c $(SRC_ARCH)/i2c_hw.c
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# test actuators mkk
|
||||||
|
#
|
||||||
|
test_actuators_mkk.ARCHDIR = $(ARCHI)
|
||||||
|
test_actuators_mkk.TARGET = test_actuators_mkk
|
||||||
|
test_actuators_mkk.TARGETDIR = test_actuators_mkk
|
||||||
|
test_actuators_mkk.CFLAGS = -I$(SRC_LISA) -I$(ARCHI) -I$(SRC_BOOZ) -I$(SRC_BOOZ_ARCH) -DPERIPHERALS_AUTO_INIT
|
||||||
|
test_actuators_mkk.CFLAGS += -DBOARD_CONFIG=$(BOARD_CFG)
|
||||||
|
test_actuators_mkk.srcs = test/test_actuators.c \
|
||||||
|
$(SRC_ARCH)/stm32_exceptions.c \
|
||||||
|
$(SRC_ARCH)/stm32_vector_table.c
|
||||||
|
|
||||||
|
test_actuators_mkk.CFLAGS += -DUSE_LED
|
||||||
|
test_actuators_mkk.srcs += $(SRC_ARCH)/led_hw.c
|
||||||
|
|
||||||
|
test_actuators_mkk.CFLAGS += -DUSE_SYS_TIME -DSYS_TIME_LED=1
|
||||||
|
test_actuators_mkk.CFLAGS += -DPERIODIC_TASK_PERIOD='SYS_TICS_OF_SEC(1./512.)'
|
||||||
|
test_actuators_mkk.srcs += sys_time.c $(SRC_ARCH)/sys_time_hw.c
|
||||||
|
|
||||||
|
test_actuators_mkk.CFLAGS += -DUSE_UART2 -DUART2_BAUD=B57600
|
||||||
|
test_actuators_mkk.srcs += $(SRC_ARCH)/uart_hw.c
|
||||||
|
|
||||||
|
test_actuators_mkk.CFLAGS += -DDOWNLINK -DDOWNLINK_TRANSPORT=PprzTransport -DDOWNLINK_DEVICE=Uart2
|
||||||
|
test_actuators_mkk.srcs += downlink.c pprz_transport.c
|
||||||
|
|
||||||
|
test_actuators_mkk.srcs += $(SRC_BOOZ)/booz2_commands.c
|
||||||
|
test_actuators_mkk.srcs += $(SRC_BOOZ)/actuators/booz_actuators_mkk.c
|
||||||
|
test_actuators_mkk.CFLAGS += -DACTUATORS_MKK_DEVICE=i2c1
|
||||||
|
test_actuators_mkk.srcs += $(SRC_BOOZ)/actuators/booz_supervision.c
|
||||||
|
test_actuators_mkk.CFLAGS += -DUSE_I2C1
|
||||||
|
test_actuators_mkk.srcs += i2c.c $(SRC_ARCH)/i2c_hw.c
|
||||||
|
|
||||||
|
#
|
||||||
|
# test actuators asctecv1
|
||||||
|
#
|
||||||
|
test_actuators_asctecv1.ARCHDIR = $(ARCHI)
|
||||||
|
test_actuators_asctecv1.TARGET = test_actuators_asctecv1
|
||||||
|
test_actuators_asctecv1.TARGETDIR = test_actuators_asctecv1
|
||||||
|
test_actuators_asctecv1.CFLAGS = -I$(SRC_LISA) -I$(ARCHI) -I$(SRC_BOOZ) -I$(SRC_BOOZ_ARCH) -DPERIPHERALS_AUTO_INIT
|
||||||
|
test_actuators_asctecv1.CFLAGS += -DBOARD_CONFIG=$(BOARD_CFG)
|
||||||
|
test_actuators_asctecv1.srcs = test/test_actuators.c \
|
||||||
|
$(SRC_ARCH)/stm32_exceptions.c \
|
||||||
|
$(SRC_ARCH)/stm32_vector_table.c
|
||||||
|
|
||||||
|
test_actuators_asctecv1.CFLAGS += -DUSE_LED
|
||||||
|
test_actuators_asctecv1.srcs += $(SRC_ARCH)/led_hw.c
|
||||||
|
|
||||||
|
test_actuators_asctecv1.CFLAGS += -DUSE_SYS_TIME -DSYS_TIME_LED=1
|
||||||
|
test_actuators_asctecv1.CFLAGS += -DPERIODIC_TASK_PERIOD='SYS_TICS_OF_SEC(1./512.)'
|
||||||
|
test_actuators_asctecv1.srcs += sys_time.c $(SRC_ARCH)/sys_time_hw.c
|
||||||
|
|
||||||
|
test_actuators_asctecv1.CFLAGS += -DUSE_UART2 -DUART2_BAUD=B57600
|
||||||
|
test_actuators_asctecv1.srcs += $(SRC_ARCH)/uart_hw.c
|
||||||
|
|
||||||
|
test_actuators_asctecv1.CFLAGS += -DDOWNLINK -DDOWNLINK_TRANSPORT=PprzTransport -DDOWNLINK_DEVICE=Uart2
|
||||||
|
test_actuators_asctecv1.srcs += downlink.c pprz_transport.c
|
||||||
|
|
||||||
|
test_actuators_asctecv1.srcs += $(SRC_BOOZ)/booz2_commands.c
|
||||||
|
test_actuators_asctecv1.CFLAGS += -DACTUATORS_ASCTEC_DEVICE=i2c1
|
||||||
|
test_actuators_asctecv1.srcs += $(SRC_BOOZ)/actuators/booz_actuators_asctec.c
|
||||||
|
test_actuators_asctecv1.CFLAGS += -DUSE_I2C1
|
||||||
|
test_actuators_asctecv1.srcs += i2c.c $(SRC_ARCH)/i2c_hw.c
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,6 @@
|
|||||||
#
|
#
|
||||||
ap.srcs += $(SRC_BOOZ)/actuators/booz_supervision.c
|
ap.srcs += $(SRC_BOOZ)/actuators/booz_supervision.c
|
||||||
ap.srcs += $(SRC_BOOZ)/actuators/booz_actuators_mkk.c
|
ap.srcs += $(SRC_BOOZ)/actuators/booz_actuators_mkk.c
|
||||||
ap.srcs += $(SRC_BOOZ_ARCH)/actuators/booz_actuators_mkk_arch.c
|
|
||||||
ap.srcs += i2c.c $(SRC_ARCH)/i2c_hw.c
|
ap.srcs += i2c.c $(SRC_ARCH)/i2c_hw.c
|
||||||
|
|
||||||
ifeq ($(ARCHI), arm7)
|
ifeq ($(ARCHI), arm7)
|
||||||
@@ -36,13 +35,12 @@ ap.CFLAGS += -DUSE_I2C0 -DI2C0_SCLL=150 -DI2C0_SCLH=150 -DI2C0_VIC_SLOT=10
|
|||||||
ap.CFLAGS += -DI2C0_STOP_HANDLER=ActuatorsMkkI2cHandler
|
ap.CFLAGS += -DI2C0_STOP_HANDLER=ActuatorsMkkI2cHandler
|
||||||
ap.CFLAGS += -DI2C0_STOP_HANDLER_HEADER=\"actuators/booz_actuators_mkk.h\"
|
ap.CFLAGS += -DI2C0_STOP_HANDLER_HEADER=\"actuators/booz_actuators_mkk.h\"
|
||||||
else ifeq ($(ARCHI), stm32)
|
else ifeq ($(ARCHI), stm32)
|
||||||
ap.CFLAGS += -DACTUATORS_MKK_DEVICE=i2c1 -DUSE_TIM2_IRQ
|
ap.CFLAGS += -DACTUATORS_MKK_DEVICE=i2c1
|
||||||
ap.CFLAGS += -DUSE_I2C1
|
ap.CFLAGS += -DUSE_I2C1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Simulator
|
# Simulator
|
||||||
sim.srcs += $(SRC_BOOZ)/actuators/booz_supervision.c
|
sim.srcs += $(SRC_BOOZ)/actuators/booz_supervision.c
|
||||||
sim.srcs += $(SRC_BOOZ)/actuators/booz_actuators_mkk.c
|
sim.srcs += $(SRC_BOOZ)/actuators/booz_actuators_mkk.c
|
||||||
sim.srcs += $(SRC_BOOZ_SIM)/actuators/booz_actuators_mkk_arch.c
|
|
||||||
sim.CFLAGS += -DUSE_I2C0 -DI2C0_SCLL=150 -DI2C0_SCLH=150 -DI2C0_VIC_SLOT=10
|
sim.CFLAGS += -DUSE_I2C0 -DI2C0_SCLL=150 -DI2C0_SCLH=150 -DI2C0_VIC_SLOT=10
|
||||||
sim.srcs += i2c.c $(SRC_ARCH)/i2c_hw.c
|
sim.srcs += i2c.c $(SRC_ARCH)/i2c_hw.c
|
||||||
|
|||||||
@@ -1,33 +1,15 @@
|
|||||||
#include "booz_actuators.h"
|
#include "booz/booz_actuators.h"
|
||||||
#include "actuators/booz_actuators_asctec.h"
|
#include "booz/actuators/booz_actuators_asctec.h"
|
||||||
|
|
||||||
#ifdef ACTUATORS_ASCTEC_V2_PROTOCOL
|
#ifdef ACTUATORS_ASCTEC_V2_PROTOCOL
|
||||||
#include "actuators/booz_supervision.h"
|
#include "booz/actuators/booz_supervision.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "booz2_commands.h"
|
#include "booz/booz2_commands.h"
|
||||||
#include "i2c.h"
|
#include "i2c.h"
|
||||||
#include "sys_time.h"
|
#include "sys_time.h"
|
||||||
|
|
||||||
|
|
||||||
#ifndef ACTUATORS_ASCTEC_DEVICE
|
|
||||||
#define ACTUATORS_ASCTEC_DEVICE i2c0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Macros to generate i2cx_buf and i2cx_transmit from
|
|
||||||
* ACTUATORS_ASCTEC_DEVICE
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
#define __Device(dev, _z) dev##_##_z
|
|
||||||
#define _Device(dev, _z) __Device(dev, _z)
|
|
||||||
#define Device( _z) _Device(ACTUATORS_ASCTEC_DEVICE, _z)
|
|
||||||
|
|
||||||
#define DeviceBuf Device(buf)
|
|
||||||
#define DeviceTransmit(_x, _y, _z) Device(transmit(_x, _y, _z))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct ActuatorsAsctec actuators_asctec;
|
struct ActuatorsAsctec actuators_asctec;
|
||||||
|
|
||||||
uint32_t actuators_delay_time;
|
uint32_t actuators_delay_time;
|
||||||
@@ -38,6 +20,13 @@ void actuators_init(void) {
|
|||||||
actuators_asctec.cur_addr = FRONT;
|
actuators_asctec.cur_addr = FRONT;
|
||||||
actuators_asctec.new_addr = FRONT;
|
actuators_asctec.new_addr = FRONT;
|
||||||
actuators_asctec.i2c_trans.status = I2CTransSuccess;
|
actuators_asctec.i2c_trans.status = I2CTransSuccess;
|
||||||
|
actuators_asctec.i2c_trans.type = I2CTransTx;
|
||||||
|
actuators_asctec.i2c_trans.slave_addr = 0x02;
|
||||||
|
#ifdef ACTUATORS_ASCTEC_V2_PROTOCOL
|
||||||
|
actuators_asctec.i2c_trans.len_w = 5;
|
||||||
|
#else
|
||||||
|
actuators_asctec.i2c_trans.len_w = 4;
|
||||||
|
#endif
|
||||||
actuators_asctec.nb_err = 0;
|
actuators_asctec.nb_err = 0;
|
||||||
|
|
||||||
#if defined BOOZ_START_DELAY && ! defined SITL
|
#if defined BOOZ_START_DELAY && ! defined SITL
|
||||||
@@ -117,9 +106,7 @@ void actuators_set(bool_t motors_on) {
|
|||||||
}
|
}
|
||||||
actuators_asctec.cmd = NONE;
|
actuators_asctec.cmd = NONE;
|
||||||
|
|
||||||
i2c_submit(&i2c1,&actuators_asctec.i2c_trans);
|
i2c_submit(&ACTUATORS_ASCTEC_DEVICE, &actuators_asctec.i2c_trans);
|
||||||
// actuators_asctec.i2c_done = FALSE;
|
|
||||||
// DeviceTransmit(0x02, 4, &actuators_asctec.i2c_done);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
#else /* ! ACTUATORS_ASCTEC_V2_PROTOCOL */
|
#else /* ! ACTUATORS_ASCTEC_V2_PROTOCOL */
|
||||||
@@ -141,12 +128,7 @@ void actuators_set(bool_t motors_on) {
|
|||||||
actuators_asctec.i2c_trans.buf[2] + actuators_asctec.i2c_trans.buf[3];
|
actuators_asctec.i2c_trans.buf[2] + actuators_asctec.i2c_trans.buf[3];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
i2c_submit(&i2c1,&actuators_asctec.i2c_trans);
|
i2c_submit(&ACTUATORS_ASCTEC_DEVICE, &actuators_asctec.i2c_trans);
|
||||||
|
|
||||||
// if (actuators_asctec.i2c_done) {
|
|
||||||
//actuators_asctec.i2c_done = FALSE;
|
|
||||||
// DeviceTransmit(0x02, 5, &actuators_asctec.i2c_done);
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif /* ACTUATORS_ASCTEC_V2_PROTOCOL */
|
#endif /* ACTUATORS_ASCTEC_V2_PROTOCOL */
|
||||||
|
|||||||
@@ -21,8 +21,8 @@
|
|||||||
* Boston, MA 02111-1307, USA.
|
* Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "booz_actuators.h"
|
#include "booz/booz_actuators.h"
|
||||||
#include "actuators/booz_actuators_mkk.h"
|
#include "booz/actuators/booz_actuators_mkk.h"
|
||||||
|
|
||||||
#include "booz/booz2_commands.h"
|
#include "booz/booz2_commands.h"
|
||||||
#include "i2c.h"
|
#include "i2c.h"
|
||||||
@@ -31,7 +31,6 @@
|
|||||||
|
|
||||||
struct ActuatorsMkk actuators_mkk;
|
struct ActuatorsMkk actuators_mkk;
|
||||||
|
|
||||||
const uint8_t actuators_addr[ACTUATORS_MKK_NB] = ACTUATORS_MKK_ADDR;
|
|
||||||
|
|
||||||
uint32_t actuators_delay_time;
|
uint32_t actuators_delay_time;
|
||||||
bool_t actuators_delay_done;
|
bool_t actuators_delay_done;
|
||||||
@@ -39,10 +38,14 @@ bool_t actuators_delay_done;
|
|||||||
void actuators_init(void) {
|
void actuators_init(void) {
|
||||||
|
|
||||||
supervision_init();
|
supervision_init();
|
||||||
actuators_mkk.status = IDLE;
|
const uint8_t actuators_addr[ACTUATORS_MKK_NB] = ACTUATORS_MKK_ADDR;
|
||||||
actuators_mkk.i2c_done = TRUE;
|
for (uint8_t i=0; i<ACTUATORS_MKK_NB; i++) {
|
||||||
actuators_mkk.idx = 0;
|
actuators_mkk.trans[i].type = I2CTransTx;
|
||||||
|
actuators_mkk.trans[i].len_w = 1;
|
||||||
|
actuators_mkk.trans[i].slave_addr = actuators_addr[i];
|
||||||
|
actuators_mkk.trans[i].status = I2CTransSuccess;
|
||||||
|
}
|
||||||
|
|
||||||
#if defined BOOZ_START_DELAY && ! defined SITL
|
#if defined BOOZ_START_DELAY && ! defined SITL
|
||||||
actuators_delay_done = FALSE;
|
actuators_delay_done = FALSE;
|
||||||
SysTimeTimerStart(actuators_delay_time);
|
SysTimeTimerStart(actuators_delay_time);
|
||||||
@@ -50,9 +53,7 @@ void actuators_init(void) {
|
|||||||
actuators_delay_done = TRUE;
|
actuators_delay_done = TRUE;
|
||||||
actuators_delay_time = 0;
|
actuators_delay_time = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
booz_actuators_mkk_arch_init();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -65,15 +66,12 @@ void actuators_set(bool_t motors_on) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
supervision_run(motors_on, FALSE, booz2_commands);
|
supervision_run(motors_on, FALSE, booz2_commands);
|
||||||
actuators_mkk.status = BUSY;
|
for (uint8_t i=0; i<ACTUATORS_MKK_NB; i++) {
|
||||||
actuators_mkk.i2c_done = FALSE;
|
|
||||||
actuators_mkk.idx = 0;
|
|
||||||
BoozActuatorsMkkArchSend();
|
|
||||||
#ifdef KILL_MOTORS
|
#ifdef KILL_MOTORS
|
||||||
DeviceBuf[0] = 0;
|
actuators_mkk.trans[i].buf[0] = 0;
|
||||||
#else
|
#else
|
||||||
DeviceBuf[0] = supervision.commands[actuators_mkk.idx];
|
actuators_mkk.trans[i].buf[0] = supervision.commands[i];
|
||||||
#endif
|
#endif
|
||||||
DeviceTransmit(actuators_addr[actuators_mkk.idx], 1, &actuators_mkk.i2c_done);
|
i2c_submit(&ACTUATORS_MKK_DEVICE, &actuators_mkk.trans[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,58 +25,20 @@
|
|||||||
#define BOOZ_ACTUATORS_MKK_H
|
#define BOOZ_ACTUATORS_MKK_H
|
||||||
|
|
||||||
#include "std.h"
|
#include "std.h"
|
||||||
|
#include "i2c.h"
|
||||||
|
|
||||||
#ifndef ACTUATORS_MKK_DEVICE
|
#include "airframe.h"
|
||||||
#define ACTUATORS_MKK_DEVICE i2c0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define __Device(dev, _z) dev##_##_z
|
|
||||||
#define _Device(dev, _z) __Device(dev, _z)
|
|
||||||
#define Device( _z) _Device(ACTUATORS_MKK_DEVICE, _z)
|
|
||||||
|
|
||||||
#define DeviceBuf Device(buf)
|
|
||||||
#define DeviceTransmit(_x, _y, _z) Device(transmit(_x, _y, _z))
|
|
||||||
|
|
||||||
enum actuators_mkk_status {IDLE, BUSY};
|
|
||||||
|
|
||||||
struct ActuatorsMkk {
|
struct ActuatorsMkk {
|
||||||
volatile enum actuators_mkk_status status;
|
struct i2c_transaction trans[ACTUATORS_MKK_NB];
|
||||||
volatile bool_t i2c_done;
|
|
||||||
volatile uint8_t idx;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern struct ActuatorsMkk actuators_mkk;
|
extern struct ActuatorsMkk actuators_mkk;
|
||||||
|
|
||||||
#include "actuators/booz_actuators_mkk_arch.h"
|
|
||||||
/* must be defined by underlying achitecture */
|
|
||||||
extern void booz_actuators_mkk_arch_init(void);
|
|
||||||
|
|
||||||
|
|
||||||
#include "airframe.h"
|
|
||||||
#include "actuators/booz_supervision.h"
|
#include "actuators/booz_supervision.h"
|
||||||
extern const uint8_t actuators_addr[];
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef KILL_MOTORS
|
|
||||||
#define ActuatorsMkkI2cHandler() { \
|
|
||||||
actuators_mkk.idx++; \
|
|
||||||
if (actuators_mkk.idx<ACTUATORS_MKK_NB) { \
|
|
||||||
DeviceBuf[0] = 0; \
|
|
||||||
DeviceTransmit(actuators_addr[actuators_mkk.idx], 1, &actuators_mkk.i2c_done); \
|
|
||||||
} \
|
|
||||||
else \
|
|
||||||
actuators_mkk.status = IDLE; \
|
|
||||||
}
|
|
||||||
#else /* KILL_MOTORS */
|
|
||||||
#define ActuatorsMkkI2cHandler() { \
|
|
||||||
actuators_mkk.idx++; \
|
|
||||||
if (actuators_mkk.idx<ACTUATORS_MKK_NB) { \
|
|
||||||
DeviceBuf[0] = supervision.commands[actuators_mkk.idx]; \
|
|
||||||
DeviceTransmit(actuators_addr[actuators_mkk.idx], 1, &actuators_mkk.i2c_done); \
|
|
||||||
} \
|
|
||||||
else \
|
|
||||||
actuators_mkk.status = IDLE; \
|
|
||||||
}
|
|
||||||
#endif /* KILL_MOTORS */
|
|
||||||
|
|
||||||
#endif /* BOOZ_ACTUATORS_MKK_H */
|
#endif /* BOOZ_ACTUATORS_MKK_H */
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
#include "actuators/booz_actuators_mkk.h"
|
|
||||||
|
|
||||||
void booz_actuators_mkk_arch_init(void) {}
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
#include "actuators/booz_actuators_mkk.h"
|
|
||||||
|
|
||||||
#include "i2c.h"
|
|
||||||
|
|
||||||
#include <stm32/rcc.h>
|
|
||||||
#include <stm32/misc.h>
|
|
||||||
|
|
||||||
void tim2_irq_handler(void);
|
|
||||||
|
|
||||||
/* ---------------------------------------------------------------
|
|
||||||
TIM2 Configuration: Output Compare Timing Mode:
|
|
||||||
TIM2CLK = 36 MHz, Prescaler = 4, TIM2 counter clock = 7.2 MHz
|
|
||||||
*/
|
|
||||||
|
|
||||||
void booz_actuators_mkk_arch_init(void) {
|
|
||||||
|
|
||||||
/* TIM2 clock enable */
|
|
||||||
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);
|
|
||||||
|
|
||||||
/* Time base configuration */
|
|
||||||
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
|
|
||||||
TIM_TimeBaseStructure.TIM_Period = 3072;
|
|
||||||
// TIM_TimeBaseStructure.TIM_Period = 2048;
|
|
||||||
TIM_TimeBaseStructure.TIM_Prescaler = 0;
|
|
||||||
TIM_TimeBaseStructure.TIM_ClockDivision = 0;
|
|
||||||
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
|
|
||||||
TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure);
|
|
||||||
/* Prescaler configuration */
|
|
||||||
TIM_PrescalerConfig(TIM2, 4, TIM_PSCReloadMode_Immediate);
|
|
||||||
|
|
||||||
/* Enable the TIM2 global Interrupt */
|
|
||||||
NVIC_InitTypeDef NVIC_InitStructure;
|
|
||||||
NVIC_InitStructure.NVIC_IRQChannel = TIM2_IRQn;
|
|
||||||
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
|
|
||||||
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3;
|
|
||||||
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
|
|
||||||
NVIC_Init(&NVIC_InitStructure);
|
|
||||||
|
|
||||||
// DEBUG5_INIT();
|
|
||||||
|
|
||||||
TIM_Cmd(TIM2, ENABLE);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void tim2_irq_handler(void) {
|
|
||||||
// DEBUG5_T();
|
|
||||||
|
|
||||||
/* Clear TIM2 update interrupt */
|
|
||||||
TIM_ClearITPendingBit(TIM2, TIM_IT_Update);
|
|
||||||
actuators_mkk.idx++;
|
|
||||||
if (actuators_mkk.idx<ACTUATORS_MKK_NB) {
|
|
||||||
#ifdef KILL_MOTORS
|
|
||||||
DeviceBuf[0] = 0;
|
|
||||||
#else
|
|
||||||
DeviceBuf[0] = supervision.commands[actuators_mkk.idx];
|
|
||||||
#endif
|
|
||||||
DeviceTransmit(actuators_addr[actuators_mkk.idx], 1, &actuators_mkk.i2c_done);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
actuators_mkk.status = IDLE;
|
|
||||||
TIM_ITConfig(TIM2, TIM_IT_Update, DISABLE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+2
-2
@@ -74,8 +74,8 @@ void i2c0_transceive(uint8_t slave_addr, uint8_t len_w, uint16_t len_r, volatile
|
|||||||
struct i2c_periph i2c1;
|
struct i2c_periph i2c1;
|
||||||
|
|
||||||
void i2c1_init(void) {
|
void i2c1_init(void) {
|
||||||
i2c_init(&i2c2);
|
i2c_init(&i2c1);
|
||||||
i2c2_hw_init();
|
i2c1_hw_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* USE_I2C1 */
|
#endif /* USE_I2C1 */
|
||||||
|
|||||||
@@ -78,6 +78,27 @@ struct i2c_errors {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#define I2C_ZERO_EVENTS(_err) { \
|
||||||
|
_err.irq_cnt = 0; \
|
||||||
|
memset((void*)_err.event_chain, 0, sizeof(_err.event_chain)); \
|
||||||
|
memset((void*)_err.status_chain, 0, sizeof(_err.status_chain)); \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define ZEROS_ERR_COUNTER(_i2c_err) { \
|
||||||
|
_i2c_err.ack_fail_cnt = 0; \
|
||||||
|
_i2c_err.miss_start_stop_cnt = 0; \
|
||||||
|
_i2c_err.arb_lost_cnt = 0; \
|
||||||
|
_i2c_err.over_under_cnt = 0; \
|
||||||
|
_i2c_err.pec_recep_cnt = 0; \
|
||||||
|
_i2c_err.timeout_tlow_cnt = 0; \
|
||||||
|
_i2c_err.smbus_alert_cnt = 0; \
|
||||||
|
_i2c_err.unexpected_event_cnt = 0; \
|
||||||
|
_i2c_err.last_unexpected_event = 0; \
|
||||||
|
_i2c_err.er_irq_cnt = 0; \
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef USE_I2C0
|
#ifdef USE_I2C0
|
||||||
|
|
||||||
extern void i2c0_init(void);
|
extern void i2c0_init(void);
|
||||||
|
|||||||
+10
-22
@@ -5,18 +5,6 @@
|
|||||||
#include <stm32/flash.h>
|
#include <stm32/flash.h>
|
||||||
#include <stm32/misc.h>
|
#include <stm32/misc.h>
|
||||||
|
|
||||||
#define ZEROS_ERR_COUNTER(_i2c_err) { \
|
|
||||||
_i2c_err.ack_fail_cnt = 0; \
|
|
||||||
_i2c_err.miss_start_stop_cnt = 0; \
|
|
||||||
_i2c_err.arb_lost_cnt = 0; \
|
|
||||||
_i2c_err.over_under_cnt = 0; \
|
|
||||||
_i2c_err.pec_recep_cnt = 0; \
|
|
||||||
_i2c_err.timeout_tlow_cnt = 0; \
|
|
||||||
_i2c_err.smbus_alert_cnt = 0; \
|
|
||||||
_i2c_err.unexpected_event_cnt = 0; \
|
|
||||||
_i2c_err.last_unexpected_event = 0; \
|
|
||||||
_i2c_err.er_irq_cnt = 0; \
|
|
||||||
}
|
|
||||||
|
|
||||||
static void start_transaction(struct i2c_periph* p);
|
static void start_transaction(struct i2c_periph* p);
|
||||||
|
|
||||||
@@ -52,8 +40,8 @@ struct i2c_errors i2c1_errors;
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define I2C1_ABORT_AND_RESET() { \
|
#define I2C1_ABORT_AND_RESET() { \
|
||||||
struct i2c_transaction* trans = i2c1.trans[i2c1.trans_extract_idx]; \
|
struct i2c_transaction* trans2 = i2c1.trans[i2c1.trans_extract_idx]; \
|
||||||
trans->status = I2CTransFailed; \
|
trans2->status = I2CTransFailed; \
|
||||||
i2c1.status = I2CFailed; \
|
i2c1.status = I2CFailed; \
|
||||||
I2C_ITConfig(I2C1, I2C_IT_EVT | I2C_IT_BUF | I2C_IT_ERR, DISABLE); \
|
I2C_ITConfig(I2C1, I2C_IT_EVT | I2C_IT_BUF | I2C_IT_ERR, DISABLE); \
|
||||||
I2C_Cmd(I2C1, DISABLE); \
|
I2C_Cmd(I2C1, DISABLE); \
|
||||||
@@ -130,7 +118,7 @@ void i2c1_hw_init(void) {
|
|||||||
void i2c1_ev_irq_handler(void) {
|
void i2c1_ev_irq_handler(void) {
|
||||||
|
|
||||||
uint32_t event = I2C_GetLastEvent(I2C1);
|
uint32_t event = I2C_GetLastEvent(I2C1);
|
||||||
struct i2c_transaction* trans = i2c2.trans[i2c2.trans_extract_idx];
|
struct i2c_transaction* trans = i2c1.trans[i2c1.trans_extract_idx];
|
||||||
switch (event) {
|
switch (event) {
|
||||||
/* EV5 */
|
/* EV5 */
|
||||||
case I2C_EVENT_MASTER_MODE_SELECT:
|
case I2C_EVENT_MASTER_MODE_SELECT:
|
||||||
@@ -321,7 +309,7 @@ void i2c2_hw_init(void) {
|
|||||||
I2C_ITConfig(I2C2, I2C_IT_ERR, ENABLE);
|
I2C_ITConfig(I2C2, I2C_IT_ERR, ENABLE);
|
||||||
|
|
||||||
// DEBUG_SERVO1_INIT();
|
// DEBUG_SERVO1_INIT();
|
||||||
DEBUG_SERVO2_INIT();
|
// DEBUG_SERVO2_INIT();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -590,14 +578,14 @@ static inline void on_status_restart_requested(struct i2c_transaction* trans, ui
|
|||||||
}
|
}
|
||||||
|
|
||||||
void i2c2_ev_irq_handler(void) {
|
void i2c2_ev_irq_handler(void) {
|
||||||
DEBUG_S4_ON();
|
// DEBUG_S4_ON();
|
||||||
uint32_t event = I2C_GetLastEvent(I2C2);
|
uint32_t event = I2C_GetLastEvent(I2C2);
|
||||||
struct i2c_transaction* trans = i2c2.trans[i2c2.trans_extract_idx];
|
struct i2c_transaction* trans = i2c2.trans[i2c2.trans_extract_idx];
|
||||||
//#if 0
|
//#if 0
|
||||||
// if (i2c2_errors.irq_cnt < 16) {
|
// if (i2c2_errors.irq_cnt < 16) {
|
||||||
i2c2_errors.event_chain[i2c2_errors.irq_cnt] = event;
|
// i2c2_errors.event_chain[i2c2_errors.irq_cnt] = event;
|
||||||
i2c2_errors.status_chain[i2c2_errors.irq_cnt] = i2c2.status;
|
// i2c2_errors.status_chain[i2c2_errors.irq_cnt] = i2c2.status;
|
||||||
i2c2_errors.irq_cnt++;
|
// i2c2_errors.irq_cnt++;
|
||||||
// } else { while (1);}
|
// } else { while (1);}
|
||||||
//#endif
|
//#endif
|
||||||
switch (i2c2.status) {
|
switch (i2c2.status) {
|
||||||
@@ -646,7 +634,7 @@ void i2c2_ev_irq_handler(void) {
|
|||||||
OUT_OF_SYNC_STATE_MACHINE(i2c2.status, event);
|
OUT_OF_SYNC_STATE_MACHINE(i2c2.status, event);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
DEBUG_S4_OFF();
|
// DEBUG_S4_OFF();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -725,7 +713,7 @@ bool_t i2c_submit(struct i2c_periph* p, struct i2c_transaction* t) {
|
|||||||
static void start_transaction(struct i2c_periph* p) {
|
static void start_transaction(struct i2c_periph* p) {
|
||||||
p->idx_buf = 0;
|
p->idx_buf = 0;
|
||||||
p->status = I2CStartRequested;
|
p->status = I2CStartRequested;
|
||||||
I2C_ZERO_EVENTS();
|
// I2C_ZERO_EVENTS();
|
||||||
I2C_ITConfig(p->reg_addr, I2C_IT_EVT, ENABLE);
|
I2C_ITConfig(p->reg_addr, I2C_IT_EVT, ENABLE);
|
||||||
I2C_GenerateSTART(p->reg_addr, ENABLE);
|
I2C_GenerateSTART(p->reg_addr, ENABLE);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,12 +52,6 @@ extern void i2c2_hw_init(void);
|
|||||||
extern void i2c2_ev_irq_handler(void);
|
extern void i2c2_ev_irq_handler(void);
|
||||||
extern void i2c2_er_irq_handler(void);
|
extern void i2c2_er_irq_handler(void);
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#define I2C_ZERO_EVENTS() { \
|
|
||||||
i2c2_errors.irq_cnt = 0; \
|
|
||||||
memset((void*)i2c2_errors.event_chain, 0, sizeof(i2c2_errors.event_chain)); \
|
|
||||||
memset((void*)i2c2_errors.status_chain, 0, sizeof(i2c2_errors.status_chain)); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* USE_I2C2 */
|
#endif /* USE_I2C2 */
|
||||||
|
|
||||||
|
|||||||
+49
-4
@@ -21,9 +21,54 @@
|
|||||||
* Boston, MA 02111-1307, USA.
|
* Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef BOOZ_ACTUATORS_MKK_ARCH_H
|
|
||||||
#define BOOZ_ACTUATORS_MKK_ARCH_H
|
|
||||||
|
|
||||||
#define BoozActuatorsMkkArchSend() {}
|
#include "init_hw.h"
|
||||||
|
#include "sys_time.h"
|
||||||
|
#include "led.h"
|
||||||
|
|
||||||
#endif /* BOOZ_ACTUATORS_MKK_ARCH_H */
|
#include "i2c.h"
|
||||||
|
#include "booz/booz2_commands.h"
|
||||||
|
#include "booz/booz_actuators.h"
|
||||||
|
|
||||||
|
static inline void main_init( void );
|
||||||
|
static inline void main_periodic_task( void );
|
||||||
|
static inline void main_event_task( void );
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
main_init();
|
||||||
|
|
||||||
|
while(1) {
|
||||||
|
if (sys_time_periodic())
|
||||||
|
main_periodic_task();
|
||||||
|
main_event_task();
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void main_init( void ) {
|
||||||
|
hw_init();
|
||||||
|
sys_time_init();
|
||||||
|
actuators_init();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static inline void main_periodic_task( void ) {
|
||||||
|
|
||||||
|
booz2_commands[COMMAND_ROLL]=0;
|
||||||
|
booz2_commands[COMMAND_PITCH]=0;
|
||||||
|
booz2_commands[COMMAND_YAW]=0;
|
||||||
|
booz2_commands[COMMAND_THRUST]=1;
|
||||||
|
|
||||||
|
actuators_set(TRUE);
|
||||||
|
|
||||||
|
LED_PERIODIC();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static inline void main_event_task( void ) {
|
||||||
|
|
||||||
|
}
|
||||||
+45
-10
@@ -21,20 +21,55 @@
|
|||||||
* Boston, MA 02111-1307, USA.
|
* Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef BOOZ_ACTUATORS_MKK_ARCH_H
|
|
||||||
#define BOOZ_ACTUATORS_MKK_ARCH_H
|
|
||||||
|
|
||||||
#include <stm32/tim.h>
|
#include "init_hw.h"
|
||||||
#include <stm32/gpio.h>
|
#include "sys_time.h"
|
||||||
|
#include "led.h"
|
||||||
|
|
||||||
|
#include "i2c.h"
|
||||||
|
|
||||||
|
static inline void main_init( void );
|
||||||
|
static inline void main_periodic_task( void );
|
||||||
|
static inline void main_event_task( void );
|
||||||
|
|
||||||
|
static struct i2c_transaction trans;
|
||||||
|
|
||||||
#define BoozActuatorsMkkArchSend() { \
|
int main(void) {
|
||||||
/*DEBUG5_T();*/ \
|
main_init();
|
||||||
TIM_SetCounter(TIM2, 0); \
|
|
||||||
TIM_ClearITPendingBit(TIM2, TIM_IT_Update); \
|
while(1) {
|
||||||
TIM_ITConfig(TIM2, TIM_IT_Update, ENABLE); \
|
if (sys_time_periodic())
|
||||||
|
main_periodic_task();
|
||||||
|
main_event_task();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* BOOZ_ACTUATORS_MKK_ARCH_H */
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void main_init( void ) {
|
||||||
|
hw_init();
|
||||||
|
sys_time_init();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static inline void main_periodic_task( void ) {
|
||||||
|
|
||||||
|
trans.type = I2CTransTx;
|
||||||
|
trans.slave_addr = 0x02;
|
||||||
|
trans.len_w = 4;
|
||||||
|
trans.buf[0] = 100;
|
||||||
|
trans.buf[1] = 100;
|
||||||
|
trans.buf[2] = 100;
|
||||||
|
trans.buf[3] = 1;
|
||||||
|
i2c_submit(&i2c1,&trans);
|
||||||
|
|
||||||
|
LED_PERIODIC();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static inline void main_event_task( void ) {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -26,11 +26,13 @@
|
|||||||
#include "sys_time.h"
|
#include "sys_time.h"
|
||||||
#include "led.h"
|
#include "led.h"
|
||||||
|
|
||||||
|
#include "i2c.h"
|
||||||
|
|
||||||
static inline void main_init( void );
|
static inline void main_init( void );
|
||||||
static inline void main_periodic_task( void );
|
static inline void main_periodic_task( void );
|
||||||
static inline void main_event_task( void );
|
static inline void main_event_task( void );
|
||||||
|
|
||||||
static uint8_t i2c_done;
|
static struct i2c_transaction trans;
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
main_init();
|
main_init();
|
||||||
@@ -53,8 +55,11 @@ static inline void main_init( void ) {
|
|||||||
|
|
||||||
static inline void main_periodic_task( void ) {
|
static inline void main_periodic_task( void ) {
|
||||||
|
|
||||||
i2c1_buf[0] = 0x04;
|
trans.type = I2CTransTx;
|
||||||
i2c1_transmit(0x58, 1, &i2c_done);
|
trans.buf[0] = 0x04;
|
||||||
|
trans.len_w = 1;
|
||||||
|
trans.slave_addr = 0x58;
|
||||||
|
i2c_submit(&i2c1,&trans);
|
||||||
|
|
||||||
LED_PERIODIC();
|
LED_PERIODIC();
|
||||||
|
|
||||||
Reference in New Issue
Block a user