mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-27 17:06:31 +08:00
*** empty log message ***
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
<airframe name="DEMO">
|
||||
|
||||
<makefile>
|
||||
|
||||
ARCHI=arm7
|
||||
|
||||
FLASH_MODE = IAP
|
||||
|
||||
|
||||
WIND_TUNNEL=wind_tunnel
|
||||
|
||||
#
|
||||
# DOWNLINK : send formated messages according to messages.xml description
|
||||
# requires "link" to run on the other side of the serial link
|
||||
#
|
||||
ap.ARCHDIR = $(ARCHI)
|
||||
ap.ARCH = arm7tdmi
|
||||
ap.TARGET = ap
|
||||
ap.TARGETDIR = ap
|
||||
|
||||
ap.CFLAGS += -DCONFIG=\"conf_demo.h\" -I$(WIND_TUNNEL)
|
||||
ap.srcs = $(WIND_TUNNEL)/main.c
|
||||
|
||||
ap.CFLAGS += -DPERIODIC_TASK_PERIOD='SYS_TICS_OF_SEC(1e-1)'
|
||||
ap.srcs += sys_time.c $(SRC_ARCH)/sys_time_hw.c
|
||||
|
||||
ap.CFLAGS += -DLED
|
||||
|
||||
ap.srcs += $(SRC_ARCH)/armVIC.c
|
||||
|
||||
ap.CFLAGS += -DUSE_UART0 -DUART0_BAUD=B38400
|
||||
ap.srcs += $(SRC_ARCH)/uart_hw.c
|
||||
|
||||
ap.CFLAGS += -DDOWNLINK -DDOWNLINK_TRANSPORT=PprzTransport -DDOWNLINK_DEVICE=Uart0
|
||||
ap.srcs += downlink.c pprz_transport.c
|
||||
|
||||
ap.CFLAGS += -DDATALINK=PPRZ -DPPRZ_UART=Uart0
|
||||
#ap.srcs += $(BOOZ)/booz_datalink.c
|
||||
|
||||
ap.srcs += $(WIND_TUNNEL)/wt_servo.c
|
||||
|
||||
|
||||
</makefile>
|
||||
|
||||
</airframe>
|
||||
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE settings SYSTEM "settings.dtd">
|
||||
|
||||
<settings>
|
||||
<dl_settings>
|
||||
|
||||
<dl_settings NAME="Misc">
|
||||
</dl_settings>
|
||||
|
||||
</dl_settings>
|
||||
</settings>
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE telemetry SYSTEM "telemetry.dtd">
|
||||
<telemetry>
|
||||
|
||||
|
||||
<process name="Main">
|
||||
|
||||
<mode name="default">
|
||||
</mode>
|
||||
|
||||
</process>
|
||||
|
||||
</telemetry>
|
||||
@@ -0,0 +1,84 @@
|
||||
#include "std.h"
|
||||
#include "init_hw.h"
|
||||
#include "sys_time.h"
|
||||
#include "led.h"
|
||||
#include "interrupt_hw.h"
|
||||
#include "uart.h"
|
||||
|
||||
#include "messages.h"
|
||||
#include "downlink.h"
|
||||
|
||||
#include "datalink.h"
|
||||
#include "settings.h"
|
||||
#include "dl_protocol.h"
|
||||
|
||||
#include "wt_servo.h"
|
||||
|
||||
|
||||
static inline void main_init( void );
|
||||
static inline void main_periodic_task( void );
|
||||
static inline void main_event_task( void );
|
||||
|
||||
|
||||
uint16_t motor_power;
|
||||
uint8_t dl_buffer[MSG_SIZE] __attribute__ ((aligned));
|
||||
bool_t dl_msg_available;
|
||||
uint16_t datalink_time;
|
||||
|
||||
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();
|
||||
led_init();
|
||||
uart0_init_tx();
|
||||
|
||||
motor_power = 0;
|
||||
wt_servo_init();
|
||||
wt_servo_set(500);
|
||||
|
||||
int_enable();
|
||||
}
|
||||
|
||||
static inline void main_periodic_task( void ) {
|
||||
// LED_TOGGLE(1);
|
||||
DOWNLINK_SEND_TAKEOFF(&motor_power);
|
||||
}
|
||||
|
||||
static inline void main_event_task( void ) {
|
||||
DatalinkEvent();
|
||||
}
|
||||
|
||||
|
||||
#define IdOfMsg(x) (x[1])
|
||||
|
||||
void dl_parse_msg(void) {
|
||||
|
||||
LED_TOGGLE(1);
|
||||
|
||||
uint8_t msg_id = IdOfMsg(dl_buffer);
|
||||
switch (msg_id) {
|
||||
|
||||
case DL_PING: {
|
||||
DOWNLINK_SEND_PONG();
|
||||
break;
|
||||
}
|
||||
|
||||
case DL_SETTING : {
|
||||
uint8_t i = DL_SETTING_index(dl_buffer);
|
||||
float var = DL_SETTING_value(dl_buffer);
|
||||
DlSetting(i, var);
|
||||
DOWNLINK_SEND_DL_VALUE(&i, &var);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
#include "wt_servo.h"
|
||||
|
||||
#include "LPC21xx.h"
|
||||
|
||||
#include "sys_time.h"
|
||||
|
||||
uint16_t wt_servo_motor_power;
|
||||
|
||||
#define MY_NB_CLOCK_TIMER_PWM(time_us) SYS_TICS_OF_USEC(time_us)
|
||||
|
||||
void mb_servo_set_ns(uint32_t duration_ns);
|
||||
|
||||
void wt_servo_init(void) {
|
||||
|
||||
/* set P0.21 as PWM5 output */
|
||||
PINSEL1 |= (0X01 << 10);
|
||||
/* enable and select the type of PWM channel */
|
||||
PWMPCR |= PWMPCR_ENA5;
|
||||
/* set Match0 value (refresh rate) */
|
||||
PWMMR0 = MY_NB_CLOCK_TIMER_PWM(20000);
|
||||
/* commit PWMMRx changes */
|
||||
PWMLER = PWMLER_LATCH0;
|
||||
/* enable PWM timer in PWM mode */
|
||||
PWMTCR = PWMTCR_COUNTER_ENABLE | PWMTCR_PWM_ENABLE;
|
||||
|
||||
}
|
||||
|
||||
#define MB_SERVO_MIN_PULSE_NS 1000000
|
||||
#define MB_SERVO_RANGE_PULSE_NS 1000
|
||||
|
||||
void wt_servo_set(uint16_t val) {
|
||||
|
||||
uint32_t pulse_ns = MB_SERVO_MIN_PULSE_NS + val*MB_SERVO_RANGE_PULSE_NS;
|
||||
mb_servo_set_ns(pulse_ns);
|
||||
|
||||
}
|
||||
|
||||
void mb_servo_set_ns(uint32_t duration_ns) {
|
||||
/* set Match5 value (pulse duration )*/
|
||||
PWMMR5 = SYS_TICS_OF_NSEC(duration_ns);
|
||||
/* commit PWMMRx changes */
|
||||
PWMLER = PWMLER_LATCH5;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
#ifndef WT_SERVO_H
|
||||
#define WT_SERVO_H
|
||||
|
||||
#include "std.h"
|
||||
|
||||
extern void wt_servo_init(void);
|
||||
extern void wt_servo_set(uint16_t val);
|
||||
|
||||
extern uint16_t wt_servo_motor_power;
|
||||
|
||||
#define wt_servo_SetPower(_val) { \
|
||||
motor_power = _val; \
|
||||
wt_servo_set(motor_power); \
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif /* WT_SERVO_H */
|
||||
|
||||
Reference in New Issue
Block a user