*** empty log message ***

This commit is contained in:
Antoine Drouin
2007-01-23 00:02:32 +00:00
parent 08a9390465
commit fe9b6689a6
11 changed files with 237 additions and 4 deletions
+4 -2
View File
@@ -17,10 +17,12 @@ FLASH_MODE = IAP
imu.CFLAGS += -DIMU -DCONFIG=\"pprz_imu.h\"
imu.srcs = main_imu.c sys_time.c $(SRC_ARCH)/sys_time_hw.c $(SRC_ARCH)/armVIC.c
#imu.CFLAGS += -DUSE_UART0 -DUART0_BAUD=B38400
imu.CFLAGS += -DLED
imu.CFLAGS += -DUSE_UART1 -DUART1_BAUD=B38400
imu.srcs += $(SRC_ARCH)/uart_hw.c
imu.CFLAGS += -DUSE_UART1 -DUART1_BAUD=B38400 -DDOWNLINK -DDOWNLINK_TRANSPORT=PprzTransport -DDOWNLINK_DEVICE=Uart1
imu.CFLAGS += -DDOWNLINK -DDOWNLINK_TRANSPORT=PprzTransport -DDOWNLINK_DEVICE=Uart1
imu.srcs += downlink.c pprz_transport.c
imu.CFLAGS += -DADC -DUSE_AD0 -DUSE_AD0_1 -DUSE_AD0_2 -DUSE_AD0_3 -DUSE_AD0_4
+41
View File
@@ -0,0 +1,41 @@
<airframe name="IMU">
<makefile>
ARCHI=arm7
mb.ARCHDIR = $(ARCHI)
mb.ARCH = arm7tdmi
mb.TARGET = motor_bench
mb.TARGETDIR = motor_bench
LPC21ISP_BAUD = 38400
LPC21ISP_XTAL = 12000
#FLASH_MODE = IAP
FLASH_MODE = ISP
mb.CFLAGS += -DCONFIG=\"motor_bench.h\"
mb.srcs = main_motor_bench.c sys_time.c $(SRC_ARCH)/sys_time_hw.c $(SRC_ARCH)/armVIC.c
mb.CFLAGS += -DLED
mb.CFLAGS += -DUSE_UART0 -DUART0_BAUD=B38400
mb.srcs += $(SRC_ARCH)/uart_hw.c
mb.CFLAGS += -DDOWNLINK -DDOWNLINK_TRANSPORT=PprzTransport -DDOWNLINK_DEVICE=Uart1
mb.srcs += downlink.c pprz_transport.c
mb.CFLAGS += -DADC -DUSE_AD0 -DUSE_AD0_1 -DUSE_AD0_2 -DUSE_AD0_3 -DUSE_AD0_4
mb.srcs += $(SRC_ARCH)/adc_hw.c
mb.CFLAGS += -DICP_SCALE
#mb.srcs += $(SRC_ARCH)/icp_scale.c
mb.CFLAGS += -DTACHO_MB
mb.srcs += $(SRC_ARCH)/tacho_mb.c
</makefile>
</airframe>
+22
View File
@@ -0,0 +1,22 @@
#ifndef CONFIG_MOTOR_BENCH_H
#define CONFIG_MOTOR_BENCH_H
/* Master oscillator freq. */
#define FOSC (12000000)
/* PLL multiplier */
#define PLL_MUL (5)
/* CPU clock freq. */
#define CCLK (FOSC * PLL_MUL)
/* Peripheral bus speed mask 0x00->4, 0x01-> 1, 0x02 -> 2 */
#define PBSD_BITS 0x00
#define PBSD_VAL 4
/* Peripheral bus clock freq. */
#define PCLK (CCLK / PBSD_VAL)
#define LED_1_BANK 0
#define LED_1_PIN 12
#define LED_2_BANK 0
#define LED_2_PIN 13
#endif /* CONFIG_MOTOR_BENCH_H */
+4
View File
@@ -18,7 +18,11 @@
#define ADC_CHANNEL_AZ 3
#define ADC_CHANNEL_BAT 4
#define LED_1_BANK 0
#define LED_1_PIN 2
#define LED_2_BANK 0
#define LED_2_PIN 3
+31
View File
@@ -0,0 +1,31 @@
#ifndef ICP_SCALE_H
#define ICP_SCALE_H
/* INPUT CAPTURE on P0.6*/
#define ICP_PINSEL PINSEL0
#define ICP_PINSEL_VAL 0x02
#define ICP_PINSEL_BIT 12
#include "led.h"
volatile uint32_t pulse_len;
static inline void icp_scale_init ( void ) {
/* select pin for capture */
ICP_PINSEL |= ICP_PINSEL_VAL << ICP_PINSEL_BIT;
/* enable capture 0.2 on falling edge + trigger interrupt */
T0CCR |= TCCR_CR2_F | TCCR_CR2_I;
}
#define ICP_ISR() { \
static uint32_t last; \
uint32_t now = T0CR2; \
pulse_len = now - last; \
last = now; \
LED_TOGGLE(2); \
}
#endif /* ICP_SCALE_H */
+23
View File
@@ -7,8 +7,17 @@
#include "ppm.h"
#ifdef ICP_SCALE
#include "icp_scale.h"
#endif /* ICP_SCALE */
#ifdef TACHO_MB
#include "tacho_mb.h"
#define TIMER0_IT_MASK (TIR_CR2I | TIR_MR1I | TIR_CR0I)
#else
#define TIMER0_IT_MASK (TIR_CR2I | TIR_MR1I)
#endif /* TACHO_MB */
void TIMER0_ISR ( void ) {
ISR_ENTRY();
@@ -35,6 +44,20 @@ void TIMER0_ISR ( void ) {
T0IR = TIR_MR1I;
}
#endif
#ifdef ICP_SCALE
if (T0IR&TIR_CR2I) {
ICP_ISR();
/* clear interrupt */
T0IR = TIR_CR2I;
}
#endif
#ifdef TACHO_MB
if (T0IR&TIR_CR0I) {
TACHO_MB_ISR();
/* clear interrupt */
T0IR = TIR_CR0I;
}
#endif /* TACHO_MB */
}
VICVectAddr = 0x00000000;
+17
View File
@@ -0,0 +1,17 @@
#include "tacho_mb.h"
#include "LPC21xx.h"
uint32_t t_duration;
/* INPUT CAPTURE CAP0.0 on P0.22*/
#define TACHO_MB_PINSEL PINSEL1
#define TACHO_MB_PINSEL_VAL 0x02
#define TACHO_MB_PINSEL_BIT 12
void tacho_mb_init ( void ) {
/* select pin for capture */
TACHO_MB_PINSEL |= TACHO_MB_PINSEL_VAL << TACHO_MB_PINSEL_BIT;
/* enable capture 0.2 on falling edge + trigger interrupt */
T0CCR |= TCCR_CR0_F | TCCR_CR0_I;
}
+18
View File
@@ -0,0 +1,18 @@
#ifndef TACHO_MB_H
#define TACHO_MB_H
#include "std.h"
extern void tacho_mb_init ( void );
extern uint32_t t_duration;
#define TACHO_MB_ISR() { \
static uint32_t tmb_last; \
uint32_t t_now = T0CR0; \
t_duration = t_now - tmb_last; \
tmb_last = t_now; \
LED_TOGGLE(1); \
}
#endif /* TACHO_MB_H */
+2 -2
View File
@@ -50,12 +50,12 @@
#endif /** !SITL */
#ifdef AP
/** Telemetry mode for FBW process: index in the telemetry.xml file */
/** Telemetry mode for AP process: index in the telemetry.xml file */
extern uint8_t telemetry_mode_Ap;
#endif
#ifdef FBW
/** Telemetry mode for AP process: index in the telemetry.xml file */
/** Telemetry mode for FBW process: index in the telemetry.xml file */
extern uint8_t telemetry_mode_Fbw;
#endif
+67
View File
@@ -0,0 +1,67 @@
#include "std.h"
#include "sys_time.h"
#include "init_hw.h"
#include "interrupt_hw.h"
#include "uart.h"
#include "print.h"
#include "adc.h"
#include "icp_scale.h"
#include "tacho_mb.h"
#include "messages.h"
#include "downlink.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();
LED_ON(1);
LED_ON(2);
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();
adc_init();
icp_scale_init();
tacho_mb_init();
int_enable();
}
static uint32_t t0, t1;
static inline void main_event_task( void ) {
}
static inline void main_periodic_task( void ) {
t0 = T0TC;
static uint8_t cnt;
cnt++;
if (!(cnt%16)) {
// LED_TOGGLE(1);
uart0_transmit('#');
Uart0PrintHex32(pulse_len);
uart0_transmit(' ');
Uart0PrintHex32(t_duration);
uart0_transmit('\n');
}
}
+8
View File
@@ -51,8 +51,16 @@
_PrintHex(out_fun, low16); \
}
#define _PrintHex32(out_fun, c ) { \
uint16_t high32 = (uint16_t)(c>>16); \
uint16_t low32 = (uint16_t)(c); \
_PrintHex16(out_fun, high32); \
_PrintHex16(out_fun, low32); \
}
#define Uart0PrintHex(c) _PrintHex(uart0_transmit, c)
#define Uart0PrintHex16(c) _PrintHex16(uart0_transmit, c)
#define Uart0PrintHex32(c) _PrintHex32(uart0_transmit, c)
#define Uart0PrintString(s) _PrintString(uart0_transmit, s)
#define Uart1PrintHex(c) _PrintHex(uart1_transmit, c)