}
static void
-ao_pressure(int16_t value, int16_t max_adc, double ref, double r1, double r2)
+ao_pressure(int16_t value, int16_t max_adc, double ref, double r1, double r2, double sensor_range)
{
printf(" pressure %5d", value);
if (r1 && r2 && ref) {
if (volts < 0.5) volts = 0.5;
if (volts > 4.5) volts = 4.5;
- double psi = (volts - 0.5) / 4.0 * 2500.0;
+ double psi = (volts - 0.5) / 4.0 * sensor_range;
double pa = psi_to_pa(psi);
printf(" %9.3f kPa", pa / 1000.0);
}
double sense_r1 = 0.0, sense_r2 = 0.0;
double batt_r1 = 0.0, batt_r2 = 0.0;
double adc_ref = 0.0;
+ double pressure_sensor = 0.0;
int16_t max_adc = 0;
switch (eeprom->log_format) {
break;
case AO_LOG_FORMAT_TELEFIRETWO:
len = 32;
+ pressure_sensor = 2500.0;
max_adc = 4095;
adc_ref = 3.3;
sense_r1 = batt_r1 = 5600;
break;
case AO_LOG_FORMAT_TELEMEGA_4:
len = 32;
- break;
max_adc= 4095;
adc_ref = 3.3;
batt_r1 = 5600;
len = 16;
max_adc = 32767;
adc_ref = 3.3;
+ pressure_sensor = 1600.0;
batt_r1 = 5600;
batt_r2 = 10000;
sense_r1 = 5600;
log_mega = (struct ao_log_mega *) &eeprom->data[pos];
switch (log_mega->type) {
case AO_LOG_FLIGHT:
- printf(" serial %5u flight %5u ground_accel %6d ground_pres %9u",
+ printf(" serial %5u flight %5u ground_accel %6d ground_pres %9u kPa %7.1f %7.1f m",
eeprom->serial_number,
log_mega->u.flight.flight,
log_mega->u.flight.ground_accel,
- log_mega->u.flight.ground_pres);
+ log_mega->u.flight.ground_pres,
+ log_mega->u.flight.ground_pres / 1000.0,
+ ao_pressure_to_altitude(log_mega->u.flight.ground_pres));
+
printf(" along %6d aross %6d through %6d",
log_mega->u.flight.ground_accel_along,
log_mega->u.flight.ground_accel_across,
log_mini = (struct ao_log_mini *) &eeprom->data[pos];
switch (log_mini->type) {
case AO_LOG_FLIGHT:
- printf(" serial %5u flight %5u ground_pres %9u",
+ printf(" serial %5u flight %5u ground_pres %9u kPa %7.1f %7.1f m",
eeprom->serial_number,
log_mini->u.flight.flight,
- log_mini->u.flight.ground_pres);
+ log_mini->u.flight.ground_pres,
+ log_mini->u.flight.ground_pres / 1000.0,
+ ao_pressure_to_altitude(log_mini->u.flight.ground_pres));
break;
case AO_LOG_STATE:
ao_state(log_mini->u.state.state,
log_metrum = (struct ao_log_metrum *) &eeprom->data[pos];
switch (log_metrum->type) {
case AO_LOG_FLIGHT:
- printf(" serial %5u flight %5u ground_accel %6d ground_pres %9u ground_temp %9u",
+ printf(" serial %5u flight %5u ground_accel %6d ground_pres %9u kPa %7.1f %7.1f m ground_temp %9u",
eeprom->serial_number,
log_metrum->u.flight.flight,
log_metrum->u.flight.ground_accel,
log_metrum->u.flight.ground_pres,
+ log_metrum->u.flight.ground_pres / 1000.0,
+ ao_pressure_to_altitude(log_metrum->u.flight.ground_pres),
log_metrum->u.flight.ground_temp);
break;
case AO_LOG_SENSOR:
case AO_LOG_SENSOR:
ao_pressure(log_firetwo->u.sensor.pressure,
max_adc, adc_ref,
- sense_r1, sense_r2);
+ sense_r1, sense_r2,
+ pressure_sensor);
ao_thrust(log_firetwo->u.sensor.thrust,
max_adc, adc_ref,
sense_r1, sense_r2);
break;
}
break;
+ case AO_LOG_FORMAT_EASYMOTOR:
+ log_motor = (struct ao_log_motor *) &eeprom->data[pos];
+ switch (log_motor->type) {
+ case AO_LOG_FLIGHT:
+ printf(" serial %5u flight %5u ground_accel %6d",
+ eeprom->serial_number,
+ log_motor->u.flight.flight,
+ log_motor->u.flight.ground_accel);
+ printf(" along %6d aross %6d through %6d",
+ log_motor->u.flight.ground_accel_along,
+ log_motor->u.flight.ground_accel_across,
+ log_motor->u.flight.ground_accel_through);
+ ao_volts("ground pressure",
+ log_motor->u.flight.ground_motor_pressure,
+ max_adc, adc_ref,
+ sense_r1, sense_r2);
+ break;
+ case AO_LOG_STATE:
+ ao_state(log_motor->u.state.state,
+ log_motor->u.state.reason);
+ break;
+ case AO_LOG_SENSOR:
+ ao_volts("pressure",
+ log_motor->u.sensor.pressure,
+ max_adc, adc_ref,
+ sense_r1, sense_r2);
+ ao_volts("v_batt",
+ log_motor->u.sensor.v_batt,
+ max_adc,
+ adc_ref, batt_r1, batt_r2);
+ printf(" accel %6d",
+ log_motor->u.sensor.accel);
+ printf(" along %6d aross %6d through %6d",
+ log_motor->u.sensor.accel_along,
+ log_motor->u.sensor.accel_across,
+ log_motor->u.sensor.accel_through);
+ break;
+ }
+ break;
case AO_LOG_FORMAT_DETHERM:
break;
+ case AO_LOG_FORMAT_EASYMOTOR:
+ log_motor = (struct ao_log_motor *) &eeprom->data[pos];
+ switch (log_motor->type) {
+ case AO_LOG_FLIGHT:
+ printf(" serial %5u flight %5u",
+ eeprom->serial_number,
+ log_motor->u.flight.flight);
+ break;
+ case AO_LOG_STATE:
+ ao_state(log_motor->u.state.state,
+ log_motor->u.state.reason);
+ break;
+ case AO_LOG_SENSOR:
+ ao_pressure(log_motor->u.sensor.pressure,
+ max_adc, adc_ref,
+ sense_r1, sense_r2,
+ pressure_sensor);
+ ao_volts("v_batt",
+ log_motor->u.sensor.v_batt,
+ max_adc,
+ adc_ref,
+ batt_r1, batt_r2);
+ break;
+ }
+ break;
}
}
printf("\n");
#define AO_LOG_FORMAT_TELESTATIC 17 /* 32 byte typed telestatic records */
#define AO_LOG_FORMAT_MICROPEAK2 18 /* 2-byte baro values with header */
#define AO_LOG_FORMAT_TELEMEGA_4 19 /* 32 byte typed telemega records with 32 bit gyro cal and Bmx160 */
-#define AO_LOG_FORMAT_EASYMOTOR 20 /* 16 byte typed easymotor records */
+#define AO_LOG_FORMAT_EASYMOTOR 20 /* 16 byte typed easymotor records with pressure sensor and adxl375 */
#define AO_LOG_FORMAT_NONE 127 /* No log at all */
enum ao_pyro_flag {
} u; /* 16 */
}; /* 16 */
+ struct ao_log_motor {
+ char type; /* 0 */
+ uint8_t csum; /* 1 */
+ uint16_t tick; /* 2 */
+ union { /* 4 */
+ /* AO_LOG_FLIGHT */
+ struct {
+ uint16_t flight; /* 4 */
+ int16_t ground_accel; /* 6 */
+ int16_t ground_accel_along; /* 8 */
+ int16_t ground_accel_across; /* 10 */
+ int16_t ground_accel_through; /* 12 */
+ int16_t ground_motor_pressure; /* 14 */
+ } flight; /* 16 */
+ /* AO_LOG_STATE */
+ struct {
+ uint16_t state; /* 4 */
+ uint16_t reason; /* 6 */
+ } state;
+ /* AO_LOG_SENSOR */
+ struct {
+ uint16_t pressure; /* 4 */
+ uint16_t v_batt; /* 6 */
+ int16_t accel; /* 8 */
+ int16_t accel_across; /* 10 */
+ int16_t accel_along; /* 12 */
+ int16_t accel_through; /* 14 */
+ } sensor; /* 16 */
+ } u;
+ };
+
#define ao_log_pack24(dst,value) do { \
(dst)[0] = (value); \
(dst)[1] = (value) >> 8; \
} u;
};
+struct ao_log_motor {
+ char type; /* 0 */
+ uint8_t csum; /* 1 */
+ uint16_t tick; /* 2 */
+ union { /* 4 */
+ /* AO_LOG_FLIGHT */
+ struct {
+ uint16_t flight; /* 4 */
+ int16_t ground_accel; /* 6 */
+ int16_t ground_accel_along; /* 8 */
+ int16_t ground_accel_across; /* 10 */
+ int16_t ground_accel_through; /* 12 */
+ int16_t ground_motor_pressure; /* 14 */
+ } flight; /* 16 */
+ /* AO_LOG_STATE */
+ struct {
+ uint16_t state; /* 4 */
+ uint16_t reason; /* 6 */
+ } state;
+ /* AO_LOG_SENSOR */
+ struct {
+ uint16_t pressure; /* 4 */
+ uint16_t v_batt; /* 6 */
+ int16_t accel; /* 8 */
+ int16_t accel_across; /* 10 */
+ int16_t accel_along; /* 12 */
+ int16_t accel_through; /* 14 */
+ } sensor; /* 16 */
+ } u;
+};
+
struct ao_eeprom {
struct ao_config config;
struct ao_ms5607_prom ms5607_prom;
easymega-v1.0 easymega-v1.0/flash-loader \
easymega-v2.0 easymega-v2.0/flash-loader \
easymotor-v2 easymotor-v2/flash-loader \
+ easymotor-v3 easymotor-v3/flash-loader \
easytimer-v1 easytimer-v1/flash-loader \
telemega-v0.1 telemega-v0.1/flash-loader \
telemega-v1.0 telemega-v1.0/flash-loader \
chaoskey-v1.0 chaoskey-v1.0/flash-loader \
telemini-v3.0 telemini-v3.0/flash-loader \
easymini-v2.0 easymini-v2.0/flash-loader \
+ easymini-v3.0 easymini-v3.0/flash-loader \
micropeak-v2.0
AVRDIRS=\
#include "ao.h"
-#define _cat(a,b) a##b
-#define cat(a,b) _cat(a,b)
+#define _cat2(a,b) a##b
+#define cat2(a,b) _cat2(a,b)
#define _cat4(a,b,c,d) a##b##c##d
#define cat4(a,b,c,d) _cat4(a,b,c,d)
#define _cat8(a,b,c,d,e,f,g,h) a##b##c##d##e##f##g##h
#define cat8(a,b,c,d,e,f,g,h) _cat8(a,b,c,d,e,f,g,h)
-#define AO_TIMER_CLKCTRL cat(LPC_SCB_SYSAHBCLKCTRL_CT32B, BEEPER_TIMER)
-#define AO_TIMER cat(lpc_ct32b, BEEPER_TIMER)
-#define AO_TIMER_EMC cat(LPC_CT32B_EMR_EMC, BEEPER_OUTPUT)
-#define AO_TIMER_PIO cat4(pio, BEEPER_PORT, _, BEEPER_PIN)
-/* LPC_IOCONF_FUNC_PIO0_14_CT32B1_MAT1 */
-#define AO_TIMER_FUNC cat8(LPC_IOCONF_FUNC_PIO, BEEPER_PORT, _, BEEPER_PIN, _CT32B, BEEPER_TIMER, _MAT, BEEPER_OUTPUT)
-#define AO_TIMER_PWM cat(LPC_CT32B_PWMC_PWMEN, BEEPER_OUTPUT)
+#ifndef AO_LPC_BEEP_TIMER
+#define AO_LPC_BEEP_TIMER 1
+#define AO_LPC_BEEP_CHANNEL 1
+#define AO_LPC_BEEP_PORT 0
+#define AO_LPC_BEEP_PIN 14
+#endif
+
+#define AO_LPC_CT_BEEP cat2(lpc_ct32b, AO_LPC_BEEP_TIMER)
+#define AO_LPC_CT_BEEP_CLKCTRL cat2(LPC_SCB_SYSAHBCLKCTRL_CT32B, AO_LPC_BEEP_TIMER)
+#define AO_LPC_CT_BEEP_EMR cat2(LPC_CT32B_EMR_EMC, AO_LPC_BEEP_CHANNEL)
+#define AO_LPC_CT_BEEP_MR AO_LPC_BEEP_CHANNEL
+#define AO_LPC_CT_BEEP_PWMC cat2(LPC_CT32B_PWMC_PWMEN, AO_LPC_BEEP_CHANNEL)
+#define AO_LPC_CT_BEEP_IOCONF cat4(pio,AO_LPC_BEEP_PORT,_,AO_LPC_BEEP_PIN)
+#define AO_LPC_CT_BEEP_FUNC cat8(LPC_IOCONF_FUNC_PIO,AO_LPC_BEEP_PORT,_,AO_LPC_BEEP_PIN,_CT32B,AO_LPC_BEEP_TIMER,_MAT,AO_LPC_BEEP_CHANNEL)
void
ao_beep(uint8_t beep)
{
if (beep == 0) {
- AO_TIMER.tcr = ((0 << LPC_CT32B_TCR_CEN) |
+ AO_LPC_CT_BEEP.tcr = ((0 << LPC_CT32B_TCR_CEN) |
(1 << LPC_CT32B_TCR_CRST));
- lpc_scb.sysahbclkctrl &= ~(1UL << AO_TIMER_CLKCTRL);
+ lpc_scb.sysahbclkctrl &= ~(1UL << AO_LPC_CT_BEEP_CLKCTRL);
} else {
- lpc_scb.sysahbclkctrl |= (1 << AO_TIMER_CLKCTRL);
+ lpc_scb.sysahbclkctrl |= (1UL << AO_LPC_CT_BEEP_CLKCTRL);
/* Set prescaler to match cc1111 clocks
*/
- AO_TIMER.pr = AO_LPC_SYSCLK / 750000 - 1;
+ AO_LPC_CT_BEEP.pr = AO_LPC_SYSCLK / 750000 - 1;
/* Write the desired data in the match registers */
/* Reset after two time units */
- AO_TIMER.mr[0] = beep << 1;
+ AO_LPC_CT_BEEP.mr[0] = beep << 1;
/* PWM width is half of that */
- AO_TIMER.mr[BEEPER_OUTPUT] = beep;
+ AO_LPC_CT_BEEP.mr[AO_LPC_CT_BEEP_MR] = beep;
/* Flip output on PWM match */
- AO_TIMER.emr = (LPC_CT32B_EMR_EMC_TOGGLE << AO_TIMER_EMC);
+ AO_LPC_CT_BEEP.emr = (LPC_CT32B_EMR_EMC_TOGGLE << AO_LPC_CT_BEEP_EMR);
/* Reset on match 0 */
- AO_TIMER.mcr = (1 << LPC_CT32B_MCR_MR0R);
+ AO_LPC_CT_BEEP.mcr = (1 << LPC_CT32B_MCR_MR0R);
/* PWM on match */
- AO_TIMER.pwmc = (1 << AO_TIMER_PWM);
+ AO_LPC_CT_BEEP.pwmc = (1 << AO_LPC_CT_BEEP_PWMC);
/* timer mode */
- AO_TIMER.ctcr = 0;
+ AO_LPC_CT_BEEP.ctcr = 0;
/* And turn the timer on */
- AO_TIMER.tcr = ((1 << LPC_CT32B_TCR_CEN) |
+ AO_LPC_CT_BEEP.tcr = ((1 << LPC_CT32B_TCR_CEN) |
(0 << LPC_CT32B_TCR_CRST));
}
}
void
- ao_beep_for(uint8_t beep, AO_TICK_TYPE ticks)
+ ao_beep_for(uint8_t beep, AO_TICK_TYPE ticks)
{
ao_beep(beep);
ao_delay(ticks);
void
ao_beep_init(void)
{
- lpc_ioconf.AO_TIMER_PIO = ((AO_TIMER_FUNC << LPC_IOCONF_FUNC) |
+ /* Our beeper is on c32b1_mat1
+ * which is on pin pio0_14
+ */
+
+ lpc_ioconf.AO_LPC_CT_BEEP_IOCONF = ((AO_LPC_CT_BEEP_FUNC << LPC_IOCONF_FUNC) |
(LPC_IOCONF_MODE_INACTIVE << LPC_IOCONF_MODE) |
(0 << LPC_IOCONF_HYS) |
(0 << LPC_IOCONF_INV) |
(1 << LPC_IOCONF_ADMODE) |
(0 << LPC_IOCONF_OD));
+
+ lpc_scb.sysahbclkctrl |= (1 << AO_LPC_CT_BEEP_CLKCTRL);
+
+ /* Disable the counter and reset the value */
+ AO_LPC_CT_BEEP.tcr = ((0 << LPC_CT32B_TCR_CEN) |
+ (1 << LPC_CT32B_TCR_CRST));
}