[mcu] move mcu peripheral event functions to common mcu_event

This commit is contained in:
Felix Ruess
2015-03-05 16:10:17 +01:00
parent 9d89856145
commit 0f014a2562
19 changed files with 52 additions and 74 deletions
+4 -10
View File
@@ -692,16 +692,10 @@ void event_task_ap(void)
{ {
#ifndef SINGLE_MCU #ifndef SINGLE_MCU
#if USE_I2C0 || USE_I2C1 || USE_I2C2 || USE_I2C3 /* for SINGLE_MCU done in main_fbw */
i2c_event(); /* event functions for mcu peripherals, like i2c, uart, etc.. */
#endif mcu_event();
#endif /* SINGLE_MCU */
uart_event();
#endif
#if USE_USB_SERIAL
VCOM_event();
#endif
#if USE_AHRS && USE_IMU #if USE_AHRS && USE_IMU
ImuEvent(on_gyro_event, on_accel_event, on_mag_event); ImuEvent(on_gyro_event, on_accel_event, on_mag_event);
+2 -7
View File
@@ -193,13 +193,8 @@ void event_task_fbw(void)
RadioControlEvent(handle_rc_frame); RadioControlEvent(handle_rc_frame);
#endif #endif
#if USE_I2C0 || USE_I2C1 || USE_I2C2 || USE_I2C3 /* event functions for mcu peripherals, like i2c, uart, etc.. */
i2c_event(); mcu_event();
#endif
#ifndef SITL
uart_event();
#endif
#ifdef INTER_MCU #ifdef INTER_MCU
#if defined MCU_SPI_LINK | defined MCU_UART_LINK #if defined MCU_SPI_LINK | defined MCU_UART_LINK
+2 -23
View File
@@ -33,11 +33,6 @@
#include <inttypes.h> #include <inttypes.h>
#include "mcu.h" #include "mcu.h"
#include "mcu_periph/sys_time.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 "led.h"
#include "subsystems/datalink/telemetry.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 "generated/modules.h"
#include "subsystems/abi.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 */ /* if PRINT_CONFIG is defined, print some config options */
PRINT_CONFIG_VAR(PERIODIC_FREQUENCY) PRINT_CONFIG_VAR(PERIODIC_FREQUENCY)
@@ -317,20 +308,8 @@ STATIC_INLINE void failsafe_check(void)
STATIC_INLINE void main_event(void) STATIC_INLINE void main_event(void)
{ {
/* event functions for mcu peripherals, like i2c, uart, etc.. */
i2c_event(); mcu_event();
#ifndef SITL
uart_event();
#endif
#if USE_UDP
udp_event();
#endif
#if USE_USB_SERIAL
VCOM_event();
#endif
DatalinkEvent(); DatalinkEvent();
@@ -86,11 +86,8 @@ static inline void main_periodic(void)
static inline void main_event(void) static inline void main_event(void)
{ {
#if USE_UDP mcu_event();
udp_event();
#else
uart_event();
#endif
DatalinkEvent(); DatalinkEvent();
} }
+21
View File
@@ -39,9 +39,11 @@
#endif #endif
#endif #endif
#if USE_UART0 || USE_UART1 || USE_UART2 || USE_UART3 || USE_UART4 || USE_UART5 || USE_UART6 #if USE_UART0 || USE_UART1 || USE_UART2 || USE_UART3 || USE_UART4 || USE_UART5 || USE_UART6
#define USING_UART 1
#include "mcu_periph/uart.h" #include "mcu_periph/uart.h"
#endif #endif
#if USE_I2C0 || USE_I2C1 || USE_I2C2 || USE_I2C3 #if USE_I2C0 || USE_I2C1 || USE_I2C2 || USE_I2C3
#define USING_I2C 1
#include "mcu_periph/i2c.h" #include "mcu_periph/i2c.h"
#endif #endif
#if USE_ADC #if USE_ADC
@@ -172,3 +174,22 @@ void mcu_init(void)
#endif /* PERIPHERALS_AUTO_INIT */ #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
}
+6
View File
@@ -43,6 +43,12 @@
*/ */
extern void mcu_init(void); 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 */ #endif /* MCU_H */
+1 -1
View File
@@ -60,6 +60,7 @@ static inline void main_periodic_task(void)
static inline void main_event_task(void) static inline void main_event_task(void)
{ {
mcu_event();
if (uart_char_available(&uart2)) { if (uart_char_available(&uart2)) {
uart_transmit(&uart1, uart_getch(&uart2)); uart_transmit(&uart1, uart_getch(&uart2));
@@ -68,5 +69,4 @@ static inline void main_event_task(void)
if (uart_char_available(&uart1)) { if (uart_char_available(&uart1)) {
uart_transmit(&uart2, uart_getch(&uart1)); uart_transmit(&uart2, uart_getch(&uart1));
} }
} }
+1 -1
View File
@@ -103,5 +103,5 @@ static inline void main_periodic_task(void)
static inline void main_event_task(void) static inline void main_event_task(void)
{ {
mcu_event();
} }
+1 -2
View File
@@ -71,9 +71,9 @@ static inline void main_periodic_task(void)
static inline void main_event_task(void) static inline void main_event_task(void)
{ {
mcu_event();
AMI601Event(on_mag); AMI601Event(on_mag);
} }
static inline void on_mag(void) static inline void on_mag(void)
@@ -82,5 +82,4 @@ static inline void on_mag(void)
ami601_status = AMI601_IDLE; ami601_status = AMI601_IDLE;
struct Int32Vect3 bla = {ami601_values[0], ami601_values[1], ami601_values[2]}; 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); 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) static inline void main_event_task(void)
{ {
mcu_event();
if (sys_time.nb_sec > 1) { if (sys_time.nb_sec > 1) {
lis302dl_spi_event(&lis302); lis302dl_spi_event(&lis302);
} }
@@ -71,6 +71,8 @@ static inline void main_periodic_task(void)
static inline void main_event_task(void) static inline void main_event_task(void)
{ {
mcu_event();
ms2100_event(&ms2100); ms2100_event(&ms2100);
if (ms2100.status == MS2100_DATA_AVAILABLE) { if (ms2100.status == MS2100_DATA_AVAILABLE) {
RunOnceEvery(10, { RunOnceEvery(10, {
+1 -5
View File
@@ -96,11 +96,7 @@ static inline void main_periodic_task(void)
static inline void main_event_task(void) static inline void main_event_task(void)
{ {
#if USE_UDP mcu_event();
udp_event();
#else
uart_event();
#endif
ImuEvent(on_gyro_event, on_accel_event, on_mag_event); ImuEvent(on_gyro_event, on_accel_event, on_mag_event);
} }
+1 -5
View File
@@ -116,11 +116,7 @@ static inline void main_periodic_task(void)
static inline void main_event_task(void) static inline void main_event_task(void)
{ {
#if USE_UDP mcu_event();
udp_event();
#else
uart_event();
#endif
ImuEvent(on_gyro_event, on_accel_event, on_mag_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) static inline void main_event_task(void)
{ {
#if USE_UDP mcu_event();
udp_event();
#else
uart_event();
#endif
RadioControlEvent(main_on_radio_control_frame); RadioControlEvent(main_on_radio_control_frame);
} }
+1 -5
View File
@@ -88,11 +88,7 @@ static inline void main_periodic(void)
static inline void main_event(void) static inline void main_event(void)
{ {
#if USE_UDP mcu_event();
udp_event();
#else
uart_event();
#endif
DatalinkEvent(); DatalinkEvent();
} }
+1
View File
@@ -104,5 +104,6 @@ static inline void main_periodic_task(void)
static inline void main_event_task(void) static inline void main_event_task(void)
{ {
mcu_event();
BaroEvent(); BaroEvent();
} }
+1
View File
@@ -59,6 +59,7 @@ static inline void main_periodic(void)
static inline void main_event(void) static inline void main_event(void)
{ {
mcu_event();
DatalinkEvent(); DatalinkEvent();
} }
+1
View File
@@ -108,6 +108,7 @@ static inline void main_periodic(void)
static inline void main_event(void) static inline void main_event(void)
{ {
mcu_event();
DatalinkEvent(); DatalinkEvent();
RadioControlEvent(on_rc_frame); RadioControlEvent(on_rc_frame);
} }
+1 -5
View File
@@ -65,9 +65,5 @@ static inline void main_periodic(void)
static inline void main_event(void) static inline void main_event(void)
{ {
#if USE_UDP mcu_event();
udp_event();
#else
uart_event();
#endif
} }