mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-09 22:49:53 +08:00
[mcu] move mcu peripheral event functions to common mcu_event
This commit is contained in:
@@ -692,16 +692,10 @@ void event_task_ap(void)
|
||||
{
|
||||
|
||||
#ifndef SINGLE_MCU
|
||||
#if USE_I2C0 || USE_I2C1 || USE_I2C2 || USE_I2C3
|
||||
i2c_event();
|
||||
#endif
|
||||
|
||||
uart_event();
|
||||
#endif
|
||||
|
||||
#if USE_USB_SERIAL
|
||||
VCOM_event();
|
||||
#endif
|
||||
/* for SINGLE_MCU done in main_fbw */
|
||||
/* event functions for mcu peripherals, like i2c, uart, etc.. */
|
||||
mcu_event();
|
||||
#endif /* SINGLE_MCU */
|
||||
|
||||
#if USE_AHRS && USE_IMU
|
||||
ImuEvent(on_gyro_event, on_accel_event, on_mag_event);
|
||||
|
||||
@@ -193,13 +193,8 @@ void event_task_fbw(void)
|
||||
RadioControlEvent(handle_rc_frame);
|
||||
#endif
|
||||
|
||||
#if USE_I2C0 || USE_I2C1 || USE_I2C2 || USE_I2C3
|
||||
i2c_event();
|
||||
#endif
|
||||
|
||||
#ifndef SITL
|
||||
uart_event();
|
||||
#endif
|
||||
/* event functions for mcu peripherals, like i2c, uart, etc.. */
|
||||
mcu_event();
|
||||
|
||||
#ifdef INTER_MCU
|
||||
#if defined MCU_SPI_LINK | defined MCU_UART_LINK
|
||||
|
||||
@@ -33,11 +33,6 @@
|
||||
#include <inttypes.h>
|
||||
#include "mcu.h"
|
||||
#include "mcu_periph/sys_time.h"
|
||||
#include "mcu_periph/i2c.h"
|
||||
#include "mcu_periph/uart.h"
|
||||
#if USE_UDP
|
||||
#include "mcu_periph/udp.h"
|
||||
#endif
|
||||
#include "led.h"
|
||||
|
||||
#include "subsystems/datalink/telemetry.h"
|
||||
@@ -85,10 +80,6 @@ PRINT_CONFIG_MSG_VALUE("USE_BARO_BOARD is TRUE, reading onboard baro: ", BARO_BO
|
||||
#include "generated/modules.h"
|
||||
#include "subsystems/abi.h"
|
||||
|
||||
#if USE_USB_SERIAL
|
||||
#include "mcu_periph/usb_serial.h"
|
||||
#endif
|
||||
|
||||
/* if PRINT_CONFIG is defined, print some config options */
|
||||
PRINT_CONFIG_VAR(PERIODIC_FREQUENCY)
|
||||
|
||||
@@ -317,20 +308,8 @@ STATIC_INLINE void failsafe_check(void)
|
||||
|
||||
STATIC_INLINE void main_event(void)
|
||||
{
|
||||
|
||||
i2c_event();
|
||||
|
||||
#ifndef SITL
|
||||
uart_event();
|
||||
#endif
|
||||
|
||||
#if USE_UDP
|
||||
udp_event();
|
||||
#endif
|
||||
|
||||
#if USE_USB_SERIAL
|
||||
VCOM_event();
|
||||
#endif
|
||||
/* event functions for mcu peripherals, like i2c, uart, etc.. */
|
||||
mcu_event();
|
||||
|
||||
DatalinkEvent();
|
||||
|
||||
|
||||
@@ -86,11 +86,8 @@ static inline void main_periodic(void)
|
||||
|
||||
static inline void main_event(void)
|
||||
{
|
||||
#if USE_UDP
|
||||
udp_event();
|
||||
#else
|
||||
uart_event();
|
||||
#endif
|
||||
mcu_event();
|
||||
|
||||
DatalinkEvent();
|
||||
}
|
||||
|
||||
|
||||
@@ -39,9 +39,11 @@
|
||||
#endif
|
||||
#endif
|
||||
#if USE_UART0 || USE_UART1 || USE_UART2 || USE_UART3 || USE_UART4 || USE_UART5 || USE_UART6
|
||||
#define USING_UART 1
|
||||
#include "mcu_periph/uart.h"
|
||||
#endif
|
||||
#if USE_I2C0 || USE_I2C1 || USE_I2C2 || USE_I2C3
|
||||
#define USING_I2C 1
|
||||
#include "mcu_periph/i2c.h"
|
||||
#endif
|
||||
#if USE_ADC
|
||||
@@ -172,3 +174,22 @@ void mcu_init(void)
|
||||
#endif /* PERIPHERALS_AUTO_INIT */
|
||||
|
||||
}
|
||||
|
||||
void mcu_event(void)
|
||||
{
|
||||
#if USING_I2C
|
||||
i2c_event();
|
||||
#endif
|
||||
|
||||
#if USING_UART
|
||||
uart_event();
|
||||
#endif
|
||||
|
||||
#if USE_UDP
|
||||
udp_event();
|
||||
#endif
|
||||
|
||||
#if USE_USB_SERIAL
|
||||
VCOM_event();
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -43,6 +43,12 @@
|
||||
*/
|
||||
extern void mcu_init(void);
|
||||
|
||||
/**
|
||||
* MCU event functions.
|
||||
* Calls the event functions of used peripherals like i2c, uart, etc.
|
||||
*/
|
||||
extern void mcu_event(void);
|
||||
|
||||
/** @}*/
|
||||
|
||||
#endif /* MCU_H */
|
||||
|
||||
@@ -60,6 +60,7 @@ static inline void main_periodic_task(void)
|
||||
|
||||
static inline void main_event_task(void)
|
||||
{
|
||||
mcu_event();
|
||||
|
||||
if (uart_char_available(&uart2)) {
|
||||
uart_transmit(&uart1, uart_getch(&uart2));
|
||||
@@ -68,5 +69,4 @@ static inline void main_event_task(void)
|
||||
if (uart_char_available(&uart1)) {
|
||||
uart_transmit(&uart2, uart_getch(&uart1));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -103,5 +103,5 @@ static inline void main_periodic_task(void)
|
||||
|
||||
static inline void main_event_task(void)
|
||||
{
|
||||
|
||||
mcu_event();
|
||||
}
|
||||
|
||||
@@ -71,9 +71,9 @@ static inline void main_periodic_task(void)
|
||||
|
||||
static inline void main_event_task(void)
|
||||
{
|
||||
mcu_event();
|
||||
|
||||
AMI601Event(on_mag);
|
||||
|
||||
}
|
||||
|
||||
static inline void on_mag(void)
|
||||
@@ -82,5 +82,4 @@ static inline void on_mag(void)
|
||||
ami601_status = AMI601_IDLE;
|
||||
struct Int32Vect3 bla = {ami601_values[0], ami601_values[1], ami601_values[2]};
|
||||
DOWNLINK_SEND_IMU_MAG_RAW(DefaultChannel, DefaultDevice, &bla.x, &bla.y, &bla.z);
|
||||
|
||||
}
|
||||
|
||||
@@ -88,6 +88,8 @@ static inline void main_periodic_task(void)
|
||||
|
||||
static inline void main_event_task(void)
|
||||
{
|
||||
mcu_event();
|
||||
|
||||
if (sys_time.nb_sec > 1) {
|
||||
lis302dl_spi_event(&lis302);
|
||||
}
|
||||
|
||||
@@ -71,6 +71,8 @@ static inline void main_periodic_task(void)
|
||||
|
||||
static inline void main_event_task(void)
|
||||
{
|
||||
mcu_event();
|
||||
|
||||
ms2100_event(&ms2100);
|
||||
if (ms2100.status == MS2100_DATA_AVAILABLE) {
|
||||
RunOnceEvery(10, {
|
||||
|
||||
@@ -96,11 +96,7 @@ static inline void main_periodic_task(void)
|
||||
|
||||
static inline void main_event_task(void)
|
||||
{
|
||||
#if USE_UDP
|
||||
udp_event();
|
||||
#else
|
||||
uart_event();
|
||||
#endif
|
||||
mcu_event();
|
||||
ImuEvent(on_gyro_event, on_accel_event, on_mag_event);
|
||||
}
|
||||
|
||||
|
||||
@@ -116,11 +116,7 @@ static inline void main_periodic_task(void)
|
||||
|
||||
static inline void main_event_task(void)
|
||||
{
|
||||
#if USE_UDP
|
||||
udp_event();
|
||||
#else
|
||||
uart_event();
|
||||
#endif
|
||||
mcu_event();
|
||||
ImuEvent(on_gyro_event, on_accel_event, on_mag_event);
|
||||
}
|
||||
|
||||
|
||||
@@ -86,11 +86,7 @@ static inline void main_periodic_task(void)
|
||||
|
||||
static inline void main_event_task(void)
|
||||
{
|
||||
#if USE_UDP
|
||||
udp_event();
|
||||
#else
|
||||
uart_event();
|
||||
#endif
|
||||
mcu_event();
|
||||
RadioControlEvent(main_on_radio_control_frame);
|
||||
}
|
||||
|
||||
|
||||
@@ -88,11 +88,7 @@ static inline void main_periodic(void)
|
||||
|
||||
static inline void main_event(void)
|
||||
{
|
||||
#if USE_UDP
|
||||
udp_event();
|
||||
#else
|
||||
uart_event();
|
||||
#endif
|
||||
mcu_event();
|
||||
DatalinkEvent();
|
||||
}
|
||||
|
||||
|
||||
@@ -104,5 +104,6 @@ static inline void main_periodic_task(void)
|
||||
|
||||
static inline void main_event_task(void)
|
||||
{
|
||||
mcu_event();
|
||||
BaroEvent();
|
||||
}
|
||||
|
||||
@@ -59,6 +59,7 @@ static inline void main_periodic(void)
|
||||
|
||||
static inline void main_event(void)
|
||||
{
|
||||
mcu_event();
|
||||
DatalinkEvent();
|
||||
}
|
||||
|
||||
|
||||
@@ -108,6 +108,7 @@ static inline void main_periodic(void)
|
||||
|
||||
static inline void main_event(void)
|
||||
{
|
||||
mcu_event();
|
||||
DatalinkEvent();
|
||||
RadioControlEvent(on_rc_frame);
|
||||
}
|
||||
|
||||
@@ -65,9 +65,5 @@ static inline void main_periodic(void)
|
||||
|
||||
static inline void main_event(void)
|
||||
{
|
||||
#if USE_UDP
|
||||
udp_event();
|
||||
#else
|
||||
uart_event();
|
||||
#endif
|
||||
mcu_event();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user