common main()

This commit is contained in:
Pascal Brisset
2005-12-15 17:40:32 +00:00
parent 9ac33172e6
commit ff161f2d46
5 changed files with 159 additions and 149 deletions
+1 -1
View File
@@ -450,7 +450,7 @@ WARN_LOGFILE =
# directories like "/usr/src/myproject". Separate the files or directories # directories like "/usr/src/myproject". Separate the files or directories
# with spaces. # with spaces.
INPUT = sw/airborne/autopilot sw/airborne/fly_by_wire var/include var/Twin1 sw/airborne/avr sw/airborne INPUT = var/include var/Twin1 sw/airborne/avr sw/airborne
# If the value of the INPUT tag contains directories, you can use the # If the value of the INPUT tag contains directories, you can use the
# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
+4 -2
View File
@@ -8,7 +8,8 @@ ap.LOW_FUSE = a0
ap.HIGH_FUSE = 99 ap.HIGH_FUSE = 99
ap.EXT_FUSE = ff ap.EXT_FUSE = ff
ap.LOCK_FUSE = ff ap.LOCK_FUSE = ff
ap.srcs = main_ap.c $(SRC_ARCH)/modem.c link_mcu.c $(SRC_ARCH)/link_mcu_ap.c $(SRC_ARCH)/spi_ap.c $(SRC_ARCH)/adc_ap.c gps_ubx.c infrared.c pid.c nav.c $(SRC_ARCH)/uart_ap.c estimator.c if_calib.c mainloop.c cam.c ap.CFLAGS += -DAP
ap.srcs = main.c main_ap.c $(SRC_ARCH)/modem.c link_mcu.c $(SRC_ARCH)/link_mcu_ap.c $(SRC_ARCH)/spi_ap.c $(SRC_ARCH)/adc_ap.c gps_ubx.c infrared.c pid.c nav.c $(SRC_ARCH)/uart_ap.c estimator.c if_calib.c mainloop.c cam.c
fbw.ARCHDIR = $(ARCHI) fbw.ARCHDIR = $(ARCHI)
fbw.ARCH = atmega8 fbw.ARCH = atmega8
@@ -18,4 +19,5 @@ fbw.LOW_FUSE = 2e
fbw.HIGH_FUSE = cb fbw.HIGH_FUSE = cb
fbw.EXT_FUSE = ff fbw.EXT_FUSE = ff
fbw.LOCK_FUSE = ff fbw.LOCK_FUSE = ff
fbw.srcs = main_fbw.c $(SRC_ARCH)/ppm.c $(SRC_ARCH)/servo.c $(SRC_ARCH)/spi_fbw.c $(SRC_ARCH)/uart_fbw.c $(SRC_ARCH)/adc_fbw.c fbw.CFLAGS += -DFBW
fbw.srcs = main.c main_fbw.c $(SRC_ARCH)/ppm.c $(SRC_ARCH)/servo.c $(SRC_ARCH)/spi_fbw.c $(SRC_ARCH)/uart_fbw.c $(SRC_ARCH)/adc_fbw.c
+32
View File
@@ -0,0 +1,32 @@
#ifdef FBW
extern void init_fbw( void );
extern void periodic_task_fbw( void );
extern void event_task_fbw( void );
#define Fbw(f) f ## _fbw()
#else
#define Fbw(f)
#endif
#ifdef AP
extern void init_ap( void );
extern void periodic_task_ap( void );
extern void event_task_ap( void );
#define Ap(f) f ## _ap()
#else
#define Ap(f)
#endif
int main( void ) __attribute__ ((noreturn));
int main( void ) {
Fbw(init);
Ap(init);
while (1) {
Fbw(periodic_task);
Ap(periodic_task);
Fbw(event_task);
Ap(event_task);
}
}
+6 -23
View File
@@ -142,8 +142,7 @@ inline void spi_task(void) {
// for compatibility // for compatibility
#endif #endif
int main( void ) void init_fbw( void ) {
{
{ {
uint8_t foo1 = 25; uint8_t foo1 = 25;
while (foo1--) { while (foo1--) {
@@ -175,8 +174,10 @@ int main( void )
#warning IMU_RESET_ON_BOOT #warning IMU_RESET_ON_BOOT
imu_capture_neutral(); imu_capture_neutral();
#endif #endif
}
while( 1 ) {
void event_task_fbw( void) {
if( ppm_valid ) { if( ppm_valid ) {
ppm_valid = FALSE; ppm_valid = FALSE;
radio_control_task(); radio_control_task();
@@ -209,28 +210,15 @@ int main( void )
failsafe_mode = TRUE; failsafe_mode = TRUE;
command_set(failsafe); command_set(failsafe);
} }
}
if(timer_periodic()) { void periodic_task_fbw( void ) {
static uint8_t _1Hz; static uint8_t _1Hz;
static uint8_t _20Hz; static uint8_t _20Hz;
_1Hz++; _1Hz++;
_20Hz++; _20Hz++;
#if defined IMU_ANALOG #if defined IMU_ANALOG
imu_update(); imu_update();
#if 0
{
static uint8_t foo = 0;
foo++;
if (!(foo%10)) {
uart0_print_hex16(roll_dot);
uart0_transmit(',');
uart0_print_hex16(pitch_dot);
uart0_transmit(',');
uart0_print_hex16(yaw_dot);
uart0_transmit('\n');
}
}
#endif /* 0 */
#endif #endif
#if defined IMU_3DMG || defined IMU_ANALOG #if defined IMU_3DMG || defined IMU_ANALOG
control_run(); control_run();
@@ -259,8 +247,3 @@ int main( void )
if (time_since_last_ppm < REALLY_STALLED_TIME) if (time_since_last_ppm < REALLY_STALLED_TIME)
time_since_last_ppm++; time_since_last_ppm++;
} }
}
return 0;
}
+7 -14
View File
@@ -24,12 +24,8 @@
* \brief Main loop used in the autopilot microcontroler * \brief Main loop used in the autopilot microcontroler
*/ */
#include "std.h"
#include "timer_ap.h" #include "timer_ap.h"
#include "modem.h"
#include "adc_ap.h" #include "adc_ap.h"
#include "airframe.h"
#include "autopilot.h" #include "autopilot.h"
#include "spi_ap.h" #include "spi_ap.h"
#include "link_mcu_ap.h" #include "link_mcu_ap.h"
@@ -38,7 +34,6 @@
#include "infrared.h" #include "infrared.h"
#include "estimator.h" #include "estimator.h"
#include "downlink.h" #include "downlink.h"
#include "uart_ap.h"
#include "datalink.h" #include "datalink.h"
#include "wavecard.h" #include "wavecard.h"
@@ -51,10 +46,7 @@
#endif // AHRS #endif // AHRS
/** \fn int main( void ) void init_ap( void ) {
* \brief Main and @@@@@ unique @@@@@ function \n
*/
int main( void ) {
/** - init peripherals: /** - init peripherals:
* - \a timer * - \a timer
* - \a modem * - \a modem
@@ -113,11 +105,13 @@ int main( void ) {
* - receive radio control task from fbw and use it with * - receive radio control task from fbw and use it with
* \a radio_control_task * \a radio_control_task
*/ */
}
while( 1 ) { void periodic_task_ap( void) {
if(timer_periodic())
/* do periodic task */
periodic_task(); periodic_task();
}
void event_task_ap( void ) {
if (gps_msg_received) { if (gps_msg_received) {
/* parse and use GPS messages */ /* parse and use GPS messages */
parse_gps_msg(); parse_gps_msg();
@@ -185,8 +179,7 @@ int main( void ) {
#endif #endif
} }
} }
return 0;
}