moving files around

This commit is contained in:
Antoine Drouin
2009-07-18 12:34:48 +00:00
parent ae98b30741
commit 5c1dcd5fa8
31 changed files with 1868 additions and 0 deletions
@@ -0,0 +1,105 @@
/*
* $Id$
*
* Copyright (C) 2008-2009 Antoine Drouin <poinix@gmail.com>
*
* This file is part of paparazzi.
*
* paparazzi is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* paparazzi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "actuators.h"
#include "i2c.h"
#include "led.h"
bool_t actuators_asctec_twi_blmc_command;
uint8_t actuators_asctec_twi_blmc_command_type;
#define MB_TWI_CONTROLLER_ASCTECH_ADDR_FRONT 0
#define MB_TWI_CONTROLLER_ASCTECH_ADDR_BACK 1
#define MB_TWI_CONTROLLER_ASCTECH_ADDR_LEFT 2
#define MB_TWI_CONTROLLER_ASCTECH_ADDR_RIGHT 3
uint8_t actuators_asctec_twi_blmc_addr;
uint8_t actuators_asctec_twi_blmc_new_addr;
#define ASCTEC_TWI_BLMC_NB 4
int8_t asctec_twi_blmc_motor_power[ASCTEC_TWI_BLMC_NB];
uint8_t twi_blmc_nb_err;
volatile uint8_t mb_twi_i2c_done;
#define MB_TWI_CONTROLLER_MAX_CMD 200
#define MB_TWI_CONTROLLER_ADDR 0x02
void actuators_init(void) {
twi_blmc_nb_err = 0;
mb_twi_i2c_done = TRUE;
actuators_asctec_twi_blmc_command = MB_TWI_CONTROLLER_COMMAND_NONE;
actuators_asctec_twi_blmc_addr = MB_TWI_CONTROLLER_ASCTECH_ADDR_FRONT;
}
void asctec_twi_controller_send() {
if (!mb_twi_i2c_done) {
twi_blmc_nb_err++;
}
if (actuators_asctec_twi_blmc_command != MB_TWI_CONTROLLER_COMMAND_NONE) {
switch (actuators_asctec_twi_blmc_command) {
case MB_TWI_CONTROLLER_COMMAND_TEST :
i2c0_buf[0] = 251;
i2c0_buf[1] = actuators_asctec_twi_blmc_addr;
i2c0_buf[2] = 0;
i2c0_buf[3] = 231 + actuators_asctec_twi_blmc_addr;
mb_twi_i2c_done = FALSE;
i2c0_transmit(MB_TWI_CONTROLLER_ADDR, 4, &mb_twi_i2c_done);
break;
case MB_TWI_CONTROLLER_COMMAND_REVERSE :
i2c0_buf[0] = 254;
i2c0_buf[1] = actuators_asctec_twi_blmc_addr;
i2c0_buf[2] = 0;
i2c0_buf[3] = 234 + actuators_asctec_twi_blmc_addr;
mb_twi_i2c_done = FALSE;
i2c0_transmit(MB_TWI_CONTROLLER_ADDR, 4, &mb_twi_i2c_done);
break;
case MB_TWI_CONTROLLER_COMMAND_SET_ADDR :
i2c0_buf[0] = 250;
i2c0_buf[1] = actuators_asctec_twi_blmc_addr;
i2c0_buf[2] = actuators_asctec_twi_blmc_new_addr;
i2c0_buf[3] = 230 + actuators_asctec_twi_blmc_addr +
actuators_asctec_twi_blmc_new_addr;
actuators_asctec_twi_blmc_addr = actuators_asctec_twi_blmc_new_addr;
mb_twi_i2c_done = FALSE;
i2c0_transmit(MB_TWI_CONTROLLER_ADDR, 4, &mb_twi_i2c_done);
break;
}
actuators_asctec_twi_blmc_command = MB_TWI_CONTROLLER_COMMAND_NONE;
}
else {
i2c0_buf[0] = 100 + asctec_twi_blmc_motor_power[SERVO_PITCH];
i2c0_buf[1] = 100 + asctec_twi_blmc_motor_power[SERVO_ROLL];
i2c0_buf[2] = 100 + asctec_twi_blmc_motor_power[SERVO_YAW];
i2c0_buf[3] = asctec_twi_blmc_motor_power[SERVO_THRUST];
mb_twi_i2c_done = FALSE;
i2c0_transmit(MB_TWI_CONTROLLER_ADDR, 4, &mb_twi_i2c_done);
}
}
@@ -0,0 +1,110 @@
/*
* $Id$
*
* Copyright (C) 2008-2009 Antoine Drouin <poinix@gmail.com>
*
* This file is part of paparazzi.
*
* paparazzi is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* paparazzi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef ACTUATORS_ASCTEC_TWI_BLMC_H
#define ACTUATORS_ASCTEC_TWI_BLMC_H
#include "std.h"
#include "led.h"
#include "airframe.h"
extern void asctec_twi_controller_send(void);
extern uint8_t twi_blmc_nb_err;
extern int8_t asctec_twi_blmc_motor_power[];
#define MB_TWI_CONTROLLER_COMMAND_NONE 0
#define MB_TWI_CONTROLLER_COMMAND_TEST 1
#define MB_TWI_CONTROLLER_COMMAND_REVERSE 2
#define MB_TWI_CONTROLLER_COMMAND_SET_ADDR 3
extern uint8_t actuators_asctec_twi_blmc_command;
extern uint8_t actuators_asctec_twi_blmc_addr;
extern uint8_t actuators_asctec_twi_blmc_new_addr;
#define actuators_asctec_twi_blmc_hw_SetCommand(value) { \
actuators_asctec_twi_blmc_command = value; \
}
#define actuators_asctec_twi_blmc_hw_SetAddr(value) { \
actuators_asctec_twi_blmc_command = MB_TWI_CONTROLLER_COMMAND_SET_ADDR; \
actuators_asctec_twi_blmc_new_addr = value; \
}
#ifndef SetActuatorsFromCommands
#ifdef KILL_MOTORS
#define SetActuatorsFromCommands(_motors_on) { \
Actuator(SERVO_PITCH) = 0; \
Actuator(SERVO_ROLL) = 0; \
Actuator(SERVO_YAW) = 0; \
Actuator(SERVO_THRUST) = 0; \
ActuatorsCommit(); \
}
#else /* ! KILL_MOTORS */
#ifndef SUPERVISION_HACK_45
#define SetActuatorsFromCommands(_motors_on) { \
booz2_commands[COMMAND_PITCH] += SUPERVISION_TRIM_E; \
booz2_commands[COMMAND_ROLL] += SUPERVISION_TRIM_A; \
booz2_commands[COMMAND_YAW] += SUPERVISION_TRIM_R; \
Bound(booz2_commands[COMMAND_PITCH],-100, 100); \
Bound(booz2_commands[COMMAND_ROLL], -100, 100); \
Bound(booz2_commands[COMMAND_YAW], -100, 100); \
if (_motors_on) { \
Bound(booz2_commands[COMMAND_THRUST], 1, 200); \
} \
Actuator(SERVO_PITCH) = -(uint8_t)booz2_commands[COMMAND_PITCH]; \
Actuator(SERVO_ROLL) = (uint8_t)booz2_commands[COMMAND_ROLL]; \
Actuator(SERVO_YAW) = -(uint8_t)booz2_commands[COMMAND_YAW]; \
Actuator(SERVO_THRUST) = (uint8_t)booz2_commands[COMMAND_THRUST]; \
ActuatorsCommit(); \
}
#else /* SUPERVISION_HACK_45 */
#define SetActuatorsFromCommands(_motors_on) { \
int32_t _r1 = booz2_commands[COMMAND_ROLL] + booz2_commands[COMMAND_PITCH]; \
int32_t _p1 = booz2_commands[COMMAND_ROLL] - booz2_commands[COMMAND_PITCH]; \
int32_t _y1 = booz2_commands[COMMAND_YAW]; \
int32_t _t1 = booz2_commands[COMMAND_THRUST]; \
Bound(_r1,-100, 100); \
Bound(_p1,-100, 100); \
Bound(_y1,-100, 100); \
if (_motors_on) { \
Bound(_t1, 1, 200); \
} \
Actuator(SERVO_ROLL) = _r1; \
Actuator(SERVO_PITCH) = _p1; \
Actuator(SERVO_YAW) = _y1; \
Actuator(SERVO_THRUST) = _t1; \
ActuatorsCommit(); \
}
#endif /* SUPERVISION_HACK_45 */
#endif /* KILL_MOTORS */
#endif /* SetActuatorsFromCommands */
#define Actuator(i) asctec_twi_blmc_motor_power[i]
#define ActuatorsCommit() { \
asctec_twi_controller_send(); \
}
#endif /* ACTUATORS_ASCTEC_TWI_BLMC_H */
@@ -0,0 +1,44 @@
/*
* $Id$
*
* Copyright (C) 2008-2009 Antoine Drouin <poinix@gmail.com>
*
* This file is part of paparazzi.
*
* paparazzi is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* paparazzi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "actuators.h"
#include BOARD_CONFIG
uint8_t twi_blmc_nb_err;
uint8_t buss_twi_blmc_motor_power[BUSS_TWI_BLMC_NB];
volatile bool_t buss_twi_blmc_status;
volatile bool_t buss_twi_blmc_i2c_done;
volatile uint8_t buss_twi_blmc_idx;
const uint8_t buss_twi_blmc_addr[BUSS_TWI_BLMC_NB] = BUSS_BLMC_ADDR;
void actuators_init ( void ) {
uint8_t i;
for (i=0; i<BUSS_TWI_BLMC_NB;i++)
buss_twi_blmc_motor_power[i] = 0;
buss_twi_blmc_status = BUSS_TWI_BLMC_STATUS_IDLE;
twi_blmc_nb_err = 0;
buss_twi_blmc_i2c_done = TRUE;
}
@@ -0,0 +1,111 @@
/*
* $Id$
*
* Copyright (C) 2008-2009 Antoine Drouin <poinix@gmail.com>
*
* This file is part of paparazzi.
*
* paparazzi is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* paparazzi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef ACTUATORS_BUSS_TWI_BLMC_HW_H
#define ACTUATORS_BUSS_TWI_BLMC_HW_H
#include <string.h>
#include "std.h"
#include "i2c.h"
#include "airframe.h"
#include "booz2_supervision.h"
/*
We're not using the airframe file "mixer" facility
and instead explicitely call the "supervision" code
to do the mixing
*/
#ifndef SetActuatorsFromCommands
#ifdef KILL_MOTORS
#define SetActuatorsFromCommands(_motors_on) { \
Actuator(SERVO_FRONT) = 0; \
Actuator(SERVO_BACK) = 0; \
Actuator(SERVO_RIGHT) = 0; \
Actuator(SERVO_LEFT) = 0; \
ActuatorsCommit(); \
}
#else
#define SetActuatorsFromCommands(_motors_on) { \
pprz_t mixed_commands[SERVOS_NB]; \
BOOZ2_SUPERVISION_RUN(mixed_commands, booz2_commands, _motors_on); \
Actuator(SERVO_FRONT) = (uint8_t)mixed_commands[SERVO_FRONT]; \
Actuator(SERVO_BACK) = (uint8_t)mixed_commands[SERVO_BACK]; \
Actuator(SERVO_RIGHT) = (uint8_t)mixed_commands[SERVO_RIGHT]; \
Actuator(SERVO_LEFT) = (uint8_t)mixed_commands[SERVO_LEFT]; \
ActuatorsCommit(); \
}
#endif /* KILL_MOTORS */
#endif /* SetActuatorsFromCommands */
#define ChopServo(x,a,b) ((x)>(b)?(b):(x))
#define Actuator(i) buss_twi_blmc_motor_power[i]
#ifdef TWI_IGNORE_ACK
#define ActuatorsCommit() { \
buss_twi_blmc_idx = 0; \
buss_twi_blmc_status = BUSS_TWI_BLMC_STATUS_BUSY; \
ActuatorsBussTwiBlmcSend(); \
}
#else
#define ActuatorsCommit() { \
if ( buss_twi_blmc_status == BUSS_TWI_BLMC_STATUS_IDLE) { \
buss_twi_blmc_idx = 0; \
buss_twi_blmc_status = BUSS_TWI_BLMC_STATUS_BUSY; \
ActuatorsBussTwiBlmcSend(); \
} \
else \
twi_blmc_nb_err++; \
}
#endif
#define SERVOS_TICS_OF_USEC(s) ((uint8_t)(s))
#define BUSS_TWI_BLMC_STATUS_IDLE 0
#define BUSS_TWI_BLMC_STATUS_BUSY 1
#define BUSS_TWI_BLMC_NB 4
extern uint8_t buss_twi_blmc_motor_power[BUSS_TWI_BLMC_NB];
extern volatile bool_t buss_twi_blmc_status;
extern uint8_t twi_blmc_nb_err;
extern volatile bool_t buss_twi_blmc_i2c_done;
extern volatile uint8_t buss_twi_blmc_idx;
extern const uint8_t buss_twi_blmc_addr[];
#define ActuatorsBussTwiBlmcNext() { \
buss_twi_blmc_idx++; \
if (buss_twi_blmc_idx < BUSS_TWI_BLMC_NB) { \
ActuatorsBussTwiBlmcSend(); \
} \
else \
buss_twi_blmc_status = BUSS_TWI_BLMC_STATUS_IDLE; \
}
#define ActuatorsBussTwiBlmcSend() { \
i2c0_buf[0] = buss_twi_blmc_motor_power[buss_twi_blmc_idx]; \
i2c0_transmit(buss_twi_blmc_addr[buss_twi_blmc_idx], 1, &buss_twi_blmc_i2c_done); \
}
#endif /* ACTUATORS_BUSS_TWI_BLMC_HW_H */
@@ -0,0 +1,114 @@
/*
* $Id$
*
* Copyright (C) 2008-2009 Antoine Drouin <poinix@gmail.com>
*
* This file is part of paparazzi.
*
* paparazzi is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* paparazzi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "booz2_analog.h"
#include "armVIC.h"
#include "sys_time.h"
#include "booz2_analog_baro.h"
#include "booz2_battery.h"
void ADC0_ISR ( void ) __attribute__((naked));
void ADC1_ISR ( void ) __attribute__((naked));
void booz2_analog_init_hw( void ) {
/* start ADC0 */
/* select P0.29 as AD0.2 for bat meas*/
PINSEL1 |= 0x01 << 26;
/* sample AD0.2 - PCLK/4 ( 3.75MHz) - ON */
AD0CR = 1 << 2 | 0x03 << 8 | 1 << 21;
/* AD0 selected as IRQ */
VICIntSelect &= ~VIC_BIT(VIC_AD0);
/* AD0 interrupt enabled */
VICIntEnable = VIC_BIT(VIC_AD0);
/* AD0 interrupt as VIC2 */
_VIC_CNTL(ADC0_VIC_SLOT) = VIC_ENABLE | VIC_AD0;
_VIC_ADDR(ADC0_VIC_SLOT) = (uint32_t)ADC0_ISR;
/* start convertion on T0M1 match */
AD0CR |= 4 << 24;
/* clear match 1 */
T0EMR &= ~TEMR_EM1;
/* set high on match 1 */
T0EMR |= TEMR_EMC1_2;
/* first match in a while */
T0MR1 = 1024;
/* start ADC1 */
/* select P0.10 as AD1.2 for baro*/
ANALOG_BARO_PINSEL |= ANALOG_BARO_PINSEL_VAL << ANALOG_BARO_PINSEL_BIT;
/* sample AD1.2 - PCLK/4 ( 3.75MHz) - ON */
AD1CR = 1 << 2 | 0x03 << 8 | 1 << 21;
/* AD0 selected as IRQ */
VICIntSelect &= ~VIC_BIT(VIC_AD1);
/* AD0 interrupt enabled */
VICIntEnable = VIC_BIT(VIC_AD1);
/* AD0 interrupt as VIC2 */
_VIC_CNTL(ADC1_VIC_SLOT) = VIC_ENABLE | VIC_AD1;
_VIC_ADDR(ADC1_VIC_SLOT) = (uint32_t)ADC1_ISR;
/* start convertion on T0M3 match */
AD1CR |= 5 << 24;
/* clear match 2 */
T0EMR &= ~TEMR_EM3;
/* set high on match 2 */
T0EMR |= TEMR_EMC3_2;
/* first match in a while */
T0MR3 = 512;
/* turn on DAC pins */
PINSEL1 |= 2 << 18;
}
void ADC0_ISR ( void ) {
ISR_ENTRY();
uint32_t tmp = AD0GDR;
uint16_t tmp2 = (uint16_t)(tmp >> 6) & 0x03FF;
Booz2BatteryISRHandler(tmp2);
/* trigger next convertion */
T0MR1 += BOOZ2_ANALOG_BATTERY_PERIOD;
/* lower clock */
T0EMR &= ~TEMR_EM1;
VICVectAddr = 0x00000000; // clear this interrupt from the VIC
ISR_EXIT(); // recover registers and return
}
void ADC1_ISR ( void ) {
ISR_ENTRY();
uint32_t tmp = AD1GDR;
uint16_t tmp2 = (uint16_t)(tmp >> 6) & 0x03FF;
Booz2BaroISRHandler(tmp2);
/* trigger next convertion */
T0MR3 += BOOZ2_ANALOG_BARO_PERIOD;
/* lower clock */
T0EMR &= ~TEMR_EM3;
VICVectAddr = 0x00000000; // clear this interrupt from the VIC
ISR_EXIT(); // recover registers and return
}
@@ -0,0 +1,33 @@
/*
* $Id$
*
* Copyright (C) 2008-2009 Antoine Drouin <poinix@gmail.com>
*
* This file is part of paparazzi.
*
* paparazzi is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* paparazzi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef BOOZ2_ANALOG_HW_H
#define BOOZ2_ANALOG_HW_H
#include "LPC21xx.h"
#define Booz2AnalogSetDAC(x) { DACR = x << 6; }
extern void booz2_analog_init_hw(void);
#endif /* BOOZ2_ANALOG_HW_H */
@@ -0,0 +1,48 @@
/*
* $Id: $
*
* Copyright (C) 2007 ENAC
*
* This file is part of paparazzi.
*
* paparazzi is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* paparazzi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
*/
#include "booz2_pwm_hw.h"
#define PWM_PERIOD SYS_TICS_OF_USEC(20000)
#define PWM_DUTY SYS_TICS_OF_USEC(1500)
void booz2_pwm_init_hw( void ) {
/* start PWM5 */
/* select P0.21 as PWM5 */
PWM_PINSEL |= PWM_PINSEL_VAL << PWM_PINSEL_BIT;
/* select pwm period */
PWMMR0 = PWM_PERIOD;
/* select pwm value to 50% at init (1500 us) */
PWMMR5 = PWM_DUTY;
/* commit values */
PWMLER = PWMLER_LATCH0 | PWMLER_LATCH5;
/* enable counter and pwm mode */
PWMTCR = PWMTCR_COUNTER_ENABLE | PWMTCR_PWM_ENABLE;
/* enable PWM5 */
PWMPCR = PWMPCR_ENA5;
}
@@ -0,0 +1,38 @@
/*
* $Id: $
*
* Copyright (C) 2007 ENAC
*
* This file is part of paparazzi.
*
* paparazzi is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* paparazzi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
*/
#ifndef BOOZ2_PWM_HW_H
#define BOOZ2_PWM_HW_H
#include "std.h"
#include "sys_time.h"
extern void booz2_pwm_init_hw(void);
#define Booz2SetPwmValue(_v) { \
PWMMR5 = SYS_TICS_OF_USEC(_v); \
PWMLER = PWMLER_LATCH5; \
}
#endif /* BOOZ2_PWM_HW_H */
@@ -0,0 +1,64 @@
/* PNI micromag3 connected on SPI1 */
/*
Twisted Logic
SS on P0.20
RESET on P0.29
DRDY on P0.30 ( EINT3 )
*/
/*
IMU v3
SS on P0.20
RESET on P1.21
DRDY on P0.15 ( EINT2 )
*/
/*
IMU b2
SS on P1.28
RESET on P1.19
DRDY on P0.30 ( EINT3)
*/
#include "micromag.h"
volatile uint8_t micromag_cur_axe;
static void EXTINT_ISR(void) __attribute__((naked));
void micromag_hw_init( void ) {
MmUnselect(); /* pin idles high */
/* configure SS pin */
SetBit(MM_SS_IODIR, MM_SS_PIN); /* pin is output */
/* configure RESET pin */
SetBit(MM_RESET_IODIR, MM_RESET_PIN); /* pin is output */
MmReset(); /* pin idles low */
/* configure DRDY pin */
/* connected pin to EXINT */
MM_DRDY_PINSEL |= MM_DRDY_PINSEL_VAL << MM_DRDY_PINSEL_BIT;
SetBit(EXTMODE, MM_DRDY_EINT); /* EINT is edge trigered */
SetBit(EXTPOLAR,MM_DRDY_EINT); /* EINT is trigered on rising edge */
SetBit(EXTINT,MM_DRDY_EINT); /* clear pending EINT */
/* initialize interrupt vector */
VICIntSelect &= ~VIC_BIT( MM_DRDY_VIC_IT ); /* select EINT as IRQ source */
VICIntEnable = VIC_BIT( MM_DRDY_VIC_IT ); /* enable it */
_VIC_CNTL(MICROMAG_DRDY_VIC_SLOT) = VIC_ENABLE | MM_DRDY_VIC_IT;
_VIC_ADDR(MICROMAG_DRDY_VIC_SLOT) = (uint32_t)EXTINT_ISR; // address of the ISR
}
void EXTINT_ISR(void) {
ISR_ENTRY();
/* no, we won't do anything asynchronously, so just notify */
micromag_status = MM_GOT_EOC;
/* clear EINT */
//SetBit(EXTINT,MM_DRDY_EINT);
EXTINT = (1<<MM_DRDY_EINT);
VICVectAddr = 0x00000000; /* clear this interrupt from the VIC */
ISR_EXIT();
}
@@ -0,0 +1,94 @@
#ifndef BOOZ_MS2001_ARCH_H
#define BOOZ_MS2001_ARCH_H
#include <stdlib.h> // for abs
#include "std.h"
#include "LPC21xx.h"
#include "interrupt_hw.h"
#include "ssp_hw.h"
#include BOARD_CONFIG
#include "airframe.h"
#define MS2001_DIVISOR_128 2
#define MS2001_DIVISOR_256 3
#define MS2001_DIVISOR_512 4
#define MS2001_DIVISOR_1024 5
#define MS2001_DIVISOR MS2001_DIVISOR_1024
extern volatile uint8_t ms2001_cur_axe;
#define Ms2001Select() SetBit(MS2001_SS_IOCLR,MS2001_SS_PIN)
#define Ms2001Unselect() SetBit(MS2001_SS_IOSET,MS2001_SS_PIN)
#define Ms2001Reset() SetBit(MS2001_RESET_IOCLR,MS2001_RESET_PIN)
#define Ms2001Set() SetBit(MS2001_RESET_IOSET,MS2001_RESET_PIN)
#define Ms2001OnSpiIt() { \
switch (ms2001_status) { \
case MS2001_SENDING_REQ: \
{ \
/* read dummy control byte reply */ \
uint8_t foo __attribute__ ((unused)) = SSPDR; \
ms2001_status = MS2001_WAITING_EOC; \
Ms2001Unselect(); \
SSP_ClearRti(); \
SSP_DisableRti(); \
SSP_Disable(); \
} \
break; \
case MS2001_READING_RES: \
{ \
int16_t new_val; \
new_val = SSPDR << 8; \
new_val += SSPDR; \
if (abs(new_val) < 2000) \
ms2001_values[micromag_cur_axe] = new_val; \
Ms2001Unselect(); \
SSP_ClearRti(); \
SSP_DisableRti(); \
SSP_Disable(); \
ms2001_cur_axe++; \
if (ms2001_cur_axe > 2) { \
ms2001_cur_axe = 0; \
ms2001_status = MS2001_DATA_AVAILABLE; \
} \
else \
ms2001_status = MS2001_IDLE; \
} \
break; \
} \
}
#define Ms2001SendReq() { \
Ms2001Select(); \
ms2001_status = MS2001_SENDING_REQ; \
Ms2001Set(); \
SSP_ClearRti(); \
SSP_EnableRti(); \
Ms2001Reset(); \
uint8_t control_byte = (ms2001_cur_axe+1) << 0 | \
MS2001_DIVISOR << 4; \
SSP_Send(control_byte); \
SSP_Enable(); \
}
#define MmReadRes() { \
ms2001_status = MS2001_READING_RES; \
Ms2001Select(); \
/* trigger 2 bytes read */ \
SSP_Send(0); \
SSP_Send(0); \
SSP_Enable(); \
SSP_ClearRti(); \
SSP_EnableRti(); \
}
#endif /* BOOZ_MS2001_ARCH_H */
@@ -0,0 +1,186 @@
/*
* $Id$
*
* Copyright (C) 2008-2009 Antoine Drouin <poinix@gmail.com>
*
* This file is part of paparazzi.
*
* paparazzi is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* paparazzi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "booz_imu.h"
volatile uint8_t booz_imu_ssp_status;
static void SSP_ISR(void) __attribute__((naked));
#if 0
static inline bool_t isr_try_mag(void);
#endif
/* SSPCR0 settings */
#define SSP_DDS8 0x07 << 0 /* data size : 8 bits */
#define SSP_DDS16 0x0F << 0 /* data size : 16 bits */
#define SSP_FRF 0x00 << 4 /* frame format : SPI */
#define SSP_CPOL 0x00 << 6 /* clock polarity : data captured on first clock transition */
#define SSP_CPHA 0x00 << 7 /* clock phase : SCK idles low */
#define SSP_SCR 0x0F << 8 /* serial clock rate : divide by 16 */
/* SSPCR1 settings */
#define SSP_LBM 0x00 << 0 /* loopback mode : disabled */
#define SSP_SSE 0x00 << 1 /* SSP enable : disabled */
#define SSP_MS 0x00 << 2 /* master slave mode : master */
#define SSP_SOD 0x00 << 3 /* slave output disable : don't care when master */
#define SSPCR0_VAL8 (SSP_DDS8 | SSP_FRF | SSP_CPOL | SSP_CPHA | SSP_SCR )
#define SSPCR0_VAL16 (SSP_DDS16 | SSP_FRF | SSP_CPOL | SSP_CPHA | SSP_SCR )
#define SSPCR1_VAL (SSP_LBM | SSP_SSE | SSP_MS | SSP_SOD )
#define SSP_PINSEL1_SCK (2<<2)
#define SSP_PINSEL1_MISO (2<<4)
#define SSP_PINSEL1_MOSI (2<<6)
#define BoozImuSetSSP8bits() { \
SSPCR0 = SSPCR0_VAL8; \
}
#define BoozImuSetSSP16bits() { \
SSPCR0 = SSPCR0_VAL16; \
}
void booz_imu_b2_arch_init(void) {
booz_imu_ssp_status = BOOZ_IMU_SSP_STA_IDLE;
/* setup pins for SSP (SCK, MISO, MOSI) */
PINSEL1 |= SSP_PINSEL1_SCK | SSP_PINSEL1_MISO | SSP_PINSEL1_MOSI;
/* setup SSP */
SSPCR0 = SSPCR0_VAL16;
SSPCR1 = SSPCR1_VAL;
SSPCPSR = 0x02;
/* initialize interrupt vector */
VICIntSelect &= ~VIC_BIT( VIC_SPI1 ); /* SPI1 selected as IRQ */
VICIntEnable = VIC_BIT( VIC_SPI1 ); /* enable it */
_VIC_CNTL(SSP_VIC_SLOT) = VIC_ENABLE | VIC_SPI1;
_VIC_ADDR(SSP_VIC_SLOT) = (uint32_t)SSP_ISR; /* address of the ISR */
}
void booz_imu_periodic(void) {
// check ssp idle
// ASSERT((booz_imu_status == BOOZ_IMU_STA_IDLE), DEBUG_IMU, IMU_ERR_OVERUN);
// setup 16 bits
BoozImuSetSSP16bits();
// read adc
booz_imu_ssp_status = BOOZ_IMU_SSP_STA_BUSY_MAX1168;
booz_max1168_read();
}
#include "led.h"
#if 0
static inline bool_t isr_try_mag(void) {
switch (micromag_status) {
case MM_IDLE :
Booz2ImuSetSSP8bits();
MmSendReq();
return TRUE;
case MM_GOT_EOC:
Booz2ImuSetSSP8bits();
MmReadRes();
return TRUE;
}
return FALSE;
}
static void SSP_ISR(void) {
ISR_ENTRY();
switch (booz2_imu_ssp_status) {
case BOOZ2_IMU_SSP_STA_BUSY_MAX1168:
Max1168OnSpiInt();
if (isr_try_mag())
booz2_imu_ssp_status = BOOZ2_IMU_SSP_STA_BUSY_MS2100;
else
booz2_imu_ssp_status = BOOZ2_IMU_SSP_STA_IDLE;
break;
case BOOZ2_IMU_SSP_STA_BUSY_MS2100:
MmOnSpiIt();
booz2_imu_ssp_status = BOOZ2_IMU_SSP_STA_IDLE;
break;
default:
// spurious interrupt
LED_ON(1);
}
VICVectAddr = 0x00000000; /* clear this interrupt from the VIC */
ISR_EXIT();
}
#endif
static void SSP_ISR(void) {
ISR_ENTRY();
switch (booz_imu_ssp_status) {
case BOOZ_IMU_SSP_STA_BUSY_MAX1168:
Max1168OnSpiInt();
#if defined IMU_B2_MAG_TYPE && IMU_B2_MAG_TYPE == IMU_B2_MAG_MS2001
if (micromag_status == MM_IDLE || micromag_status == MM_GOT_EOC) {
BoozImuSetSSP8bits();
if (micromag_status == MM_IDLE) {
MmSendReq();
}
else { /* MM_GOT_EOC */
MmReadRes();
}
booz_imu_ssp_status = BOOZ_IMU_SSP_STA_BUSY_MS2100;
}
else {
#endif
booz_imu_ssp_status = BOOZ_IMU_SSP_STA_IDLE;
#if defined IMU_B2_MAG_TYPE && IMU_B2_MAG_TYPE == IMU_B2_MAG_MS2001
}
#endif
break;
#if defined IMU_B2_MAG_TYPE && IMU_B2_MAG_TYPE == IMU_B2_MAG_MS2001
case BOOZ_IMU_SSP_STA_BUSY_MS2100:
MmOnSpiIt();
if (micromag_status == MM_IDLE) {
MmSendReq();
booz_imu_ssp_status = BOOZ_IMU_SSP_STA_BUSY_MS2100;
}
else
booz_imu_ssp_status = BOOZ_IMU_SSP_STA_IDLE;
break;
#endif
// default:
// spurious interrupt
// FIXME LED_ON(1);
}
VICVectAddr = 0x00000000; /* clear this interrupt from the VIC */
ISR_EXIT();
}
@@ -0,0 +1,52 @@
/*
* $Id$
*
* Copyright (C) 2008-2009 Antoine Drouin <poinix@gmail.com>
*
* This file is part of paparazzi.
*
* paparazzi is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* paparazzi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef BOOZ_IMU_B2_ARCH_H
#define BOOZ_IMU_B2_ARCH_H
/*
MAX1168 SPI ADC connected on SPI1
SS on P0.20
EOC on P0.16 ( EINT0 )
PNI mag on same bus
SS on p1.28
EOC P0.30 ( EINT3 )
RESET P1.19
*/
#include "std.h"
#include "LPC21xx.h"
#include "interrupt_hw.h"
#define BOOZ_IMU_SSP_STA_IDLE 0
#define BOOZ_IMU_SSP_STA_BUSY_MAX1168 1
#define BOOZ_IMU_SSP_STA_BUSY_MS2100 2
extern volatile uint8_t booz_imu_ssp_status;
#endif /* BOOZ_IMU_B2_ARCH_H */
@@ -0,0 +1,126 @@
/*
* $Id$
*
* Copyright (C) 2008-2009 Antoine Drouin <poinix@gmail.com>
*
* This file is part of paparazzi.
*
* paparazzi is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* paparazzi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "booz_imu.h"
#include "LPC21xx.h"
#include "armVIC.h"
#include "ssp_hw.h"
#include BOARD_CONFIG
#define ADS8344_SS_IODIR IO0DIR
#define ADS8344_SS_IOSET IO0SET
#define ADS8344_SS_IOCLR IO0CLR
#define ADS8344_SS_PIN 20
#define ADS8344Select() SetBit(ADS8344_SS_IOCLR,ADS8344_SS_PIN)
#define ADS8344Unselect() SetBit(ADS8344_SS_IOSET,ADS8344_SS_PIN)
bool_t ADS8344_available;
uint16_t ADS8344_values[ADS8344_NB_CHANNELS];
#define POWER_MODE (1 << 1 | 1)
#define SGL_DIF 1 // Single ended
/* SSPCR0 settings */
#define SSP_DSS 0x07 << 0 /* data size : 8 bits */
#define SSP_FRF 0x00 << 4 /* frame format : SPI */
#define SSP_CPOL 0x00 << 6 /* clock polarity : idle low */
#define SSP_CPHA 0x00 << 7 /* clock phase : 1 */
#define SSP_SCR 0x09 << 8 /* serial clock rate : 1MHz */
/* SSPCR1 settings */
#define SSP_LBM 0x00 << 0 /* loopback mode : disabled */
#define SSP_SSE 0x00 << 1 /* SSP enable : disabled */
#define SSP_MS 0x00 << 2 /* master slave mode : master */
#define SSP_SOD 0x00 << 3 /* slave output disable : disabled */
static void SPI1_ISR(void) __attribute__((naked));
static uint8_t channel;
void booz_imu_crista_arch_init(void) {
channel = 0;
/* setup pins for SSP (SCK, MISO, MOSI) */
PINSEL1 |= 2 << 2 | 2 << 4 | 2 << 6;
/* setup SSP */
SSPCR0 = SSP_DSS | SSP_FRF | SSP_CPOL | SSP_CPHA | SSP_SCR;
SSPCR1 = SSP_LBM | SSP_MS | SSP_SOD;
SSPCPSR = 2; /* -> 50kHz */
/* initialize interrupt vector */
VICIntSelect &= ~VIC_BIT(VIC_SPI1); // SPI1 selected as IRQ
VICIntEnable = VIC_BIT(VIC_SPI1); // SPI1 interrupt enabled
VICVectCntl7 = VIC_ENABLE | VIC_SPI1;
VICVectAddr7 = (uint32_t)SPI1_ISR; // address of the ISR
/* setup slave select */
/* configure SS pin */
SetBit( ADS8344_SS_IODIR, ADS8344_SS_PIN); /* pin is output */
ADS8344Unselect(); /* pin low */
}
static inline void read_values( void ) {
uint8_t foo __attribute__ ((unused)) = SSPDR;
uint8_t msb = SSPDR;
uint8_t lsb = SSPDR;
uint8_t llsb = SSPDR;
ADS8344_values[channel] = (msb << 8 | lsb) << 1 | llsb >> 7;
}
static inline void send_request( void ) {
uint8_t control = 1 << 7 | channel << 4 | SGL_DIF << 2 | POWER_MODE;
SSP_Send(control);
SSP_Send(0);
SSP_Send(0);
SSP_Send(0);
}
void ADS8344_start( void ) {
ADS8344Select();
SSP_ClearRti();
SSP_EnableRti();
SSP_Enable();
send_request();
}
void SPI1_ISR(void) {
ISR_ENTRY();
read_values();
channel++;
if (channel > 7-1) {
channel = 0;
ADS8344_available = TRUE;
ADS8344Unselect();
}
else {
send_request();
}
SSP_ClearRti();
VICVectAddr = 0x00000000; /* clear this interrupt from the VIC */
ISR_EXIT();
}
@@ -0,0 +1,38 @@
/*
* $Id$
*
* Copyright (C) 2008-2009 Antoine Drouin <poinix@gmail.com>
*
* This file is part of paparazzi.
*
* paparazzi is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* paparazzi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef BOOZ_IMU_INT_HW_H
#define BOOZ_IMU_INT_HW_H
#include "std.h"
#define BoozImuCristaArchPeriodic() { \
ADS8344_start(); \
}
extern void ADS8344_start( void );
#endif /* BOOZ_IMU_INT_HW_H */
@@ -0,0 +1,43 @@
/*
* $Id$
*
* Copyright (C) 2008-2009 Antoine Drouin <poinix@gmail.com>
*
* This file is part of paparazzi.
*
* paparazzi is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* paparazzi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "booz_radio_control.h"
uint8_t booz_radio_control_ppm_cur_pulse;
uint32_t booz_radio_control_ppm_last_pulse_time;
void booz_radio_control_ppm_arch_init ( void ) {
/* select pin for capture */
PPM_PINSEL |= PPM_PINSEL_VAL << PPM_PINSEL_BIT;
/* enable capture 0.2 on falling or rising edge + trigger interrupt */
#if defined PPM_PULSE_TYPE && PPM_PULSE_TYPE == PPM_PULSE_TYPE_POSITIVE
T0CCR = PPM_CCR_CRF | PPM_CCR_CRI;
#elif defined PPM_PULSE_TYPE && PPM_PULSE_TYPE == PPM_PULSE_TYPE_NEGATIVE
T0CCR = PPM_CCR_CRR | PPM_CCR_CRI;
#else
#error "ppm_hw.h: Unknown PM_PULSE_TYPE"
#endif
booz_radio_control_ppm_last_pulse_time = 0;
booz_radio_control_ppm_cur_pulse = RADIO_CONTROL_NB_CHANNEL;
booz_radio_control_ppm_frame_available = FALSE;
}
@@ -0,0 +1,65 @@
/*
* $Id$
*
* Copyright (C) 2008-2009 Antoine Drouin <poinix@gmail.com>
*
* This file is part of paparazzi.
*
* paparazzi is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* paparazzi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef BOOZ_RADIO_CONTROL_PPM_HW_H
#define BOOZ_RADIO_CONTROL_PPM_HW_H
#include "LPC21xx.h"
#include BOARD_CONFIG
extern uint8_t booz_radio_control_ppm_cur_pulse;
extern uint32_t booz_radio_control_ppm_last_pulse_time;
extern void booz_radio_control_ppm_arch_init ( void );
#define RADIO_CONTROL_PPM_IT PPM_CRI
#define RADIO_CONTROL_PPM_ISR() { \
\
uint32_t now = PPM_CR; \
uint32_t length = now - booz_radio_control_ppm_last_pulse_time; \
booz_radio_control_ppm_last_pulse_time = now; \
\
if (booz_radio_control_ppm_cur_pulse == RADIO_CONTROL_NB_CHANNEL) { \
if (length > SYS_TICS_OF_USEC(PPM_SYNC_MIN_LEN) && \
length < SYS_TICS_OF_USEC(PPM_SYNC_MAX_LEN)) { \
booz_radio_control_ppm_cur_pulse = 0; \
} \
} \
else { \
if (length > SYS_TICS_OF_USEC(PPM_DATA_MIN_LEN) && \
length < SYS_TICS_OF_USEC(PPM_DATA_MAX_LEN)) { \
booz_radio_control_ppm_pulses[booz_radio_control_ppm_cur_pulse] = length; \
booz_radio_control_ppm_cur_pulse++; \
if (booz_radio_control_ppm_cur_pulse == RADIO_CONTROL_NB_CHANNEL) { \
booz_radio_control_ppm_frame_available = TRUE; \
} \
} \
else \
booz_radio_control_ppm_cur_pulse = RADIO_CONTROL_NB_CHANNEL; \
} \
}
#endif /* BOOZ_RADIO_CONTROL_PPM_HW_H */
@@ -0,0 +1,91 @@
/*
* $Id$
*
* Copyright (C) 2008-2009 Antoine Drouin <poinix@gmail.com>
*
* This file is part of paparazzi.
*
* paparazzi is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* paparazzi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "peripherals/booz_max1168.h"
static void EXTINT0_ISR(void) __attribute__((naked));
void booz_max1168_arch_init( void ) {
/* unselected max1168 */
Max1168Unselect();
/* SS pin is output */
SetBit(MAX1168_SS_IODIR, MAX1168_SS_PIN);
/* connect P0.16 to extint0 (EOC) */
MAX1168_EOC_PINSEL |= MAX1168_EOC_PINSEL_VAL << MAX1168_EOC_PINSEL_BIT;
/* extint0 is edge trigered */
SetBit(EXTMODE, MAX1168_EOC_EINT);
/* extint0 is trigered on falling edge */
ClearBit(EXTPOLAR, MAX1168_EOC_EINT);
/* clear pending extint0 before enabling interrupts */
SetBit(EXTINT, MAX1168_EOC_EINT);
/* initialize interrupt vector */
VICIntSelect &= ~VIC_BIT( VIC_EINT0 ); // EXTINT0 selected as IRQ
VICIntEnable = VIC_BIT( VIC_EINT0 ); // EXTINT0 interrupt enabled
_VIC_CNTL(MAX1168_EOC_VIC_SLOT) = VIC_ENABLE | VIC_EINT0;
_VIC_ADDR(MAX1168_EOC_VIC_SLOT) = (uint32_t)EXTINT0_ISR; // address of the ISR
}
void booz_max1168_read( void ) {
ASSERT((booz_max1168_status == STA_MAX1168_IDLE), \
DEBUG_MAX_1168, MAX1168_ERR_READ_OVERUN);
/* select max1168 */
Max1168Select();
/* enable SPI */
SSP_ClearRti();
SSP_DisableRti();
SSP_Enable();
/* write control byte - wait EOC on extint */
SSPDR = (1 << 0 | 1 << 3 | 7 << 5) << 8;
booz_max1168_status = STA_MAX1168_SENDING_REQ;
}
void EXTINT0_ISR(void) {
ISR_ENTRY();
ASSERT((booz_max1168_status == STA_MAX1168_SENDING_REQ), \
DEBUG_MAX_1168, MAX1168_ERR_SPURIOUS_EOC);
/* read dummy control byte reply */
uint16_t foo __attribute__ ((unused));
foo = SSPDR;
/* trigger 8 frames read */
SSP_Send(0);
SSP_Send(0);
SSP_Send(0);
SSP_Send(0);
SSP_Send(0);
SSP_Send(0);
SSP_Send(0);
SSP_Send(0);
SSP_ClearRti();
SSP_EnableRti();
booz_max1168_status = STA_MAX1168_READING_RES;
//SetBit(EXTINT, MAX1168_EOC_EINT); /* clear extint0 */
EXTINT = (1<<MAX1168_EOC_EINT);
VICVectAddr = 0x00000000; /* clear this interrupt from the VIC */
ISR_EXIT();
}
@@ -0,0 +1,79 @@
/*
* $Id$
*
* Copyright (C) 2008-2009 Antoine Drouin <poinix@gmail.com>
*
* This file is part of paparazzi.
*
* paparazzi is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* paparazzi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef BOOZ_MAX1168_HW_H
#define BOOZ_MAX1168_HW_H
/*
MAX1168 SPI ADC connected on SPI1
SS on P0.20
EOC on P0.16 ( EINT0 )
*/
#include "std.h"
#include "LPC21xx.h"
#include "interrupt_hw.h"
#include "ssp_hw.h"
#include "booz2_debug.h"
#define MAX1168_ERR_ISR_STATUS 0
#define MAX1168_ERR_READ_OVERUN 1
#define MAX1168_ERR_SPURIOUS_EOC 2
#define MAX1168_SS_PIN 20
#define MAX1168_SS_IODIR IO0DIR
#define MAX1168_SS_IOSET IO0SET
#define MAX1168_SS_IOCLR IO0CLR
#define MAX1168_EOC_PIN 16
#define MAX1168_EOC_PINSEL PINSEL1
#define MAX1168_EOC_PINSEL_BIT 0
#define MAX1168_EOC_PINSEL_VAL 1
#define MAX1168_EOC_EINT 0
#define Max1168Unselect() SetBit(MAX1168_SS_IOSET, MAX1168_SS_PIN)
#define Max1168Select() SetBit(MAX1168_SS_IOCLR, MAX1168_SS_PIN)
#define Max1168OnSpiInt() { \
ASSERT((booz_max1168_status == STA_MAX1168_READING_RES), \
DEBUG_MAX_1168, MAX1168_ERR_ISR_STATUS); \
/* store convertion result */ \
booz_max1168_values[0] = SSPDR; \
booz_max1168_values[1] = SSPDR; \
booz_max1168_values[2] = SSPDR; \
booz_max1168_values[3] = SSPDR; \
booz_max1168_values[4] = SSPDR; \
booz_max1168_values[5] = SSPDR; \
booz_max1168_values[6] = SSPDR; \
booz_max1168_values[7] = SSPDR; \
SSP_ClearRti(); \
SSP_DisableRti(); \
SSP_Disable(); \
Max1168Unselect(); \
booz_max1168_status = STA_MAX1168_DATA_AVAILABLE; \
}
#endif /* BOOZ2_MAX1168_HW_H */
@@ -0,0 +1,31 @@
/*
* $Id$
*
* Copyright (C) 2008-2009 Antoine Drouin <poinix@gmail.com>
*
* This file is part of paparazzi.
*
* paparazzi is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* paparazzi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "actuators.h"
uint16_t actuators[SERVOS_NB];
uint8_t twi_blmc_nb_err;
uint8_t buss_twi_blmc_motor_power[BUSS_TWI_BLMC_NB];
void actuators_init( void ) {}
@@ -0,0 +1,45 @@
/*
* $Id$
*
* Copyright (C) 2008-2009 Antoine Drouin <poinix@gmail.com>
*
* This file is part of paparazzi.
*
* paparazzi is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* paparazzi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef ACTUATORS_BUSS_TWI_BLMC_HW_H
#define ACTUATORS_BUSS_TWI_BLMC_HW_H
#include "airframe.h"
#include "booz2_supervision.h"
#define BUSS_TWI_BLMC_NB 4
extern uint8_t buss_twi_blmc_motor_power[BUSS_TWI_BLMC_NB];
#define Actuator(i) buss_twi_blmc_motor_power[i]
#define SetActuatorsFromCommands(_motors_on) { \
pprz_t mixed_commands[SERVOS_NB]; \
BOOZ2_SUPERVISION_RUN(mixed_commands, booz2_commands, _motors_on); \
Actuator(SERVO_FRONT) = (uint8_t)mixed_commands[SERVO_FRONT]; \
Actuator(SERVO_BACK) = (uint8_t)mixed_commands[SERVO_BACK]; \
Actuator(SERVO_RIGHT) = (uint8_t)mixed_commands[SERVO_RIGHT]; \
Actuator(SERVO_LEFT) = (uint8_t)mixed_commands[SERVO_LEFT]; \
}
extern uint8_t twi_blmc_nb_err;
#endif /* ACTUATORS_BUSS_TWI_BLMC_HW_H */
@@ -0,0 +1,29 @@
/*
* $Id$
*
* Copyright (C) 2008-2009 Antoine Drouin <poinix@gmail.com>
*
* This file is part of paparazzi.
*
* paparazzi is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* paparazzi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "booz2_analog.h"
void booz2_analog_init_hw(void) {
}
@@ -0,0 +1,31 @@
/*
* $Id$
*
* Copyright (C) 2008-2009 Antoine Drouin <poinix@gmail.com>
*
* This file is part of paparazzi.
*
* paparazzi is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* paparazzi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef BOOZ2_ANALOG_HW_H
#define BOOZ2_ANALOG_HW_H
#define Booz2AnalogSetDAC(x) { }
extern void booz2_analog_init_hw(void);
#endif /* BOOZ2_ANALOG_HW_H */
@@ -0,0 +1,28 @@
/*
* $Id$
*
* Copyright (C) 2008-2009 Antoine Drouin <poinix@gmail.com>
*
* This file is part of paparazzi.
*
* paparazzi is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* paparazzi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "booz2_imu_b2.h"
void booz2_imu_b2_hw_init(void) {
}
@@ -0,0 +1,51 @@
/*
* $Id$
*
* Copyright (C) 2008-2009 Antoine Drouin <poinix@gmail.com>
*
* This file is part of paparazzi.
*
* paparazzi is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* paparazzi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
*
* simulator plug for the booz2 v1 imu hw funtions
*
*/
#ifndef BOOZ2_IMU_B2_HW_H
#define BOOZ2_IMU_B2_HW_H
extern void booz2_imu_b2_hw_init(void);
#define booz2_imu_feed_data() { \
booz2_max1168_values[IMU_GYRO_P_CHAN] = bsm.gyro->ve[AXIS_P]; \
booz2_max1168_values[IMU_GYRO_Q_CHAN] = bsm.gyro->ve[AXIS_Q]; \
booz2_max1168_values[IMU_GYRO_R_CHAN] = bsm.gyro->ve[AXIS_R]; \
booz2_max1168_values[IMU_ACCEL_X_CHAN] = bsm.accel->ve[AXIS_X]; \
booz2_max1168_values[IMU_ACCEL_Y_CHAN] = bsm.accel->ve[AXIS_Y]; \
booz2_max1168_values[IMU_ACCEL_Z_CHAN] = bsm.accel->ve[AXIS_Z]; \
booz2_max1168_status = STA_MAX1168_DATA_AVAILABLE; \
}
#ifdef USE_MICROMAG
#define Booz2ImuSpiEvent(_handler1,_handler2) {}
#else // NO MICROMAG
#define Booz2ImuSpiEvent(_handler) {}
#endif
#endif /* BOOZ2_IMU_B2_HW_H */
@@ -0,0 +1,35 @@
/*
* $Id$
*
* Copyright (C) 2008-2009 Antoine Drouin <poinix@gmail.com>
*
* This file is part of paparazzi.
*
* paparazzi is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* paparazzi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
*
* simulator plug for max1168 SPI Analog to Digital converter
*
*/
#ifndef BOOZ2_MAX1168_HW_H
#define BOOZ2_MAX1168_HW_H
extern void booz2_max1168_hw_init( void );
#endif /* BOOZ2_MAX1168_HW_H */
@@ -0,0 +1,28 @@
/*
* $Id$
*
* Copyright (C) 2008-2009 Antoine Drouin <poinix@gmail.com>
*
* This file is part of paparazzi.
*
* paparazzi is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* paparazzi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "booz2_max1168.h"
void booz2_max1168_hw_init( void ) {}
void booz2_max1168_read( void ) {}
+29
View File
@@ -0,0 +1,29 @@
/*
* $Id: $
*
* Copyright (C) 2007 ENAC
*
* This file is part of paparazzi.
*
* paparazzi is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* paparazzi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
*/
#include "booz2_pwm_hw.h"
void booz2_pwm_init_hw( void ) {}
+32
View File
@@ -0,0 +1,32 @@
/*
* $Id: $
*
* Copyright (C) 2007 ENAC
*
* This file is part of paparazzi.
*
* paparazzi is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* paparazzi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
*/
#ifndef BOOZ2_PWM_HW_H
#define BOOZ2_PWM_HW_H
extern void booz2_pwm_init_hw(void);
#define Booz2SetPwmValue(_v) {}
#endif /* BOOZ2_PWM_HW_H */
@@ -0,0 +1,31 @@
/*
* $Id$
*
* Copyright (C) 2008-2009 Antoine Drouin <poinix@gmail.com>
*
* This file is part of paparazzi.
*
* paparazzi is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* paparazzi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "uart.h"
#include "i2c.h"
void uart0_init( void ) {}
void uart1_init( void ) {}
//void i2c0_hw_init( void ) {}
//void i2c1_hw_init( void ) {}
@@ -0,0 +1,28 @@
/*
* $Id$
*
* Copyright (C) 2008-2009 Antoine Drouin <poinix@gmail.com>
*
* This file is part of paparazzi.
*
* paparazzi is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* paparazzi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "booz_radio_control.h"
void booz_radio_control_ppm_hw_init ( void ) {
}
@@ -0,0 +1,29 @@
/*
* $Id$
*
* Copyright (C) 2008-2009 Antoine Drouin <poinix@gmail.com>
*
* This file is part of paparazzi.
*
* paparazzi is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* paparazzi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/** \file booz_radio_control_ppm_hw.h
* \brief STM32 ppm decoder
*
*/
extern void booz_radio_control_ppm_hw_init ( void );