mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-06-05 23:49:00 +08:00
@@ -42,7 +42,6 @@
|
||||
/debian/changelog
|
||||
/debian/files
|
||||
/debian/paparazzi-arm7
|
||||
/debian/paparazzi-avr
|
||||
/debian/paparazzi-dev
|
||||
/debian/paparazzi-bin
|
||||
/sw/lib/ocaml/ivy/debian/changelog
|
||||
|
||||
@@ -1,190 +0,0 @@
|
||||
# Hey Emacs, this is a -*- makefile -*-
|
||||
#
|
||||
# $Id$
|
||||
# Copyright (C) 2003-2005 Pascal Brisset, Antoine Drouin
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
|
||||
#
|
||||
# This is the common Makefile for the avr-target.
|
||||
# Edit the configuration part to suit your local install
|
||||
#
|
||||
|
||||
ATMELBIN = /usr/bin
|
||||
ATMEL_INCLUDES = -I /usr/avr/include
|
||||
ATMEL_LIBPATH = -B /usr/avr/lib/avr4 -B /usr/avr/lib/avr5
|
||||
PROG_PORT = /dev/parport0
|
||||
|
||||
VERIFY=--verify
|
||||
|
||||
SRC_ARCH = $(PAPARAZZI_SRC)/sw/airborne/arch/avr
|
||||
|
||||
CC = $(ATMELBIN)/avr-gcc -mmcu=$($(TARGET).MCU)
|
||||
LD = $(CC) $(ATMEL_LIBPATH)
|
||||
SIZE = $(ATMELBIN)/avr-size
|
||||
OBJCOPY = $(ATMELBIN)/avr-objcopy
|
||||
|
||||
|
||||
SERIAL_FLAGS = \
|
||||
-dprog=avr910 \
|
||||
-dpart=auto \
|
||||
-dserial=/dev/ttyS0 \
|
||||
-dspeed=38400 \
|
||||
|
||||
ISP_FLAGS = \
|
||||
-dlpt=$(PROG_PORT) -dprog=stk200 -v=3 \
|
||||
|
||||
UISP = uisp
|
||||
UISP_FLAGS = $(ISP_FLAGS)
|
||||
#UISP_FLAGS = $(SERIAL_FLAGS)
|
||||
|
||||
# Launch with "make Q=''" to get full command display
|
||||
Q=@
|
||||
|
||||
|
||||
#
|
||||
# End of configuration part.
|
||||
#
|
||||
SRCAVR = $($(TARGET).srcs)
|
||||
|
||||
CFLAGS = \
|
||||
-W -Wall -Wundef \
|
||||
$(ATMEL_INCLUDES) \
|
||||
$(INCLUDES) \
|
||||
-Wstrict-prototypes \
|
||||
$($(TARGET).CFLAGS) \
|
||||
$(LOCAL_CFLAGS) \
|
||||
-O3 \
|
||||
|
||||
LDFLAGS = -lm \
|
||||
|
||||
#
|
||||
# General rules
|
||||
#
|
||||
|
||||
#$(TARGET).srcsnd = $(notdir $($(TARGET).srcs))
|
||||
#$(TARGET).objso = $($(TARGET).srcsnd:%.c=$(OBJDIR)/%.o)
|
||||
#$(TARGET).objs = $($(TARGET).objso:%.S=$(OBJDIR)/%.o)
|
||||
|
||||
|
||||
all: build
|
||||
#all compile: $($(TARGET).objs) $(OBJDIR)/$(TARGET).elf
|
||||
#all:
|
||||
# @echo !!!!!!!
|
||||
# @echo $($(TARGET).objs)
|
||||
# @echo !!!!!!!
|
||||
|
||||
load upload: $(TARGET).install
|
||||
|
||||
|
||||
#
|
||||
# Fuses
|
||||
#
|
||||
|
||||
rd_fuses: check_arch
|
||||
$(UISP) $(ISP_FLAGS) --rd_fuses
|
||||
|
||||
wr_fuses : check_arch
|
||||
$(UISP) $(ISP_FLAGS) --wr_fuse_h=$($(TARGET).HIGH_FUSE)
|
||||
$(UISP) $(ISP_FLAGS) --wr_fuse_l=$($(TARGET).LOW_FUSE)
|
||||
$(UISP) $(ISP_FLAGS) --wr_fuse_e=$($(TARGET).EXT_FUSE)
|
||||
$(UISP) $(ISP_FLAGS) --wr_lock=$($(TARGET).LOCK_FUSE)
|
||||
|
||||
TMPFILE = '/tmp/check_fuses.tmp'
|
||||
|
||||
check_fuses: check_arch
|
||||
@echo "##### Check of fuses #####"
|
||||
@$(UISP) $(ISP_FLAGS) --rd_fuses >$(TMPFILE)
|
||||
@if (grep -i 'Fuse Low Byte' $(TMPFILE) | cut -c24- | grep -iq $($(TARGET).LOW_FUSE)) && (grep -i 'Fuse High Byte' $(TMPFILE) |cut -c24- | grep -iq $($(TARGET).HIGH_FUSE)) && (grep -i 'Fuse Extended Byte' $(TMPFILE) |cut -c24- | grep -iq $($(TARGET).EXT_FUSE)) && (grep -i 'Lock Bits' $(TMPFILE) |cut -c24- | grep -iq $($(TARGET).LOCK_FUSE)); then echo "-> Fuses are Ok"; rm $(TMPFILE); else echo "-> Wrong fuses. Type 'make wr_fuses'"; rm $(TMPFILE); exit 1; fi
|
||||
|
||||
# Define all object files.
|
||||
COBJ = $(SRC:%.c=$(OBJDIR)/%.o)
|
||||
COBJAVR = $(SRCAVR:%.c=$(OBJDIR)/%.o)
|
||||
|
||||
|
||||
build: elf hex
|
||||
|
||||
elf: $(OBJDIR)/$(TARGET).elf
|
||||
hex: $(OBJDIR)/$(TARGET).hex
|
||||
|
||||
|
||||
%.hex: %.elf
|
||||
@echo OBJC $@
|
||||
$(OBJCOPY) -O ihex -R .eeprom $< $@
|
||||
|
||||
.SECONDARY : $(OBJDIR)/$(TARGET).elf
|
||||
.PRECIOUS : $(COBJ) $(COBJAVR)
|
||||
|
||||
%.elf: $(COBJ) $(COBJAVR)
|
||||
@echo LD $@
|
||||
$(Q)$(LD) $(LOCAL_LDFLAGS) $^ -o $@ $(LDFLAGS)
|
||||
@echo SIZE
|
||||
$(Q)$(SIZE) $@
|
||||
|
||||
|
||||
#%.s: %.c
|
||||
# $(CC) $(CFLAGS) -S -o $@ $<
|
||||
|
||||
#$(OBJDIR)/%.s: %.c
|
||||
# $(CC) $(CFLAGS) -S -o $@ $<
|
||||
|
||||
$(OBJDIR)/%.o: %.c $(OBJDIR)/../Makefile.ac
|
||||
@echo CC $@
|
||||
$(Q)test -d $(dir $@) || mkdir -p $(dir $@)
|
||||
$(Q)$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
#$(OBJDIR)/%.o: $(SRC_ARCH)/%.S
|
||||
# $(CC) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
|
||||
|
||||
%.install: $(OBJDIR)/%.hex check_arch
|
||||
# stk200 needs to be erased first
|
||||
$(UISP) $(UISP_FLAGS) --erase
|
||||
@echo SIZE
|
||||
$(Q)$(SIZE) $<
|
||||
$(UISP) $(UISP_FLAGS) --upload $(VERIFY) if=$<
|
||||
|
||||
erase: check_arch
|
||||
$(UISP) $(ISP_FLAGS) --erase
|
||||
|
||||
check_arch :
|
||||
@echo "CHECKING link with device $($(TARGET).MCU) on $(PROG_PORT)"
|
||||
$(Q)$(UISP) $(UISP_FLAGS)
|
||||
$(Q)if ($(UISP) $(UISP_FLAGS) 2>&1 | tr '[:upper:]' '[:lower:]' | grep $($(TARGET).MCU)); then : ; else echo "Wrong architecture (mcu0 vs mcu1 ?)"; exit 1; fi
|
||||
|
||||
avr_clean:
|
||||
$(Q)rm -rf $(OBJDIR)
|
||||
|
||||
|
||||
#
|
||||
# Dependencies
|
||||
#
|
||||
|
||||
$(OBJDIR)/.depend:
|
||||
@echo DEPEND $@
|
||||
@test -d $(OBJDIR) || mkdir -p $(OBJDIR)
|
||||
$(Q)$(CC) -MM -MG $(CFLAGS) $($(TARGET).srcs) | sed 's|\([^\.]*\.o\)|$(OBJDIR)/\1|' > $@
|
||||
|
||||
ifneq ($(MAKECMDGOALS),clean)
|
||||
ifneq ($(MAKECMDGOALS),erase)
|
||||
-include $(OBJDIR)/.depend
|
||||
endif
|
||||
endif
|
||||
@@ -1,65 +0,0 @@
|
||||
/* -*- indent-tabs-mode:T; c-basic-offset:8; tab-width:8; -*- vi: set ts=8:
|
||||
* $Id$
|
||||
*
|
||||
* Assembly file to layout the AHRS data.
|
||||
* We want to be sure that things are aligned and packed as
|
||||
* closely as possible, as well as alias several things. This
|
||||
* is the easiest way to do it.
|
||||
*/
|
||||
.section .bss
|
||||
|
||||
.global X
|
||||
X:
|
||||
.global quat
|
||||
quat:
|
||||
.global q0
|
||||
q0:
|
||||
.space 4
|
||||
.global q1
|
||||
q1:
|
||||
.space 4
|
||||
.global q2
|
||||
q2:
|
||||
.space 4
|
||||
.global q3
|
||||
q3:
|
||||
.space 4
|
||||
|
||||
.global bias
|
||||
bias:
|
||||
.global bias_p
|
||||
bias_p:
|
||||
.space 4
|
||||
.global bias_q
|
||||
bias_q:
|
||||
.space 4
|
||||
.global bias_r
|
||||
bias_r:
|
||||
.space 4
|
||||
|
||||
|
||||
.global C
|
||||
C:
|
||||
.global Qdot
|
||||
Qdot:
|
||||
.space 16
|
||||
|
||||
|
||||
.global A
|
||||
A:
|
||||
.global PCt
|
||||
PCt:
|
||||
.space 7 * 4
|
||||
.global K
|
||||
K:
|
||||
.space 7 * 4
|
||||
.global E
|
||||
E:
|
||||
.space 1 * 4
|
||||
|
||||
/* And the rest of A */
|
||||
.space (4*7 - 7 - 7 - 1) * 4
|
||||
|
||||
|
||||
.global end_bss
|
||||
end_bss:
|
||||
@@ -1,51 +0,0 @@
|
||||
#include "ant_h_bridge.h"
|
||||
|
||||
#include <avr/io.h>
|
||||
|
||||
#include CONFIG
|
||||
|
||||
#define HB_DDR DDRE
|
||||
#define HB_PORT PORTE
|
||||
/* OC3A */
|
||||
#define HB_IN1_PIN 3
|
||||
/* OC3C */
|
||||
#define HB_IN2_PIN 5
|
||||
/* ENABLE */
|
||||
#define HB_EN_PIN 7
|
||||
|
||||
#define HB_REFRESH 500
|
||||
|
||||
|
||||
void ant_h_bridge_init( void ) {
|
||||
/* set PE1, PE3 and PE5 (OC3A, OC3C and PD0) as output */
|
||||
SetBit (HB_DDR,HB_IN1_PIN); /* input 1 */
|
||||
SetBit (HB_DDR,HB_IN2_PIN); /* input 2 */
|
||||
SetBit (HB_DDR,HB_EN_PIN); /* enable */
|
||||
|
||||
|
||||
/* disable motor */
|
||||
// ClearBit(HB_PORT, HB_EN_PIN);
|
||||
SetBit(HB_PORT, HB_EN_PIN);
|
||||
|
||||
/* set timer3 in fast PWM mode, with TOP defined by ICR3 , prescaled to 8 */
|
||||
|
||||
TCCR3A = _BV(WGM31) | _BV(COM3A1) | _BV(COM3C1);
|
||||
TCCR3B = _BV(WGM32) | _BV(WGM33) | _BV(CS31);
|
||||
ICR3 = HB_REFRESH;
|
||||
ant_h_bridge_set(0);
|
||||
// ant_h_bridge_set(HB_REFRESH/5);
|
||||
// SetBit(HB_PORT, HB_IN1_PIN);
|
||||
// ClearBit(HB_PORT, HB_IN2_PIN);
|
||||
|
||||
}
|
||||
|
||||
void ant_h_bridge_set ( int16_t value) {
|
||||
if (value > 0) {
|
||||
OCR3A = value;
|
||||
OCR3C = 0;
|
||||
}
|
||||
else {
|
||||
OCR3A = 0;
|
||||
OCR3C = -value;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
#ifndef ANT_H_BRIDGE_H
|
||||
#define ANT_H_BRIDGE_H
|
||||
|
||||
#include "std.h"
|
||||
|
||||
void ant_h_bridge_init( void );
|
||||
void ant_h_bridge_set ( int16_t value);
|
||||
|
||||
|
||||
|
||||
#endif /* ANT_H_BRIDGE_H */
|
||||
@@ -1,28 +0,0 @@
|
||||
#include "ant_servo.h"
|
||||
|
||||
#include <avr/io.h>
|
||||
|
||||
#include CONFIG
|
||||
|
||||
#define PRESCALER 8
|
||||
#define TICKS_OF_US(nb_us) (((nb_us) * (float)(CLOCK / PRESCALER)-1))
|
||||
#define SERVO_REFRESH 25000
|
||||
|
||||
void ant_servo_init( void ) {
|
||||
/* set PB5 and PB6 (OC1A and OC1B ) as output */
|
||||
SetBit (DDRB, 5);
|
||||
SetBit (DDRB, 6);
|
||||
/* set timer1 in fast PWM mode, with TOP defined by ICR3 , prescaled to 8 */
|
||||
TCCR1A = _BV(WGM11) | _BV(COM1A1) | _BV(COM1B1);
|
||||
TCCR1B = _BV(WGM12) | _BV(WGM13) | _BV(CS11);
|
||||
ICR1=TICKS_OF_US(SERVO_REFRESH);
|
||||
ant_servo_set(NEUTRAL_SERVO, NEUTRAL_SERVO);
|
||||
}
|
||||
|
||||
void ant_servo_set ( uint16_t value1_us, uint16_t value2_us) {
|
||||
/* code pour regler la valeur en ms a l'etat haut du signal PWM */
|
||||
Bound(value1_us, MIN_SERVO, MAX_SERVO);
|
||||
OCR1A = TICKS_OF_US(value1_us);
|
||||
Bound(value2_us, MIN_SERVO, MAX_SERVO);
|
||||
OCR1B = TICKS_OF_US(value2_us);
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
#ifndef ANT_SERVO_H
|
||||
#define ANT_SERVO_H
|
||||
|
||||
#include "std.h"
|
||||
|
||||
#define MAX_SERVO 2000
|
||||
#define NEUTRAL_SERVO 1500
|
||||
#define MIN_SERVO 1000
|
||||
|
||||
void ant_servo_init( void );
|
||||
void ant_servo_set ( uint16_t value1_us, uint16_t value2_us);
|
||||
|
||||
#endif /* ANT_SERVO_H */
|
||||
@@ -1,71 +0,0 @@
|
||||
#include "ant_spi.h"
|
||||
|
||||
#include <avr/io.h>
|
||||
#include "std.h"
|
||||
|
||||
|
||||
/*********************************Flush SPI*****************************************/
|
||||
|
||||
|
||||
void flush_SPI( void )
|
||||
{
|
||||
if (bit_is_set(SPSR, SPIF))
|
||||
{
|
||||
uint8_t foo __attribute__ ((unused)) = SPDR;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*****************************Initialisation SPI************************************/
|
||||
|
||||
#define DDR_SPI DDRB
|
||||
#define PORT_SPI PORTB
|
||||
#define PIN_SS 0
|
||||
#define PIN_SCK 1
|
||||
#define PIN_MOSI 2
|
||||
#define PIN_SYNC 4
|
||||
|
||||
void SPI_select_slave ( void )
|
||||
{
|
||||
ClearBit(PORT_SPI, PIN_SS);
|
||||
}
|
||||
|
||||
/***********************************************************************************/
|
||||
|
||||
void SPI_unselect_slave ( void )
|
||||
{
|
||||
SetBit(PORT_SPI, PIN_SS);
|
||||
}
|
||||
|
||||
/***********************************************************************************/
|
||||
|
||||
void SPI_master_init( void )
|
||||
{
|
||||
/* Set SS, MOSI and SCK output, all others input */
|
||||
DDR_SPI |= _BV(PIN_SS) | _BV(PIN_SCK) | _BV(PIN_MOSI);
|
||||
/* unselect slave */
|
||||
SPI_unselect_slave();
|
||||
/* Enable SPI, Master, MSB first, clock idle low, sample on leading edge, clock rate fck/128 */
|
||||
SPCR = ( _BV(SPE)| _BV(MSTR) | _BV(SPR1) | _BV(SPR0));
|
||||
}
|
||||
|
||||
/***********************************************************************************/
|
||||
|
||||
void SPI_start( void )
|
||||
{
|
||||
SPI_select_slave();
|
||||
if (bit_is_set(SPSR, SPIF)) {
|
||||
uint8_t foo __attribute__ ((unused)) = SPDR;
|
||||
}
|
||||
/* enable interrupt */
|
||||
SetBit(SPCR,SPIE);
|
||||
}
|
||||
|
||||
/***********************************************************************************/
|
||||
|
||||
void SPI_stop(void)
|
||||
{
|
||||
SPI_unselect_slave ();
|
||||
/* disable interrupt */
|
||||
ClearBit(SPCR,SPIE);
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
#ifndef ANT_SPI_H
|
||||
#define ANT_SPI_H
|
||||
|
||||
#include "std.h"
|
||||
|
||||
#include <avr/io.h>
|
||||
#include "std.h"
|
||||
|
||||
void flush_SPI( void );
|
||||
void SPI_select_slave ( void );
|
||||
void SPI_unselect_slave ( void );
|
||||
void SPI_master_init( void );
|
||||
void SPI_start( void );
|
||||
void SPI_stop( void );
|
||||
|
||||
#define SPI_transmit(c) { SPDR = c; }
|
||||
#define SPI_read() (SPDR)
|
||||
|
||||
#endif /* ANT_SPI_H */
|
||||
@@ -1,37 +0,0 @@
|
||||
#include "ant_tracker.h"
|
||||
|
||||
#include "subsystems/navigation/traffic_info.h"
|
||||
|
||||
uint8_t ant_track_mode;
|
||||
float ant_track_azim;
|
||||
float ant_track_elev;
|
||||
uint8_t ant_track_id;
|
||||
|
||||
int32_t nav_utm_east0;
|
||||
int32_t nav_utm_north0;
|
||||
uint8_t nav_utm_zone0;
|
||||
const float ant_track_gnd_alt = 185.;
|
||||
|
||||
void ant_tracker_init( void ) {
|
||||
// nav_utm_east0 = ;
|
||||
// nav_utm_north0 = ;
|
||||
// nav_utm_zone0 = ;
|
||||
ant_track_id = 5;
|
||||
ant_track_mode = ANT_TRACK_AUTO;
|
||||
ant_track_azim = 0.;
|
||||
ant_track_elev = 0.;
|
||||
}
|
||||
|
||||
void ant_tracker_periodic( void ) {
|
||||
if (ant_track_mode == ANT_TRACK_AUTO) {
|
||||
struct ac_info_ * ac = get_ac_info(ant_track_id);
|
||||
ant_track_azim = atan2(ac->north, ac->east) * 180. / M_PI;
|
||||
ant_track_azim = 90. - ant_track_azim;
|
||||
if (ant_track_azim < 0)
|
||||
ant_track_azim += 360.;
|
||||
float dist = sqrt(ac->north*ac->north + ac->east*ac->east);
|
||||
if ( dist < 1.) dist = 1.;
|
||||
float height = ac->alt - ant_track_elev;
|
||||
ant_track_elev = atan2( height, dist) * 180. / M_PI;
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
#ifndef ANT_TRACKER_H
|
||||
#define ANT_TRACKER_H
|
||||
|
||||
#include "std.h"
|
||||
|
||||
#define ANT_TRACK_MANUAL 0
|
||||
#define ANT_TRACK_AUTO 1
|
||||
|
||||
extern uint8_t ant_track_mode;
|
||||
extern float ant_track_azim;
|
||||
extern float ant_track_elev;
|
||||
extern uint8_t ant_track_id;
|
||||
|
||||
#include "led.h"
|
||||
|
||||
#define ant_tracker_SetId(i) { ant_track_id = i; }
|
||||
#define ant_tracker_SetMode(i) \
|
||||
{ \
|
||||
ant_track_mode = i; \
|
||||
if(ant_track_mode) \
|
||||
LED_ON(2); \
|
||||
else \
|
||||
LED_OFF(2); \
|
||||
}
|
||||
|
||||
|
||||
extern void ant_tracker_init( void );
|
||||
extern void ant_tracker_periodic( void );
|
||||
#endif /* ANT_TRACKER_H */
|
||||
@@ -1,258 +0,0 @@
|
||||
#include "ant_v2x.h"
|
||||
|
||||
#include <avr/io.h>
|
||||
#include <avr/interrupt.h>
|
||||
|
||||
//#include "stdlib.h"
|
||||
#include "string.h"
|
||||
#include "std.h"
|
||||
//#include "systime.h"
|
||||
//#include "signalisation.h"
|
||||
//#include "utils.h"
|
||||
|
||||
#include "ant_spi.h"
|
||||
|
||||
//#include "subsystems/datalink/downlink.h"
|
||||
|
||||
volatile bool_t ant_v2x_data_available;
|
||||
struct Ant_V2xData ant_v2x_data;
|
||||
|
||||
|
||||
#define MAG_S_RESET 0
|
||||
#define MAG_S_UNINIT 1
|
||||
#define MAG_S_READY 2
|
||||
#define MAG_S_WAIT_MEAS 3
|
||||
volatile uint8_t ant_v2x_status;
|
||||
|
||||
#define MAG_CS_IDLE 0
|
||||
#define MAG_CS_READING 1
|
||||
#define MAG_CS_WRITING 2
|
||||
volatile uint8_t ant_v2x_com_status;
|
||||
|
||||
|
||||
uint8_t ant_v2x_req[64];
|
||||
uint8_t ant_v2x_req_len;
|
||||
volatile uint8_t ant_v2x_req_idx;
|
||||
|
||||
uint8_t ant_v2x_res[128];
|
||||
uint8_t ant_v2x_res_len;
|
||||
volatile uint8_t ant_v2x_res_idx;
|
||||
|
||||
volatile uint8_t ant_v2x_periodic_count;
|
||||
|
||||
/******************************Ant_V2x define************************************/
|
||||
|
||||
#define ANT_V2X_DDR DDRB
|
||||
#define ANT_V2X_PORT PORTB
|
||||
#define ANT_V2X_PIN 4
|
||||
|
||||
#define SYNC_FLAG 0xAA
|
||||
#define TERMINATOR 0x00
|
||||
|
||||
#define GET_MODE_INFO 0x01
|
||||
#define MOD_INFO_RESP 0x02
|
||||
#define SET_DATA_COMPONENTS 0x03
|
||||
#define GET_DATA 0x04
|
||||
#define DATA_RESP 0x05
|
||||
#define SET_CONFIG 0x06
|
||||
#define GET_CONFIG 0x07
|
||||
#define CONFIG_RESP 0x08
|
||||
#define SAVE_CONFIG 0x09
|
||||
#define START_CAL 0x0A
|
||||
#define STOP_CAL 0x0B
|
||||
#define GET_CAL_DATA 0x0C
|
||||
#define CAL_DATA_RESP 0x0D
|
||||
#define SET_CAL_DATA 0x0E
|
||||
|
||||
#define DATA_XRAW 0x01 // Slnt32 counts 32768 to 32767
|
||||
#define DATA_YRAW 0x02 // Slnt32 counts 32768 to 32767
|
||||
#define DATA_XCAL 0x03 // Float32 scaled to 1.0
|
||||
#define DATA_YCAL 0x04 // Float32 scaled to 1.0
|
||||
#define DATA_HEADING 0x05 // Float32 degrees 0.0 <B0> to 359.9 <B0>
|
||||
#define DATA_MAGNITUDE 0x06 // Float32 scalebreak;
|
||||
#define DATA_TEMPERATURE 0x07 // Float32 <B0> Celsius
|
||||
#define DATA_DISTORTION 0x08 // Boolean
|
||||
#define DATA_CAL_STATUS 0x09 // Boolean
|
||||
|
||||
|
||||
extern void ant_v2x_periodic_initialise(void);
|
||||
extern void ant_v2x_send_req ( const uint8_t* req, uint8_t len);
|
||||
extern void ant_v2x_send_get_data ( void );
|
||||
|
||||
|
||||
/***************************Initialisation ant_v2x*******************************/
|
||||
|
||||
void ant_v2x_init( void )
|
||||
{
|
||||
SPI_master_init();
|
||||
/* set sync as ouptut */
|
||||
SetBit(ANT_V2X_DDR, ANT_V2X_PIN);
|
||||
/* pull it down */
|
||||
SetBit(ANT_V2X_PORT, ANT_V2X_PIN);
|
||||
|
||||
ant_v2x_data_available = FALSE;
|
||||
ant_v2x_com_status = MAG_CS_IDLE;
|
||||
|
||||
ant_v2x_data.heading = 0.;
|
||||
|
||||
ant_v2x_reset();
|
||||
}
|
||||
|
||||
|
||||
void ant_v2x_periodic_initialise( void ) {
|
||||
static uint8_t init_status = 0;
|
||||
if (ant_v2x_com_status != MAG_CS_IDLE)
|
||||
return;
|
||||
switch (init_status) {
|
||||
case 0 : /* set data response format */
|
||||
{
|
||||
const uint8_t req[] = {SET_DATA_COMPONENTS, 0x08, DATA_XRAW, DATA_YRAW, DATA_XCAL, DATA_YCAL, DATA_HEADING, DATA_MAGNITUDE, DATA_DISTORTION, DATA_CAL_STATUS };
|
||||
ant_v2x_send_req(req, sizeof(req));
|
||||
}
|
||||
break;
|
||||
case 1 : /* set little endian */
|
||||
{
|
||||
const uint8_t req[] = {SET_CONFIG, 0x06, 0x00};
|
||||
ant_v2x_send_req(req, sizeof(req));
|
||||
}
|
||||
break;
|
||||
case 2 :
|
||||
{ /* set period */
|
||||
const uint8_t req[] = {SET_CONFIG, 0x05, 0x07};
|
||||
ant_v2x_send_req(req, sizeof(req));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
ant_v2x_status = MAG_S_READY;
|
||||
}
|
||||
init_status++;
|
||||
}
|
||||
void ant_v2x_periodic( void ) { /* Run initialisation and communication request */
|
||||
switch (ant_v2x_status) {
|
||||
case MAG_S_RESET:
|
||||
SetBit(ANT_V2X_PORT, ANT_V2X_PIN);
|
||||
ant_v2x_status = MAG_S_UNINIT;
|
||||
break;
|
||||
case MAG_S_UNINIT:
|
||||
ant_v2x_periodic_initialise();
|
||||
break;
|
||||
case MAG_S_READY: /* Ready to receive request */
|
||||
/*GREEN_LED_ON();*/
|
||||
/*YELLOW_LED_OFF();*/
|
||||
// if (ant_v2x_data_available) return
|
||||
ant_v2x_send_get_data();
|
||||
ant_v2x_status = MAG_S_WAIT_MEAS;
|
||||
ant_v2x_periodic_count = 0;
|
||||
break;
|
||||
case MAG_S_WAIT_MEAS: { /* Waiting for measures */
|
||||
ant_v2x_periodic_count++;
|
||||
if (ant_v2x_periodic_count > 5) {
|
||||
ant_v2x_com_status = MAG_CS_READING;
|
||||
SPI_start();
|
||||
ant_v2x_res_idx = 0;
|
||||
ant_v2x_res_len = 43;
|
||||
SPI_transmit(0x00);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************Ant_V2x reset****************************************/
|
||||
void ant_v2x_reset (void){
|
||||
ClearBit(ANT_V2X_PORT, ANT_V2X_PIN);
|
||||
ant_v2x_status = MAG_S_RESET;
|
||||
ant_v2x_com_status = MAG_CS_IDLE;
|
||||
}
|
||||
|
||||
/**************************Ant_V2x data communication******************************/
|
||||
void ant_v2x_send_get_data ( void ) {
|
||||
const uint8_t req[] = {GET_DATA};
|
||||
ant_v2x_send_req(req, sizeof(req));
|
||||
}
|
||||
|
||||
/********************************Request procedure***********************************/
|
||||
void ant_v2x_send_req(const uint8_t* req, uint8_t len) {
|
||||
memcpy(ant_v2x_req, req, len);
|
||||
ant_v2x_req_len = len;
|
||||
ant_v2x_req_idx = 0;
|
||||
ant_v2x_com_status = MAG_CS_WRITING;
|
||||
SPI_start();
|
||||
SPI_transmit(SYNC_FLAG);/* transmit SYNC_FLAG first for every beginning of transmition */
|
||||
}
|
||||
|
||||
void ant_v2x_read_data( void ) {
|
||||
ant_v2x_data.xraw = *(int32_t*)&ant_v2x_res[4];
|
||||
ant_v2x_data.yraw = *(int32_t*)&ant_v2x_res[9];
|
||||
ant_v2x_data.xcal = *(float*)&ant_v2x_res[14];
|
||||
ant_v2x_data.ycal = *(float*)&ant_v2x_res[19];
|
||||
ant_v2x_data.heading = *(float*)&ant_v2x_res[24];
|
||||
ant_v2x_data.magnitude = *(float*)&ant_v2x_res[29];
|
||||
ant_v2x_data.temp = *(float*)&ant_v2x_res[34];
|
||||
ant_v2x_data.distor = *(int8_t*)&ant_v2x_res[39];
|
||||
ant_v2x_data.cal_status = *(int8_t*)&ant_v2x_res[41];
|
||||
}
|
||||
|
||||
|
||||
#define SPI_SIG_ON_WRITING() { \
|
||||
uint8_t c __attribute__ ((unused)) = SPI_read(); \
|
||||
if (ant_v2x_req_idx < ant_v2x_req_len) { \
|
||||
SPI_transmit(ant_v2x_req[ant_v2x_req_idx]); \
|
||||
} \
|
||||
else if (ant_v2x_req_idx == ant_v2x_req_len) { \
|
||||
SPI_transmit(TERMINATOR); \
|
||||
} \
|
||||
else { \
|
||||
ant_v2x_com_status = MAG_CS_IDLE; \
|
||||
SPI_stop(); \
|
||||
} \
|
||||
ant_v2x_req_idx++; \
|
||||
}
|
||||
|
||||
|
||||
static uint8_t nb_retry = 0;
|
||||
#define MAX_RETRY 10
|
||||
|
||||
#define SPI_SIG_ON_READING() { \
|
||||
ant_v2x_res[ant_v2x_res_idx] = SPI_read(); \
|
||||
if (ant_v2x_res_idx == 0) { \
|
||||
if (nb_retry > MAX_RETRY) { \
|
||||
ant_v2x_reset(); \
|
||||
nb_retry = 0; \
|
||||
/*YELLOW_LED_ON();*/ \
|
||||
goto sig_exit; \
|
||||
} \
|
||||
if (ant_v2x_res[ant_v2x_res_idx] != SYNC_FLAG) { \
|
||||
nb_retry++; \
|
||||
SPI_transmit(0x00); \
|
||||
goto sig_exit; \
|
||||
} \
|
||||
else { \
|
||||
nb_retry = 0; \
|
||||
} \
|
||||
} \
|
||||
ant_v2x_res_idx++; \
|
||||
if (ant_v2x_res_idx < ant_v2x_res_len) { \
|
||||
SPI_transmit(0x00); \
|
||||
} \
|
||||
else { \
|
||||
ant_v2x_com_status = MAG_CS_IDLE; \
|
||||
SPI_stop(); \
|
||||
ant_v2x_status = MAG_S_READY; \
|
||||
ant_v2x_data_available = TRUE; \
|
||||
/*GREEN_LED_OFF();*/ \
|
||||
} \
|
||||
} \
|
||||
|
||||
SIGNAL(SIG_SPI) {
|
||||
switch ( ant_v2x_com_status) {
|
||||
case MAG_CS_WRITING:
|
||||
SPI_SIG_ON_WRITING();
|
||||
break;
|
||||
case MAG_CS_READING:
|
||||
SPI_SIG_ON_READING();
|
||||
}
|
||||
sig_exit:
|
||||
/*GREEN_LED_OFF();*/
|
||||
asm("nop");
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
#ifndef ANT_V2X_H
|
||||
#define ANT_V2X_H
|
||||
|
||||
#include "std.h"
|
||||
|
||||
extern void ant_v2x_init( void );
|
||||
extern void ant_v2x_periodic(void);
|
||||
extern bool_t ant_v2x_is_in_calibration(void);
|
||||
extern void ant_v2x_reset( void );
|
||||
extern void ant_v2x_read_data( void );
|
||||
|
||||
struct Ant_V2xConfig
|
||||
{
|
||||
float declination;
|
||||
uint8_t true_north;
|
||||
uint8_t cal_sample_freq;
|
||||
uint8_t sample_freq;
|
||||
uint8_t period;
|
||||
uint8_t big_idian;
|
||||
uint8_t damping_size;
|
||||
};
|
||||
|
||||
struct Ant_V2xData
|
||||
{
|
||||
int32_t xraw;
|
||||
int32_t yraw;
|
||||
float xcal;
|
||||
float ycal;
|
||||
float heading;
|
||||
float magnitude;
|
||||
float temp;
|
||||
uint8_t distor;
|
||||
uint8_t cal_status;
|
||||
};
|
||||
|
||||
struct Ant_V2xCal
|
||||
{
|
||||
int8_t byte_count;
|
||||
int32_t x_offset;
|
||||
int32_t y_offset;
|
||||
int32_t x_gain;
|
||||
int32_t y_gain;
|
||||
float phi;
|
||||
float cal_magnitude;
|
||||
};
|
||||
|
||||
extern volatile bool_t ant_v2x_data_available;
|
||||
extern struct Ant_V2xData ant_v2x_data;
|
||||
|
||||
#endif /* ANT_V2X_H */
|
||||
|
||||
@@ -1,103 +0,0 @@
|
||||
#include "dc_mc_link.h"
|
||||
|
||||
#include <avr/interrupt.h>
|
||||
#include <avr/io.h>
|
||||
|
||||
/*
|
||||
Slave address
|
||||
front = 0x52
|
||||
back = 0x54
|
||||
right = 0x56
|
||||
left = 0x58
|
||||
*/
|
||||
#define DC_MC_LINK_TWI_ADDR 0x52
|
||||
#define DC_MC_LINK_TIMEOUT 60
|
||||
|
||||
volatile uint8_t dc_mc_link_event;
|
||||
uint16_t dc_mc_link_command;
|
||||
uint8_t dc_mc_link_timeout;
|
||||
|
||||
#define DC_MC_LINK_TWI_RX_BUF_LEN 16
|
||||
uint8_t dc_mc_link_twi_rx_buf[DC_MC_LINK_TWI_RX_BUF_LEN];
|
||||
uint8_t dc_mc_link_twi_rx_buf_idx;
|
||||
|
||||
|
||||
void dc_mc_link_init(void) {
|
||||
dc_mc_link_event = FALSE;
|
||||
dc_mc_link_command = 0;
|
||||
dc_mc_link_timeout = DC_MC_LINK_TIMEOUT;
|
||||
|
||||
/* setup slave addr */
|
||||
TWAR = 0x52;
|
||||
/* clear and enable interrupt - enable peripheral and ack bit */
|
||||
TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWIE) | (1<<TWEA);
|
||||
|
||||
}
|
||||
|
||||
void dc_mc_link_periodic(void) {
|
||||
if (dc_mc_link_timeout >= DC_MC_LINK_TIMEOUT)
|
||||
dc_mc_link_command = 0;
|
||||
else
|
||||
dc_mc_link_timeout++;
|
||||
}
|
||||
|
||||
#define TWI_BUS_ERR_1 0x00
|
||||
#define TWI_BUS_ERR_2 0xF8
|
||||
|
||||
// Status Slave RX Mode
|
||||
#define SR_SLA_ACK 0x60
|
||||
#define SR_LOST_ACK 0x68
|
||||
#define SR_GEN_CALL_ACK 0x70
|
||||
#define GEN_LOST_ACK 0x78
|
||||
#define SR_PREV_ACK 0x80
|
||||
#define SR_PREV_NACK 0x88
|
||||
#define GEN_PREV_ACK 0x90
|
||||
#define GEN_PREV_NACK 0x98
|
||||
#define STOP_CONDITION 0xA0
|
||||
#define REPEATED_START 0xA0
|
||||
|
||||
// Status Slave TX mode
|
||||
#define SW_SLA_ACK 0xA8
|
||||
#define SW_LOST_ACK 0xB0
|
||||
#define SW_DATA_ACK 0xB8
|
||||
#define SW_DATA_NACK 0xC0
|
||||
#define SW_LAST_ACK 0xC8
|
||||
|
||||
#include "led.h"
|
||||
|
||||
ISR (TWI_vect) {
|
||||
switch (TWSR & 0xF8) {
|
||||
case SR_SLA_ACK:
|
||||
// LED_OFF(1);
|
||||
dc_mc_link_twi_rx_buf_idx = 0;
|
||||
TWCR |= _BV(TWINT) | _BV(TWEA);
|
||||
break;
|
||||
case SR_PREV_ACK:
|
||||
dc_mc_link_twi_rx_buf[dc_mc_link_twi_rx_buf_idx] = TWDR;
|
||||
dc_mc_link_twi_rx_buf_idx++;
|
||||
if (dc_mc_link_twi_rx_buf_idx <= 2)
|
||||
TWCR |= _BV(TWINT) | _BV(TWEA);
|
||||
else
|
||||
TWCR |= _BV(TWINT);
|
||||
break;
|
||||
case STOP_CONDITION:
|
||||
TWCR |= _BV(TWINT);
|
||||
dc_mc_link_timeout = 0;
|
||||
// LED_ON(1);
|
||||
dc_mc_link_event = TRUE;
|
||||
break;
|
||||
case SW_SLA_ACK:
|
||||
case SW_DATA_ACK:
|
||||
TWCR |= (1<<TWINT);
|
||||
break;
|
||||
case TWI_BUS_ERR_2:
|
||||
case TWI_BUS_ERR_1:
|
||||
TWCR |=(1<<TWSTO) | (1<<TWINT);
|
||||
TWCR =(1<<TWEA) | (1<<TWINT) | (1<<TWEN) | (1<<TWIE); // TWI Reset
|
||||
break;
|
||||
|
||||
// default:
|
||||
// LED_TOGGLE(1);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
#ifndef DC_MC_LINK_H
|
||||
#define DC_MC_LINK_H
|
||||
|
||||
#include "std.h"
|
||||
|
||||
extern volatile uint8_t dc_mc_link_event;
|
||||
extern uint16_t dc_mc_link_command;
|
||||
extern uint8_t dc_mc_link_twi_rx_buf[];
|
||||
|
||||
extern void dc_mc_link_init(void);
|
||||
extern void dc_mc_link_periodic(void);
|
||||
|
||||
|
||||
#endif /* DC_MC_LINK_H */
|
||||
@@ -1,30 +0,0 @@
|
||||
#include "dc_mc_power.h"
|
||||
|
||||
#include <avr/io.h>
|
||||
|
||||
// swicthing freq = CLOCK / RESOLUTION
|
||||
// 13 bits -> 1953 Hz
|
||||
#define DC_MC_POWER_RESOLUTION 0x1FFF
|
||||
// 12 bits -> 3906 Hz
|
||||
//#define DC_MC_POWER_RESOLUTION 0xFFF
|
||||
// 11 bits -> 7812 Hz
|
||||
//#define DC_MC_POWER_RESOLUTION 0x7FF
|
||||
// 10 bits -> 15625 Hz
|
||||
//#define DC_MC_POWER_RESOLUTION 0x3FF
|
||||
|
||||
|
||||
void dc_mc_power_init(void) {
|
||||
/* OC1A output */
|
||||
DDRB |= _BV(1);
|
||||
|
||||
/* fast PWM TOP in ICR1 match in OCR1A */
|
||||
ICR1 = DC_MC_POWER_RESOLUTION;
|
||||
TCCR1A |= _BV(WGM11) | _BV(COM1A1);
|
||||
TCCR1B |= _BV(WGM12) | _BV(WGM13);
|
||||
}
|
||||
|
||||
|
||||
void dc_mc_power_set( uint16_t val) {
|
||||
OCR1A = val * ((float)DC_MC_POWER_RESOLUTION / 65535.);
|
||||
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
#ifndef DC_MC_POWER_H
|
||||
#define DC_MC_POWER_H
|
||||
|
||||
#include "std.h"
|
||||
|
||||
extern void dc_mc_power_init(void);
|
||||
extern void dc_mc_power_set( uint16_t val);
|
||||
|
||||
|
||||
#endif /* DC_MC_POWER_H */
|
||||
@@ -1,6 +0,0 @@
|
||||
#ifndef GPIO_H
|
||||
#define GPIO_H
|
||||
|
||||
|
||||
|
||||
#endif /* GPIO_H */
|
||||
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005 Pascal Brisset, Antoine Drouin
|
||||
*
|
||||
* 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 interrupt_hw.h
|
||||
* \brief AVR Low level interrupt handling
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef INTERRUPT_HW_H
|
||||
#define INTERRUPT_HW_H
|
||||
|
||||
#include <avr/interrupt.h>
|
||||
|
||||
#define int_enable() sei()
|
||||
|
||||
#endif /* INTERRUPT_HW_H */
|
||||
@@ -1,23 +0,0 @@
|
||||
#ifndef LED_HW_H
|
||||
#define LED_HW_H
|
||||
|
||||
#include CONFIG
|
||||
#include <avr/io.h>
|
||||
|
||||
#define __LED_PORT(p) PORT ## p
|
||||
#define _LED_PORT(p) __LED_PORT(p)
|
||||
#define __LED_DDR(p) DDR ## p
|
||||
#define _LED_DDR(p) __LED_DDR(p)
|
||||
|
||||
#define LED_DDR(x) _LED_DDR(LED_ ## x ## _BANK)
|
||||
#define LED_PORT(x) _LED_PORT(LED_ ## x ## _BANK)
|
||||
#define LED_PIN(x) LED_ ## x ## _PIN
|
||||
|
||||
/* set pin as output */
|
||||
#define LED_INIT(i) LED_DDR(i) |= _BV(LED_PIN(i))
|
||||
|
||||
#define LED_ON(i) LED_PORT(i) &= ~_BV(LED_PIN(i))
|
||||
#define LED_OFF(i) LED_PORT(i) |= _BV(LED_PIN(i))
|
||||
#define LED_TOGGLE(i) LED_PORT(i) ^= _BV(LED_PIN(i))
|
||||
|
||||
#endif /* LED_HW_H */
|
||||
@@ -1,43 +0,0 @@
|
||||
/* $Id$
|
||||
*
|
||||
* Copyright (C) 2003-2005 Pascal Brisset, Antoine Drouin
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/** \brief handling of avr inter mcu link
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef LINK_MCU_HW_H
|
||||
#define LINK_MCU_HW_H
|
||||
|
||||
#if (__GNUC__ == 3)
|
||||
#include <avr/signal.h>
|
||||
#include <avr/crc16.h>
|
||||
#else
|
||||
#include <util/crc16.h>
|
||||
#endif
|
||||
|
||||
#define CRC_INIT 0xffff
|
||||
#define CrcUpdate(_crc, _data) _crc_ccitt_update(_crc, _data)
|
||||
|
||||
#endif /* LINK_MCU_HW_H */
|
||||
@@ -1,167 +0,0 @@
|
||||
/*
|
||||
* Paparazzi AVR adc functions
|
||||
*
|
||||
* Copyright (C) 2006 Pascal Brisset, Antoine Drouin, Michel Gorraz
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
//// ADC3 MVSUP
|
||||
//// ADC6 MVSERVO
|
||||
|
||||
|
||||
#if (__GNUC__ == 3)
|
||||
#include <avr/signal.h>
|
||||
#endif
|
||||
#include <avr/interrupt.h>
|
||||
#include <avr/io.h>
|
||||
#include "mcu_periph/adc.h"
|
||||
#include "std.h"
|
||||
|
||||
|
||||
static struct adc_buf* buffers[NB_ADC];
|
||||
|
||||
void adc_buf_channel(uint8_t adc_channel, struct adc_buf* s, uint8_t av_nb_sample) {
|
||||
buffers[adc_channel] = s;
|
||||
s->av_nb_sample = av_nb_sample;
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************/
|
||||
#if defined (__AVR_ATmega8__)
|
||||
|
||||
|
||||
#define VOLTAGE_TIME 0x07
|
||||
#define ANALOG_PORT PORTC
|
||||
#define ANALOG_PORT_DIR DDRC
|
||||
|
||||
|
||||
#ifdef IMU_ANALOG
|
||||
#define ANALOG_VREF _BV(REFS0)
|
||||
#else
|
||||
#define ANALOG_VREF _BV(REFS0) | _BV(REFS1)
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Called when the voltage conversion is finished
|
||||
*
|
||||
* 8.913kHz on mega128 16MHz 1kHz/channel ??
|
||||
*/
|
||||
SIGNAL( SIG_ADC )
|
||||
{
|
||||
uint8_t adc_input = ADMUX & 0x7;
|
||||
struct adc_buf* buf = buffers[adc_input];
|
||||
uint16_t adc_value = ADCW;
|
||||
|
||||
if (buf) {
|
||||
uint8_t new_head = buf->head + 1;
|
||||
if (new_head >= buf->av_nb_sample) new_head = 0;
|
||||
buf->sum -= buf->values[new_head];
|
||||
buf->values[new_head] = adc_value;
|
||||
buf->sum += adc_value;
|
||||
buf->head = new_head;
|
||||
}
|
||||
|
||||
/* Find the next input */
|
||||
adc_input++;
|
||||
if (adc_input == 4)
|
||||
adc_input = 6; // ADC 4 and 5 for i2c
|
||||
if( adc_input >= 8 ) {
|
||||
adc_input = 0;
|
||||
#ifdef CTL_BRD_V1_2
|
||||
adc_input = 1; // WARNING ADC0 is for rservo driver reset on v1.2.0
|
||||
#endif /* CTL_BRD_V1_2 */
|
||||
}
|
||||
/* Select it */
|
||||
ADMUX = adc_input | ANALOG_VREF;
|
||||
/* Restart the conversion */
|
||||
sbi( ADCSR, ADSC );
|
||||
}
|
||||
|
||||
#endif /* (__AVR_ATmega8__) */
|
||||
|
||||
|
||||
|
||||
|
||||
/************************************************************************/
|
||||
#if defined (__AVR_ATmega128__)
|
||||
|
||||
#define VOLTAGE_TIME 0x07
|
||||
#define ANALOG_PORT PORTF
|
||||
#define ANALOG_PORT_DIR DDRF
|
||||
|
||||
|
||||
#define ANALOG_VREF _BV(REFS0)
|
||||
|
||||
|
||||
/**
|
||||
* Called when the voltage conversion is finished
|
||||
*
|
||||
* 8.913kHz on mega128 16MHz 1kHz/channel ??
|
||||
*/
|
||||
SIGNAL( SIG_ADC )
|
||||
{
|
||||
uint8_t adc_input = ADMUX & 0x7;
|
||||
struct adc_buf* buf = buffers[adc_input];
|
||||
uint16_t adc_value = ADCW;
|
||||
|
||||
if (buf) {
|
||||
uint8_t new_head = buf->head + 1;
|
||||
if (new_head >= buf->av_nb_sample) new_head = 0;
|
||||
buf->sum -= buf->values[new_head];
|
||||
buf->values[new_head] = adc_value;
|
||||
buf->sum += adc_value;
|
||||
buf->head = new_head;
|
||||
}
|
||||
|
||||
/* Find the next input */
|
||||
adc_input++;
|
||||
if( adc_input >= 8 )
|
||||
adc_input = 0;
|
||||
/* Select it */
|
||||
ADMUX = adc_input | ANALOG_VREF;
|
||||
/* Restart the conversion */
|
||||
sbi( ADCSR, ADSC );
|
||||
}
|
||||
#endif /* (__AVR_ATmega128__) */
|
||||
|
||||
|
||||
|
||||
void adc_init( void ) {
|
||||
uint8_t i;
|
||||
/* Ensure that our port is for input with no pull-ups */
|
||||
ANALOG_PORT = 0x00;
|
||||
ANALOG_PORT_DIR = 0x00;
|
||||
|
||||
/* Select our external voltage ref */
|
||||
ADMUX = ANALOG_VREF;
|
||||
|
||||
/* Select out clock, turn on the ADC interrupt and start conversion */
|
||||
ADCSRA = 0
|
||||
| VOLTAGE_TIME
|
||||
| _BV(ADEN )
|
||||
| _BV(ADIE )
|
||||
| _BV(ADSC );
|
||||
|
||||
/* Init to 0 (usefull ?) */
|
||||
for(i = 0; i < NB_ADC; i++)
|
||||
buffers[i] = (struct adc_buf*)0;
|
||||
}
|
||||
@@ -1,165 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005 Pascal Brisset, Antoine Drouin
|
||||
*
|
||||
* 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 i2c_ap.c
|
||||
* \brief Basic library for I2C
|
||||
*
|
||||
*/
|
||||
|
||||
#include <avr/signal.h>
|
||||
#include <avr/interrupt.h>
|
||||
#include "i2c_ap.h"
|
||||
#include "std.h"
|
||||
|
||||
|
||||
#define TWI_START 0x08
|
||||
#define TWI_RESTART 0x10
|
||||
#define MT_SLA_ACK 0x18
|
||||
#define MT_SLA_NACK 0x20
|
||||
#define MR_SLA_ACK 0x40
|
||||
#define MR_SLA_NACK 0x48
|
||||
#define MT_DATA_ACK 0x28
|
||||
#define MR_DATA_ACK 0x50
|
||||
#define MR_DATA_NACK 0x58
|
||||
|
||||
uint8_t twi_sla;
|
||||
uint8_t i2c_buf[TWI_BUF_LEN];
|
||||
uint8_t twi_index, twi_len;
|
||||
volatile bool_t i2c_idle;
|
||||
uint8_t i2c_debug;
|
||||
static bool_t *twi_end;
|
||||
|
||||
#define I2cStart() i2c_idle = FALSE; *twi_end = FALSE; TWCR=_BV(TWINT)|_BV(TWSTA)|_BV(TWEN)|_BV(TWIE);
|
||||
#define I2cStop() i2c_idle= TRUE; *twi_end = TRUE; TWCR=_BV(TWINT)|_BV(TWSTO)|_BV(TWEN);
|
||||
#define I2cReceive(_ack) TWCR=_BV(TWINT)|_BV(TWEN)| (_ack ? _BV(TWEA) : 0)|_BV(TWIE);
|
||||
#define I2cReceiveAck TWCR=_BV(TWINT)|_BV(TWEN)| _BV(TWEA) |_BV(TWIE);
|
||||
#define I2cReceiveNAck TWCR=_BV(TWINT)|_BV(TWEN)| _BV(TWIE);
|
||||
|
||||
#define I2cSendByte(a) { \
|
||||
TWDR= a; \
|
||||
TWCR=_BV(TWINT)|_BV(TWEN)|_BV(TWIE); \
|
||||
}
|
||||
|
||||
#define I2cSendSlaW(a) I2cSendSla(a | I2C_WRITE)
|
||||
#define I2cSendSlaR(a) I2cSendSla(a | I2C_READ)
|
||||
|
||||
|
||||
SIGNAL(SIG_2WIRE_SERIAL) {
|
||||
// i2c_debug = TWSR;
|
||||
switch (TWSR & 0xF8) {
|
||||
case TWI_START:
|
||||
case TWI_RESTART:
|
||||
I2cSendByte(twi_sla);
|
||||
twi_index = 0;
|
||||
break;
|
||||
case MR_DATA_ACK:
|
||||
i2c_buf[twi_index] = TWDR;
|
||||
twi_index++;
|
||||
/* Continue */
|
||||
case MR_SLA_ACK: /* At least one char */
|
||||
I2cReceive(twi_len>twi_index+1); /* Wait and reply with ACK or NACK */
|
||||
break;
|
||||
case MR_SLA_NACK:
|
||||
case MT_SLA_NACK:
|
||||
I2cStart();
|
||||
break;
|
||||
case MT_SLA_ACK:
|
||||
case MT_DATA_ACK:
|
||||
if (twi_index < twi_len) {
|
||||
I2cSendByte(i2c_buf[twi_index]);
|
||||
twi_index++;
|
||||
return;
|
||||
} /* Else Stop */
|
||||
case MR_DATA_NACK:
|
||||
i2c_debug = twi_index;
|
||||
i2c_buf[twi_index] = TWDR;
|
||||
/* Then Stop */
|
||||
default:
|
||||
I2cStop();
|
||||
}
|
||||
}
|
||||
|
||||
void i2c_send(uint8_t sla, uint8_t _twi_len, bool_t* finished) {
|
||||
i2c_debug = 0x32;
|
||||
twi_len = _twi_len;
|
||||
twi_sla = I2C_TRANSMIT | sla;
|
||||
twi_end = finished;
|
||||
I2cStart();
|
||||
}
|
||||
|
||||
void i2c_get(uint8_t sla, uint8_t _twi_len, bool_t* finished) {
|
||||
twi_len = _twi_len;
|
||||
twi_sla = I2C_RECEIVE | sla;
|
||||
twi_end = finished;
|
||||
I2cStart();
|
||||
}
|
||||
|
||||
|
||||
uint8_t i2c_start(void) {
|
||||
TWCR=_BV(TWINT)|_BV(TWSTA)|_BV(TWEN);
|
||||
while (! (TWCR & (1<<TWINT)));
|
||||
return ((TWSR & 0xF8) != TWI_START);
|
||||
}
|
||||
|
||||
uint8_t i2c_sla(uint8_t a) {
|
||||
TWDR= a;
|
||||
TWCR=_BV(TWINT)|_BV(TWEN);
|
||||
|
||||
while (! (TWCR & (1<<TWINT)));
|
||||
|
||||
return ((TWSR & 0xF8) != MT_SLA_ACK);
|
||||
}
|
||||
|
||||
uint8_t i2c_transmit(uint8_t byte) {
|
||||
TWDR= byte;
|
||||
TWCR=_BV(TWINT)|_BV(TWEN);
|
||||
|
||||
while (! (TWCR & (1<<TWINT)));
|
||||
|
||||
/***/return I2C_NO_ERROR;
|
||||
return ((TWSR & 0xF8) != MT_DATA_ACK);
|
||||
}
|
||||
|
||||
uint8_t i2c_receive(uint8_t ack) {
|
||||
if (ack == I2C_CONTINUE)
|
||||
TWCR=_BV(TWINT)|_BV(TWEN)|_BV(TWEA);
|
||||
else
|
||||
TWCR=_BV(TWINT)|_BV(TWEN);
|
||||
while (! (TWCR & (1<<TWINT)));
|
||||
uint8_t byte = TWDR;
|
||||
return byte;
|
||||
}
|
||||
|
||||
void i2c_init(void) {
|
||||
/** 100 KHz */
|
||||
TWBR = 72;
|
||||
cbi(TWSR, TWPS1);
|
||||
cbi(TWSR, TWPS0);
|
||||
/** 10 KHz
|
||||
TWBR = 198;
|
||||
cbi(TWSR, TWPS1);
|
||||
sbi(TWSR, TWPS0);
|
||||
*/
|
||||
}
|
||||
|
||||
void i2c_event(void) { }
|
||||
void i2c2_setbitrate(int bitrate __attribute__ ((unused))) { }
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005 Pascal Brisset, Antoine Drouin
|
||||
*
|
||||
* 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 i2c_ap.h
|
||||
* \brief Basic library for I2C
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef I2C_H
|
||||
#define I2C_H
|
||||
|
||||
#include <avr/io.h>
|
||||
#include <inttypes.h>
|
||||
#include "std.h"
|
||||
|
||||
#define I2C_NO_ERROR 0
|
||||
|
||||
#define I2C_RECEIVE 1
|
||||
#define I2C_TRANSMIT 0
|
||||
|
||||
#define I2C_QUIT 0
|
||||
#define I2C_CONTINUE 1
|
||||
|
||||
#define i2c_stop() TWCR=_BV(TWINT)|_BV(TWSTO)|_BV(TWEN);
|
||||
|
||||
#define TWI_BUF_LEN 16
|
||||
extern volatile bool_t i2c_idle;
|
||||
extern uint8_t i2c_debug;
|
||||
extern uint8_t i2c_buf[TWI_BUF_LEN];
|
||||
|
||||
extern void i2c_init(void);
|
||||
extern uint8_t i2c_start(void);
|
||||
extern uint8_t i2c_sla(uint8_t x);
|
||||
extern uint8_t i2c_transmit(uint8_t x);
|
||||
extern uint8_t i2c_receive(uint8_t);
|
||||
extern void i2c_send(uint8_t address, uint8_t len, bool_t* finished);
|
||||
extern void i2c_get(uint8_t address, uint8_t len, bool_t* finished);
|
||||
|
||||
#define I2C_START(ADDRESS) { i2c_start(); i2c_sla(ADDRESS); }
|
||||
#define I2C_START_TX(ADDRESS) I2C_START(ADDRESS | I2C_TRANSMIT)
|
||||
#define I2C_START_RX(ADDRESS) I2C_START(ADDRESS | I2C_RECEIVE)
|
||||
|
||||
#endif
|
||||
@@ -1,146 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2003-2005 Pascal Brisset, Antoine Drouin
|
||||
*
|
||||
* 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 mcu_periph/spi_arch.c
|
||||
* \brief handling of hardware dependant SPI on AVR architecture
|
||||
*/
|
||||
|
||||
#include CONFIG
|
||||
#include "mcu_periph/spi.h"
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <avr/io.h>
|
||||
|
||||
#if (__GNUC__ == 3)
|
||||
#include <avr/signal.h>
|
||||
#endif
|
||||
|
||||
#include <avr/interrupt.h>
|
||||
|
||||
volatile uint8_t spi_idx_buf;
|
||||
|
||||
#define HandleOneSpiByte() { \
|
||||
spi_idx_buf++; \
|
||||
if (spi_idx_buf < spi_buffer_length) { \
|
||||
SPDR = spi_buffer_output[spi_idx_buf]; \
|
||||
spi_buffer_input[spi_idx_buf-1] = SPDR; \
|
||||
} else if (spi_idx_buf == spi_buffer_length) { \
|
||||
spi_buffer_input[spi_idx_buf-1] = SPDR; \
|
||||
spi_message_received = TRUE; \
|
||||
SpiStop(); \
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
#ifdef SPI_SLAVE
|
||||
|
||||
volatile bool_t spi_was_interrupted = FALSE;
|
||||
|
||||
void spi_init(void) {
|
||||
/* set it pin output */
|
||||
// IT_DDR |= _BV(IT_PIN);
|
||||
|
||||
/* set MISO pin output */
|
||||
SLAVE_SPI_DDR |= _BV(SLAVE_SPI_MISO_PIN);
|
||||
/* enable SPI, slave, MSB first, sck idle low */
|
||||
SPCR = _BV(SPE);
|
||||
/* enable interrupt */
|
||||
SPCR |= _BV(SPIE);
|
||||
}
|
||||
|
||||
#define SpiStop() {}
|
||||
|
||||
|
||||
SIGNAL(SIG_SPI) {
|
||||
HandleOneSpiByte();
|
||||
}
|
||||
|
||||
#endif /** SPI_SLAVE */
|
||||
|
||||
|
||||
/****************************************************************************/
|
||||
#ifdef SPI_MASTER
|
||||
|
||||
#include "autopilot.h"
|
||||
|
||||
#define SpiStop() { \
|
||||
ClearBit(SPCR,SPIE); \
|
||||
ClearBit(SPCR, SPE); \
|
||||
SpiUnselectAllSlaves(); \
|
||||
}
|
||||
|
||||
volatile uint8_t spi_cur_slave;
|
||||
uint8_t spi_nb_ovrn;
|
||||
|
||||
void spi_init( void) {
|
||||
/* Set MOSI and SCK output, all others input */
|
||||
MASTER_SPI_DDR |= _BV(MASTER_SPI_MOSI_PIN)| _BV(MASTER_SPI_SCK_PIN);
|
||||
|
||||
/* enable pull up for miso */
|
||||
// SPI_PORT |= _BV(MASTER_SPI_MISO_PIN);
|
||||
|
||||
/* Set SS0 output */
|
||||
SetBit( MASTER_SPI_SS0_DDR, MASTER_SPI_SS0_PIN);
|
||||
/* SS0 idles high (don't select slave yet)*/
|
||||
|
||||
#if 0
|
||||
/* Set SS1 output */
|
||||
SetBit( MASTER_SPI_SS1_DDR, MASTER_SPI_SS1_PIN);
|
||||
/* SS1 idles high (don't select slave yet)*/
|
||||
|
||||
/* Set SS2 output */
|
||||
SetBit( MASTER_SPI_SS2_DDR, MASTER_SPI_SS2_PIN);
|
||||
/* SS2 idles high (don't select slave yet)*/
|
||||
#endif
|
||||
|
||||
SpiUnselectAllSlaves();
|
||||
|
||||
spi_cur_slave = SPI_NONE;
|
||||
}
|
||||
|
||||
|
||||
/** SPI interrupt: starts a delay */
|
||||
SIGNAL(SIG_SPI) {
|
||||
/* if (spi_cur_slave == SPI_SLAVE0) { */
|
||||
/* setup OCR1C to pop in 200 clock cycles */
|
||||
/* this leaves time for the slave (fbw) */
|
||||
/* to process the byte we've sent and to */
|
||||
/* prepare a new one to be sent */
|
||||
OCR1C = TCNT1 + (200UL*CLOCK)/16;
|
||||
/* clear interrupt flag */
|
||||
SetBit(ETIFR, OCF1C);
|
||||
/* enable OC1C interrupt */
|
||||
SetBit(ETIMSK, OCIE1C);
|
||||
/* } else
|
||||
fatal_error_nb++;
|
||||
*/
|
||||
}
|
||||
|
||||
/** Send a byte */
|
||||
SIGNAL(SIG_OUTPUT_COMPARE1C) {
|
||||
/* disable OC1C interrupt */
|
||||
ClearBit(ETIMSK, OCIE1C);
|
||||
|
||||
HandleOneSpiByte();
|
||||
}
|
||||
|
||||
#endif /* SPI_MASTER */
|
||||
@@ -1,84 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2006 Pascal Brisset, Antoine Drouin
|
||||
*
|
||||
* 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 SPI_ARCH_H
|
||||
#define SPI_ARCH_H
|
||||
|
||||
/** Index in SPI buffers: one is enough for full duplex communication */
|
||||
extern volatile uint8_t spi_idx_buf;
|
||||
|
||||
#define SpiInitBuf() { \
|
||||
spi_idx_buf = 0; \
|
||||
SPDR = spi_buffer_output[0]; \
|
||||
spi_message_received = FALSE; \
|
||||
}
|
||||
|
||||
#ifdef SPI_SLAVE
|
||||
|
||||
#define SpiStart() SpiInitBuf()
|
||||
|
||||
#endif /* SPI_SLAVE */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef SPI_MASTER
|
||||
|
||||
/* Enable SPI, Master, clock fck/16, interrupt */
|
||||
#define SpiStart() { \
|
||||
SPCR = _BV(SPE) | _BV(MSTR) | _BV(SPR0); \
|
||||
uint8_t foo; \
|
||||
if (bit_is_set(SPSR, SPIF)) \
|
||||
foo = SPDR; \
|
||||
SPCR |= _BV(SPIE); \
|
||||
SpiInitBuf(); \
|
||||
}
|
||||
|
||||
#define SpiUnselectAllSlaves() { \
|
||||
spi_cur_slave = SPI_NONE; \
|
||||
SetBit( MASTER_SPI_SS0_PORT, MASTER_SPI_SS0_PIN );\
|
||||
/* \
|
||||
SetBit( MASTER_SPI_SS1_PORT, MASTER_SPI_SS1_PIN ); \
|
||||
SetBit( MASTER_SPI_SS2_PORT, MASTER_SPI_SS2_PIN );\
|
||||
*/ \
|
||||
}
|
||||
|
||||
#define SpiSelectSlave0() { \
|
||||
spi_cur_slave = SPI_SLAVE0; \
|
||||
ClearBit( MASTER_SPI_SS0_PORT, MASTER_SPI_SS0_PIN );\
|
||||
}
|
||||
|
||||
#define SpiSelectSlave1() { \
|
||||
spi_cur_slave = SPI_SLAVE1; \
|
||||
ClearBit( MASTER_SPI_SS1_PORT, MASTER_SPI_SS1_PIN );\
|
||||
}
|
||||
|
||||
#define SpiSelectSlave2() { \
|
||||
spi_cur_slave = SPI_SLAVE2; \
|
||||
ClearBit( MASTER_SPI_SS2_PORT, MASTER_SPI_SS2_PIN );\
|
||||
}
|
||||
|
||||
#endif /* SPI_MASTER */
|
||||
|
||||
|
||||
#endif /* SPI_ARCH_H */
|
||||
@@ -1,256 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2003 Pascal Brisset, Antoine Drouin
|
||||
*
|
||||
* 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 uart_hw.c
|
||||
* \brief avr uart low level functions
|
||||
*
|
||||
*/
|
||||
#include "mcu_periph/uart.h"
|
||||
#include "mcu_periph/sys_time.h"
|
||||
|
||||
#define B2400 2400UL
|
||||
#define B9600 9600UL
|
||||
#define B38400 38400UL
|
||||
|
||||
#if defined (__AVR_ATmega8__)
|
||||
|
||||
#define TX_BUF_SIZE 256
|
||||
static uint8_t tx_head; /* next free in buf */
|
||||
static volatile uint8_t tx_tail; /* next char to send */
|
||||
static uint8_t tx_buf[ TX_BUF_SIZE ];
|
||||
|
||||
/*
|
||||
* UART Baud rate generation settings:
|
||||
*
|
||||
* With 16.0 MHz clock,UBRR=25 => 38400 baud
|
||||
*
|
||||
*/
|
||||
|
||||
void uart0_init_tx( void ) {
|
||||
UBRRH = 0;
|
||||
UBRRL = F_CPU/(16*UART0_BAUD)-1;
|
||||
|
||||
/* single speed */
|
||||
UCSRA = 0;
|
||||
/* Enable transmitter */
|
||||
UCSRB = _BV(TXEN);
|
||||
/* Set frame format: 8data, 1stop bit */
|
||||
UCSRC = _BV(URSEL) | _BV(UCSZ1) | _BV(UCSZ0);
|
||||
}
|
||||
|
||||
void uart0_init_rx( void ) {
|
||||
/* Enable receiver */
|
||||
UCSRB |= _BV(RXEN);
|
||||
/* Enable uart receive interrupt */
|
||||
sbi( UCSRB, RXCIE );
|
||||
}
|
||||
|
||||
bool_t uart0_check_free_space( uint8_t len) {
|
||||
int8_t space;
|
||||
if ((space = (tx_tail - tx_head)) <= 0)
|
||||
space += TX_BUF_SIZE;
|
||||
|
||||
return (uint8_t)(space - 1) >= len;
|
||||
}
|
||||
|
||||
void uart0_transmit( unsigned char data ) {
|
||||
if (UCSRB & _BV(TXCIE)) {
|
||||
/* we are waiting for the last char to be sent : buffering */
|
||||
if (tx_tail == tx_head + 1) { /* BUF_SIZE = 256 */
|
||||
/* Buffer is full (almost, but tx_head = tx_tail means "empty" */
|
||||
return;
|
||||
}
|
||||
tx_buf[tx_head] = data;
|
||||
tx_head++; /* BUF_SIZE = 256 */
|
||||
} else { /* Channel is free: just send */
|
||||
UDR = data;
|
||||
sbi(UCSRB, TXCIE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SIGNAL(SIG_UART_TRANS) {
|
||||
if (tx_head == tx_tail) {
|
||||
/* Nothing more to send */
|
||||
cbi(UCSRB, TXCIE); /* disable interrupt */
|
||||
} else {
|
||||
UDR = tx_buf[tx_tail];
|
||||
tx_tail++; /* warning tx_buf_len is 256 */
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* (__AVR_ATmega8__) */
|
||||
|
||||
|
||||
#if defined (__AVR_ATmega128__)
|
||||
|
||||
#define TX_BUF_SIZE 256
|
||||
|
||||
#ifdef USE_UART0
|
||||
static uint8_t tx_head0; /* next free in buf */
|
||||
static volatile uint8_t tx_tail0; /* next char to send */
|
||||
uint8_t tx_buf0[ TX_BUF_SIZE ];
|
||||
|
||||
uint16_t uart0_rx_insert_idx, uart0_rx_extract_idx;
|
||||
uint8_t uart0_rx_buffer[UART0_RX_BUFFER_SIZE];
|
||||
|
||||
void uart0_init_tx( void ) {
|
||||
UBRR0H = 0;
|
||||
UBRR0L = F_CPU/(16*UART0_BAUD)-1;
|
||||
|
||||
/* single speed */
|
||||
UCSR0A = 0;
|
||||
/* Enable transmitter */
|
||||
UCSR0B = _BV(TXEN);
|
||||
/* Set frame format: 8data, 1stop bit */
|
||||
UCSR0C = _BV(UCSZ1) | _BV(UCSZ0);
|
||||
|
||||
tx_head0 = 0;
|
||||
tx_tail0 = 0;
|
||||
}
|
||||
|
||||
void uart0_init_rx( void ) {
|
||||
/* Enable receiver */
|
||||
UCSR0B |= _BV(RXEN);
|
||||
|
||||
/* Enable uart receive interrupt */
|
||||
sbi(UCSR0B, RXCIE );
|
||||
}
|
||||
|
||||
bool_t uart0_check_free_space( uint8_t len) {
|
||||
int8_t space;
|
||||
if ((space = (tx_tail0 - tx_head0)) <= 0)
|
||||
space += TX_BUF_SIZE;
|
||||
|
||||
return (uint16_t)(space - 1) >= len;
|
||||
}
|
||||
|
||||
void uart0_transmit( unsigned char data ) {
|
||||
if (UCSR0B & _BV(TXCIE)) {
|
||||
/* we are waiting for the last char to be sent : buffering */
|
||||
if (tx_tail0 == tx_head0 + 1) { /* BUF_SIZE = 256 */
|
||||
/* Buffer is full (almost, but tx_head = tx_tail means "empty" */
|
||||
return;
|
||||
}
|
||||
tx_buf0[tx_head0] = data;
|
||||
tx_head0++; /* BUF_SIZE = 256 */
|
||||
} else { /* Channel is free: just send */
|
||||
UDR0 = data;
|
||||
sbi(UCSR0B, TXCIE);
|
||||
}
|
||||
}
|
||||
|
||||
SIGNAL(SIG_UART0_TRANS) {
|
||||
if (tx_head0 == tx_tail0) {
|
||||
/* Nothing more to send */
|
||||
cbi(UCSR0B, TXCIE); /* disable interrupt */
|
||||
} else {
|
||||
UDR0 = tx_buf0[tx_tail0];
|
||||
tx_tail0++; /* warning tx_buf_len is 256 */
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SIGNAL( SIG_UART0_RECV ) {
|
||||
uart0_rx_buffer[uart0_rx_insert_idx] = UDR0;
|
||||
uart0_rx_insert_idx = Uart0RxBufferNext(uart0_rx_insert_idx);
|
||||
}
|
||||
|
||||
#endif /** USE_UART0 */
|
||||
|
||||
#ifdef USE_UART1
|
||||
|
||||
static uint8_t tx_head1; /* next free in buf */
|
||||
static volatile uint8_t tx_tail1; /* next char to send */
|
||||
static uint8_t tx_buf1[ TX_BUF_SIZE ];
|
||||
|
||||
uint16_t uart1_rx_insert_idx, uart1_rx_extract_idx;
|
||||
uint8_t uart1_rx_buffer[UART1_RX_BUFFER_SIZE];
|
||||
|
||||
void uart1_init_tx( void ) {
|
||||
/* set baud rate */
|
||||
UBRR1H = 0;
|
||||
UBRR1L = F_CPU/(16*UART1_BAUD)-1;
|
||||
|
||||
/* single speed */
|
||||
UCSR1A = 0;
|
||||
/* Enable transmitter */
|
||||
UCSR1B = _BV(TXEN);
|
||||
/* Set frame format: 8data, 1stop bit */
|
||||
UCSR1C = _BV(UCSZ1) | _BV(UCSZ0);
|
||||
|
||||
tx_head1 = 0;
|
||||
tx_tail1 = 0;
|
||||
}
|
||||
|
||||
void uart1_init_rx( void ) {
|
||||
/* Enable receiver */
|
||||
UCSR1B |= _BV(RXEN);
|
||||
/* Enable uart receive interrupt */
|
||||
sbi(UCSR1B, RXCIE );
|
||||
}
|
||||
|
||||
bool_t uart1_check_free_space( uint8_t len) {
|
||||
int8_t space;
|
||||
if ((space = (tx_tail1 - tx_head1)) <= 0)
|
||||
space += TX_BUF_SIZE;
|
||||
|
||||
return (uint16_t)(space - 1) >= len;
|
||||
}
|
||||
|
||||
void uart1_transmit( unsigned char data ) {
|
||||
if (UCSR1B & _BV(TXCIE)) {
|
||||
/* we are waiting for the last char to be sent : buffering */
|
||||
if (tx_tail1 == tx_head1 + 1) { /* BUF_SIZE = 256 */
|
||||
/* Buffer is full (almost, but tx_head = tx_tail means "empty" */
|
||||
return;
|
||||
}
|
||||
tx_buf1[tx_head1] = data;
|
||||
tx_head1++; /* BUF_SIZE = 256 */
|
||||
} else { /* Channel is free: just send */
|
||||
UDR1 = data;
|
||||
sbi(UCSR1B, TXCIE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SIGNAL(SIG_UART1_TRANS) {
|
||||
if (tx_head1 == tx_tail1) {
|
||||
/* Nothing more to send */
|
||||
cbi(UCSR1B, TXCIE); /* disable interrupt */
|
||||
} else {
|
||||
UDR1 = tx_buf1[tx_tail1];
|
||||
tx_tail1++; /* warning tx_buf_len is 256 */
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SIGNAL( SIG_UART1_RECV ) {
|
||||
uart1_rx_buffer[uart1_rx_insert_idx] = UDR1;
|
||||
uart1_rx_insert_idx = Uart0RxBufferNext(uart1_rx_insert_idx);
|
||||
}
|
||||
|
||||
#endif /* USE_UART1 */
|
||||
|
||||
#endif /* (__AVR_ATmega128__) */
|
||||
|
||||
|
||||
@@ -1,106 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005 Pascal Brisset, Antoine Drouin
|
||||
*
|
||||
* 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 uart_hw.h
|
||||
* \brief avr uart low level headers
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef UART_HW_H
|
||||
#define UART_HW_H
|
||||
|
||||
#include <avr/io.h>
|
||||
#if (__GNUC__ == 3)
|
||||
#include <avr/signal.h>
|
||||
#endif
|
||||
#include <avr/interrupt.h>
|
||||
#include "std.h"
|
||||
|
||||
|
||||
/************************************************************************/
|
||||
#if defined (__AVR_ATmega8__)
|
||||
|
||||
#define ReceiveUart(cb) \
|
||||
SIGNAL( SIG_UART_RECV ) { \
|
||||
uint8_t c = UDR; \
|
||||
cb(c); \
|
||||
}
|
||||
|
||||
#endif /* (__AVR_ATmega8__) */
|
||||
|
||||
|
||||
/************************************************************************/
|
||||
#if defined (__AVR_ATmega128__)
|
||||
|
||||
extern uint8_t tx_buf0[256]; /** For debugging purpose */
|
||||
|
||||
extern void uart0_init_tx(void);
|
||||
extern void uart0_init_rx(void);
|
||||
extern void uart1_init(void);
|
||||
|
||||
extern void uart0_transmit(const uint8_t);
|
||||
extern void uart1_transmit(const uint8_t);
|
||||
|
||||
#define UART0_RX_BUFFER_SIZE 32 // UART0 receive buffer size
|
||||
#define UART1_RX_BUFFER_SIZE 32 // UART1 receive buffer size
|
||||
#define UART0_RX_BUFFER_SIZE_MASK 0x1f
|
||||
#define UART1_RX_BUFFER_SIZE_MASK 0x1f
|
||||
|
||||
#ifdef UART0_RX_BUFFER_SIZE_MASK
|
||||
#define Uart0RxBufferNext(_x) ((_x+1)&UART0_RX_BUFFER_SIZE_MASK)
|
||||
#else
|
||||
#define Uart0RxBufferNext(_x) ((_x+1)%UART0_RX_BUFFER_SIZE)
|
||||
#endif
|
||||
|
||||
#ifdef UART1_RX_BUFFER_SIZE_MASK
|
||||
#define Uart1RxBufferNext(_x) ((_x+1)&UART1_RX_BUFFER_SIZE_MASK)
|
||||
#else
|
||||
#define Uart1RxBufferNext(_x) ((_x+1)%UART1_RX_BUFFER_SIZE)
|
||||
#endif
|
||||
|
||||
|
||||
extern uint16_t uart0_rx_insert_idx, uart0_rx_extract_idx;
|
||||
extern uint8_t uart0_rx_buffer[UART0_RX_BUFFER_SIZE];
|
||||
|
||||
#define Uart0ChAvailable() (uart0_rx_insert_idx != uart0_rx_extract_idx)
|
||||
|
||||
#define Uart0Getch() ({\
|
||||
uint8_t ret = uart0_rx_buffer[uart0_rx_extract_idx]; \
|
||||
uart0_rx_extract_idx = Uart0RxBufferNext(uart0_rx_extract_idx); \
|
||||
ret; \
|
||||
})
|
||||
|
||||
|
||||
extern uint16_t uart1_rx_insert_idx, uart1_rx_extract_idx;
|
||||
extern uint8_t uart1_rx_buffer[UART1_RX_BUFFER_SIZE];
|
||||
|
||||
#define Uart1ChAvailable() (uart1_rx_insert_idx != uart1_rx_extract_idx)
|
||||
|
||||
#define Uart1Getch() ({\
|
||||
uint8_t ret = uart1_rx_buffer[uart1_rx_extract_idx]; \
|
||||
uart1_rx_extract_idx = Uart1RxBufferNext(uart1_rx_extract_idx); \
|
||||
ret; \
|
||||
})
|
||||
|
||||
#endif /* (__AVR_ATmega128__) */
|
||||
|
||||
#endif /* UART_HW_H */
|
||||
@@ -1,119 +0,0 @@
|
||||
/* $Id$
|
||||
* Copied from autopilot (autopilot.sf.net) thanx alot Trammell
|
||||
*
|
||||
* (c) 2003 Trammell Hudson <hudson@rotomotion.com>
|
||||
* (c) 2003 Pascal Brisset, Antoine Drouin
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#if (__GNUC__ == 3)
|
||||
#include <avr/signal.h>
|
||||
#endif
|
||||
|
||||
#include <avr/interrupt.h>
|
||||
#include "ppm.h"
|
||||
#include "mcu_periph/sys_time.h"
|
||||
|
||||
/*
|
||||
* Pulse width is computed as the difference between now and the
|
||||
* previous pulse. If no pulse has been received between then and
|
||||
* now, the time of the last pulse will be equal to the last pulse
|
||||
* we measured. Unfortunately, the Input Capture Flag (ICF1) will
|
||||
* not be set since the interrupt routine disables it.
|
||||
*
|
||||
* Sync pulses are timed with Timer2, which runs at Clk/1024. This
|
||||
* is slow enough at both 4 and 8 Mhz to measure the lengthy (10ms
|
||||
* or longer) pulse.
|
||||
*
|
||||
* Otherwise, compute the pulse width with the 16-bit timer1,
|
||||
* push the pulse width onto the stack and increment the
|
||||
* pulse counter until we have received eight pulses.
|
||||
*/
|
||||
|
||||
uint16_t ppm_pulses[ PPM_NB_PULSES ];
|
||||
volatile bool_t ppm_valid;
|
||||
|
||||
/* MC3030, Trame PPM7: 25ms, 10.4 au neutre,
|
||||
sync pulse = 16.2ms with low value on every channels */
|
||||
|
||||
#if CLOCK == 8
|
||||
#define RestartPpmCycle() { state = 0; sync_start = TCNT2 + (tmr2_ov_cnt << 8); return; }
|
||||
#else
|
||||
#define RestartPpmCycle() { state = 0; sync_start = TCNT2; return; }
|
||||
#endif
|
||||
|
||||
#ifdef TIMER1_TOP
|
||||
static volatile uint16_t tmr1_ov_cnt = 0;
|
||||
SIGNAL(SIG_OVERFLOW1) {
|
||||
tmr1_ov_cnt += TIMER1_TOP;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
SIGNAL( SIG_INPUT_CAPTURE1 )
|
||||
{
|
||||
static uint16_t last;
|
||||
uint16_t this;
|
||||
uint16_t width;
|
||||
static uint8_t state = 0;
|
||||
static uint16_t sync_start;
|
||||
|
||||
this = ICR1;
|
||||
#ifdef TIMER1_TOP
|
||||
this += tmr1_ov_cnt;
|
||||
#endif
|
||||
width = this - last;
|
||||
last = this;
|
||||
|
||||
if( state == 0 ) {
|
||||
uint16_t end = TCNT2;
|
||||
#if CLOCK == 8
|
||||
end += tmr2_ov_cnt << 8;
|
||||
uint16_t diff = (end - sync_start);
|
||||
#else
|
||||
uint8_t diff = (end - sync_start);
|
||||
#endif
|
||||
sync_start = end;
|
||||
|
||||
/* The frame period of the mc3030 seems to be 25ms.
|
||||
* One pulse lasts from 1.05ms to 2.150ms.
|
||||
* Sync pulse is at least 7ms : (7000*CLOCK)/1024 = 109
|
||||
*/
|
||||
if( diff > LONG_CPU_TICKS_OF_USEC(PPM_SYNC_MIN_LEN) &&
|
||||
diff < LONG_CPU_TICKS_OF_USEC(PPM_SYNC_MAX_LEN) ) {
|
||||
state = 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* Read a data pulses */
|
||||
if( width > CPU_TICKS_OF_USEC(PPM_DATA_MAX_LEN) ||
|
||||
width < CPU_TICKS_OF_USEC(PPM_DATA_MIN_LEN))
|
||||
RestartPpmCycle();
|
||||
ppm_pulses[state - 1] = width;
|
||||
|
||||
if (state >= PPM_NB_PULSES) {
|
||||
ppm_valid = TRUE;
|
||||
RestartPpmCycle();
|
||||
} else
|
||||
state++;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
/* $Id$
|
||||
*
|
||||
* Decoder for the trainer ports or hacked receivers for both
|
||||
* Futaba and JR formats. The ppm_valid flag is set whenever
|
||||
* a valid frame is received.
|
||||
*
|
||||
* Pulse widths are stored as unscaled 16-bit values in ppm_pulses[].
|
||||
* If you require actual microsecond values, divide by CLOCK.
|
||||
* For an 8 Mhz clock and typical servo values, these will range
|
||||
* from 0x1F00 to 0x4000.
|
||||
*
|
||||
* Copied from autopilot (autopilot.sf.net) thanx alot Trammell
|
||||
*
|
||||
* (c) 2002 Trammell Hudson <hudson@rotomotion.com>
|
||||
* (c) 2003 Pascal Brisset, Antoine Drouin
|
||||
*
|
||||
* 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 PPM_HW_H
|
||||
#define PPM_HW_H
|
||||
|
||||
#ifdef FBW
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <avr/io.h>
|
||||
|
||||
#include CONFIG
|
||||
|
||||
/*
|
||||
* PPM pulses are falling edge clocked on the ICP, which records
|
||||
* the state of the global clock. We do not use any noise
|
||||
* canceling features.
|
||||
*
|
||||
* JR might be rising edge clocked; set that as an option
|
||||
*/
|
||||
static inline void
|
||||
ppm_init( void )
|
||||
{
|
||||
#if defined RADIO_CONTROL_TYPE && RADIO_CONTROL_TYPE == RC_FUTABA
|
||||
cbi( TCCR1B, ICES1 );
|
||||
#elif defined RADIO_CONTROL_TYPE && RADIO_CONTROL_TYPE == RC_JR
|
||||
sbi( TCCR1B, ICES1 );
|
||||
#else
|
||||
#error "ppm_hw.h: Unknown RADIO_CONTROL_TYPE"
|
||||
#endif
|
||||
/* No noise cancelation */
|
||||
sbi( TCCR1B, ICNC1 );
|
||||
|
||||
/* Set ICP to input, no internal pull up */
|
||||
cbi( PPM_DDR, PPM_PIN);
|
||||
|
||||
/* Enable interrupt on input capture */
|
||||
sbi( TIMSK, TICIE1 );
|
||||
|
||||
#ifdef TIMER1_TOP
|
||||
/* Enable timer1 overflow it. */
|
||||
/* needed to increase timer1 count to 16 bits in fast pwm mode (TIMER1_TOP rollover) */
|
||||
sbi( TIMSK, TOIE1 );
|
||||
#endif
|
||||
ppm_valid = FALSE;
|
||||
}
|
||||
|
||||
#endif /* FBW */
|
||||
|
||||
extern volatile uint16_t ppm_diff;
|
||||
|
||||
|
||||
|
||||
#endif /* PPM_HW_H */
|
||||
@@ -1,138 +0,0 @@
|
||||
/* $Id$
|
||||
*
|
||||
* (c) 2003-2006 Pascal Brisset, Antoine Drouin
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/** Implementation of actuators.h */
|
||||
|
||||
#include <avr/io.h>
|
||||
#if (__GNUC__ == 3)
|
||||
#include <avr/signal.h>
|
||||
#endif
|
||||
#include <avr/interrupt.h>
|
||||
#include "servos_4017.h"
|
||||
#include "actuators.h"
|
||||
#include "mcu_periph/sys_time.h"
|
||||
#include CONFIG
|
||||
|
||||
|
||||
/* holds the servo pulses width in clock ticks */
|
||||
uint16_t servo_widths[_4017_NB_CHANNELS];
|
||||
|
||||
/*
|
||||
* We use the output compare registers to generate our servo pulses.
|
||||
* These should be connected to a decade counter that routes the
|
||||
* pulses to the appropriate servo.
|
||||
*
|
||||
* Initialization involves:
|
||||
*
|
||||
* - Reseting the decade counters
|
||||
* - Writing the first pulse width to the counters
|
||||
* - Setting output compare to set the clock line by calling servo_enable()
|
||||
* - Bringing down the reset lines
|
||||
*
|
||||
* Ideally, you can use two decade counters to drive 20 servos.
|
||||
*/
|
||||
void actuators_init( void ) {
|
||||
uint8_t i;
|
||||
/* Configure the reset and clock lines as output */
|
||||
_4017_RESET_DDR |= _BV(_4017_RESET_PIN);
|
||||
_4017_CLOCK_DDR |= _BV(_4017_CLOCK_PIN);
|
||||
/* Reset the decade counter */
|
||||
sbi( _4017_RESET_PORT, _4017_RESET_PIN );
|
||||
/* Lower the clock line */
|
||||
cbi( _4017_CLOCK_PORT, _4017_CLOCK_PIN );
|
||||
/* Set all servos at their midpoints */
|
||||
for( i=0 ; i < _4017_NB_CHANNELS ; i++ )
|
||||
servo_widths[i] = CPU_TICKS_OF_USEC(1500);
|
||||
/* Set servos to go off some long time from now */
|
||||
SERVO_OCR = 32768ul;
|
||||
/* Set output compare to toggle the output bits */
|
||||
TCCR1A |= _BV(SERVO_COM0 );
|
||||
#ifdef SERVOS_FALLING_EDGE
|
||||
/* Starts CLOCK high for the falling edge case */
|
||||
TCCR1A |= _BV(SERVO_FORCE);
|
||||
#endif
|
||||
/* Clear the interrupt flags in case they are set */
|
||||
TIFR = _BV(SERVO_FLAG);
|
||||
/* Unassert the decade counter reset to start it running */
|
||||
cbi( _4017_RESET_PORT, _4017_RESET_PIN );
|
||||
/* Enable our output compare interrupts */
|
||||
TIMSK |= _BV(SERVO_ENABLE );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Interrupt routine
|
||||
*
|
||||
* write the next pulse width to OCR register and
|
||||
* assert the servo signal. It will be cleared by
|
||||
* the following compare match.
|
||||
*/
|
||||
SIGNAL( SIG_OUTPUT_COMPARE1A )
|
||||
{
|
||||
static uint8_t servo = 0;
|
||||
uint16_t width;
|
||||
|
||||
#ifdef SERVOS_FALLING_EDGE
|
||||
#define RESET_WIDTH CPU_TICKS_OF_USEC(1000)
|
||||
#define FIRST_PULSE_WIDTH CPU_TICKS_OF_USEC(100)
|
||||
/** The clock pin has been initialized high and is toggled down by
|
||||
the timer.
|
||||
Unfortunately it seems that reset does not work on 4017 in this case if it
|
||||
occurs after the first falling edge. We add two more states at the end of
|
||||
the sequence:
|
||||
- keeping clock low, reset high during 1ms
|
||||
- clock high (toggled by the timer), reset down, during 100us (looks like
|
||||
the first pulse of a standard RC */
|
||||
if (servo == _4017_NB_CHANNELS) {
|
||||
sbi( _4017_RESET_PORT, _4017_RESET_PIN );
|
||||
/** Start a long 1ms reset, keep clock low */
|
||||
SERVO_OCR += RESET_WIDTH;
|
||||
servo++;
|
||||
return;
|
||||
}
|
||||
if (servo > _4017_NB_CHANNELS) {
|
||||
/** Clear the reset, the clock has been toggled high */
|
||||
cbi( _4017_RESET_PORT, _4017_RESET_PIN );
|
||||
/** Starts a short pulse-like period */
|
||||
SERVO_OCR += FIRST_PULSE_WIDTH;
|
||||
servo=0; /** Starts a new sequence next time */
|
||||
return;
|
||||
}
|
||||
#else
|
||||
if (servo >= _4017_NB_CHANNELS) {
|
||||
sbi( _4017_RESET_PORT, _4017_RESET_PIN );
|
||||
servo = 0;
|
||||
// FIXME: 500 ns required by 4017 reset ???? why does it work without!
|
||||
// asm( "nop; nop; nop; nop;nop; nop; nop; nop;nop; nop; nop; nop;nop; nop; nop; nop;" );
|
||||
cbi( _4017_RESET_PORT, _4017_RESET_PIN );
|
||||
}
|
||||
#endif
|
||||
width = servo_widths[servo];
|
||||
|
||||
SERVO_OCR += width;
|
||||
|
||||
TCCR1A |= _BV(SERVO_FORCE);
|
||||
|
||||
servo++;
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
/* $Id$
|
||||
*
|
||||
* (c) 2003-2005 Pascal Brisset, Antoine Drouin
|
||||
*
|
||||
* 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 extern uint16_t servo_widths[_4017_NB_CHANNELS];(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 SERVO_4017_H
|
||||
#define SERVO_4017_H
|
||||
|
||||
#define SERVOS_TICS_OF_USEC(_us) CPU_TICKS_OF_USEC(_us)
|
||||
#define ChopServo(x,a,b) Chop(x, a, b)
|
||||
|
||||
#define _4017_NB_CHANNELS 10
|
||||
extern uint16_t servo_widths[_4017_NB_CHANNELS];
|
||||
#define Actuator(i) servo_widths[i]
|
||||
|
||||
#define ActuatorsCommit() {}
|
||||
|
||||
#endif /* SERVO_4017_H */
|
||||
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
/* Implementation of command.h */
|
||||
|
||||
/*
|
||||
3 servos on OC3A OC3B OC3C using Timer3 prescaled at 8
|
||||
*/
|
||||
|
||||
#include "servos_direct_hw.h"
|
||||
#include "std.h"
|
||||
#include "actuators.h"
|
||||
#include "generated/airframe.h"
|
||||
|
||||
void actuators_init ( void ) {
|
||||
/* OC3A, OC3B, OC3C outputs */
|
||||
DDRE |= _BV(3) | _BV(4) | _BV(5);
|
||||
/* set timer3 in fast PWM mode, with TOP defined by ICR3 , prescaled to 8 */
|
||||
TCCR3A = _BV(WGM31) | _BV(COM3A1) | _BV(COM3B1) | _BV(COM3C1);
|
||||
TCCR3B = _BV(WGM32) | _BV(WGM33) | _BV(CS31);
|
||||
/* set timer3 rollover */
|
||||
ICR3 = TIMER3_TOP;
|
||||
/* Set all servos at their midpoints */
|
||||
Actuator(0) = SERVOS_TICS_OF_USEC(1500);
|
||||
Actuator(1) = SERVOS_TICS_OF_USEC(1500);
|
||||
Actuator(2) = SERVOS_TICS_OF_USEC(1500);
|
||||
}
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
#ifndef SERVOS_DIRECT_HW_H
|
||||
#define SERVOS_DIRECT_HW_H
|
||||
|
||||
#include <avr/io.h>
|
||||
#include CONFIG
|
||||
|
||||
/* servo refresh rate in HZ */
|
||||
#define SERVO_REFRESH_RATE 50
|
||||
/* timer3 prescaler */
|
||||
#define TIMER3_PRESCALER 8
|
||||
#define TIMER3_TOP (CLOCK*1e6/SERVO_REFRESH_RATE/TIMER3_PRESCALER)
|
||||
#define SERVOS_TICS_OF_USEC(s) ((s)*CLOCK/TIMER3_PRESCALER)
|
||||
#define ChopServo(x, min, max) Chop(x, min, max)
|
||||
|
||||
#define SERVO_REG_0 OCR3A
|
||||
#define SERVO_REG_1 OCR3B
|
||||
#define SERVO_REG_2 OCR3C
|
||||
#define COMMAND_(i) SERVO_REG_ ## i
|
||||
#define Actuator(i) COMMAND_(i)
|
||||
|
||||
#define ActuatorsCommit() {}
|
||||
|
||||
#endif /* SERVOS_DIRECT_HW_H */
|
||||
@@ -1,51 +0,0 @@
|
||||
/* $Id$
|
||||
*
|
||||
* (c) 2006 Pascal Brisset, Antoine Drouin
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
/** Implementation of actuators.h */
|
||||
|
||||
/*
|
||||
|
||||
4 DC motor controller with mosfets on OCR1A OCR3A OCR3B OCR3C
|
||||
|
||||
*/
|
||||
|
||||
#include <avr/io.h>
|
||||
#include "servos_esc_hw.h"
|
||||
#include CONFIG
|
||||
|
||||
|
||||
void actuators_init ( void ) {
|
||||
/* OC1A output */
|
||||
DDRB |= _BV(5);
|
||||
/* fast PWM, 10 bits */
|
||||
TCCR1A |= _BV(WGM10) | _BV(WGM11) | _BV(COM1A1);
|
||||
TCCR1B |= _BV(WGM12);
|
||||
/* OC3A, OC3B, OC3C outputs */
|
||||
DDRE |= _BV(3) | _BV(4) | _BV(5);
|
||||
/* fast PWM : 10 bits */
|
||||
TCCR3A |= _BV(WGM30) | _BV(WGM31) | _BV(COM3A1) | _BV(COM3B1) | _BV(COM3C1);
|
||||
TCCR3B |= _BV(WGM32);
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
/* $Id$
|
||||
*
|
||||
* Copied from autopilot (autopilot.sf.net) thanx alot Trammell
|
||||
* (c) 2003-2005 Pascal Brisset, Antoine Drouin
|
||||
*
|
||||
* 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 SERVOS_ESC_HW_H
|
||||
#define SERVOS_ESC_HW_H
|
||||
|
||||
|
||||
/** Implementation of actuators.h */
|
||||
|
||||
/*
|
||||
4 DC motor controller with mosfets on OCR1A OCR3A OCR3B OCR3C
|
||||
*/
|
||||
|
||||
#include <avr/io.h>
|
||||
|
||||
#define MAX_TICK 0x3FF
|
||||
#define MOT_CTL_0 OCR3C
|
||||
#define MOT_CTL_1 OCR1A
|
||||
#define MOT_CTL_2 OCR3B
|
||||
#define MOT_CTL_3 OCR3A
|
||||
|
||||
#define COMMAND_(i) MOT_CTL_ ## i
|
||||
#define Actuator(i) COMMAND_(i)
|
||||
#define ChopServo(x,_a,b) (x > b ? b : x)
|
||||
#define SERVOS_TICS_OF_USEC(s) (s)
|
||||
|
||||
#define ActuatorsCommit() {}
|
||||
|
||||
#endif /* SERVOS_ESC_HW_H */
|
||||
@@ -1,74 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2003 Pascal Brisset, Antoine Drouin
|
||||
*
|
||||
* 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 audio_telemetry_hw.c
|
||||
* \brief Handling of a CMX 469 on avr mega128 architecture
|
||||
*/
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#if (__GNUC__ == 3)
|
||||
#include <avr/signal.h>
|
||||
#endif
|
||||
|
||||
#include <avr/interrupt.h>
|
||||
#include "audio_telemetry.h"
|
||||
|
||||
uint8_t audio_telemetry_nb_ovrn;
|
||||
|
||||
uint8_t tx_head;
|
||||
volatile uint8_t tx_tail;
|
||||
uint8_t tx_buf[ TX_BUF_SIZE ];
|
||||
|
||||
uint8_t tx_byte;
|
||||
uint8_t tx_byte_idx;
|
||||
|
||||
|
||||
SIGNAL( AUDIO_TELEMETRY_CLK_INT_SIG ) {
|
||||
/* start bit */
|
||||
if (tx_byte_idx == 0)
|
||||
cbi(AUDIO_TELEMETRY_TX_PORT, AUDIO_TELEMETRY_TX_DATA);
|
||||
/* 8 data bits */
|
||||
else if (tx_byte_idx < 9) {
|
||||
if (tx_byte & 0x01)
|
||||
sbi(AUDIO_TELEMETRY_TX_PORT, AUDIO_TELEMETRY_TX_DATA);
|
||||
else
|
||||
cbi(AUDIO_TELEMETRY_TX_PORT, AUDIO_TELEMETRY_TX_DATA);
|
||||
tx_byte >>= 1;
|
||||
}
|
||||
/* stop_bit */
|
||||
else {
|
||||
sbi(AUDIO_TELEMETRY_TX_PORT, AUDIO_TELEMETRY_TX_DATA);
|
||||
}
|
||||
tx_byte_idx++;
|
||||
/* next byte */
|
||||
if (tx_byte_idx >= 10) {
|
||||
/* if we have nothing left to transmit */
|
||||
if( tx_head == tx_tail ) {
|
||||
/* disable clock interrupt */
|
||||
cbi( EIMSK, AUDIO_TELEMETRY_CLK_INT );
|
||||
} else {
|
||||
/* else load next byte */
|
||||
AUDIO_TELEMETRY_LOAD_NEXT_BYTE();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,94 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2003 Pascal Brisset, Antoine Drouin
|
||||
*
|
||||
* 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 audio_telemetry_hw.h
|
||||
* \brief AVR CMX469 low level functions
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef AUDIO_TELEMETRY_HW_H
|
||||
#define AUDIO_TELEMETRY_HW_H
|
||||
|
||||
#include <avr/io.h>
|
||||
#include "std.h"
|
||||
|
||||
#define AUDIO_TELEMETRY_CHECK_RUNNING() { \
|
||||
if (!(EIMSK & _BV(AUDIO_TELEMETRY_CLK_INT))) { \
|
||||
AUDIO_TELEMETRY_LOAD_NEXT_BYTE() \
|
||||
sbi(EIFR, INTF0); \
|
||||
sbi(EIMSK, AUDIO_TELEMETRY_CLK_INT); \
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
#define AUDIO_TELEMETRY_TX_PORT PORTD
|
||||
#define AUDIO_TELEMETRY_TX_DDR DDRD
|
||||
#define AUDIO_TELEMETRY_TX_EN 7
|
||||
#define AUDIO_TELEMETRY_TX_DATA 6
|
||||
|
||||
#ifdef CTL_BRD_V1_2
|
||||
#define AUDIO_TELEMETRY_CLK_DDR DDRD
|
||||
#define AUDIO_TELEMETRY_CLK_PORT PORTD
|
||||
#define AUDIO_TELEMETRY_CLK 0
|
||||
#define AUDIO_TELEMETRY_CLK_INT INT0
|
||||
#define AUDIO_TELEMETRY_CLK_INT_REG EICRA
|
||||
#define AUDIO_TELEMETRY_CLK_INT_CFG _BV(ISC01)
|
||||
#define AUDIO_TELEMETRY_CLK_INT_SIG SIG_INTERRUPT0
|
||||
|
||||
#define AUDIO_TELEMETRY_OSC_DDR DDRB
|
||||
#define AUDIO_TELEMETRY_OSC_PORT PORTB
|
||||
#define AUDIO_TELEMETRY_OSC 4
|
||||
#endif /* CTL_BRD_V1_2 */
|
||||
|
||||
#ifdef CTL_BRD_V1_2_1
|
||||
#define AUDIO_TELEMETRY_CLK_DDR DDRE
|
||||
#define AUDIO_TELEMETRY_CLK_PORT PORTE
|
||||
#define AUDIO_TELEMETRY_CLK 4
|
||||
#define AUDIO_TELEMETRY_CLK_INT INT4
|
||||
#define AUDIO_TELEMETRY_CLK_INT_REG EICRB
|
||||
#define AUDIO_TELEMETRY_CLK_INT_CFG _BV(ISC41)
|
||||
#define AUDIO_TELEMETRY_CLK_INT_SIG SIG_INTERRUPT4
|
||||
#define AUDIO_TELEMETRY_OSC_DDR DDRB
|
||||
#define AUDIO_TELEMETRY_OSC_PORT PORTB
|
||||
#define AUDIO_TELEMETRY_OSC 4
|
||||
#endif /* CTL_BRD_V1_2_1 */
|
||||
|
||||
static inline void audio_telemetry_init ( void ) {
|
||||
/* setup TIMER0 to generate a 4MHz clock */
|
||||
AUDIO_TELEMETRY_OSC_DDR |= _BV(AUDIO_TELEMETRY_OSC);
|
||||
OCR0 = 1; /* 4MhZ */
|
||||
TCCR0 = _BV(WGM01) | _BV(COM00) | _BV(CS00);
|
||||
|
||||
/* setup TX_EN and TX_DATA pin as output */
|
||||
AUDIO_TELEMETRY_TX_DDR |= _BV(AUDIO_TELEMETRY_TX_EN) | _BV(AUDIO_TELEMETRY_TX_DATA);
|
||||
/* data idles hight */
|
||||
sbi(AUDIO_TELEMETRY_TX_PORT, AUDIO_TELEMETRY_TX_DATA);
|
||||
/* enable transmitter */
|
||||
cbi(AUDIO_TELEMETRY_TX_PORT, AUDIO_TELEMETRY_TX_EN);
|
||||
/* set interrupt on failing edge of clock */
|
||||
AUDIO_TELEMETRY_CLK_INT_REG |= AUDIO_TELEMETRY_CLK_INT_CFG;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,22 +0,0 @@
|
||||
#include <inttypes.h>
|
||||
#if (__GNUC__ == 3)
|
||||
#include <avr/signal.h>
|
||||
#endif
|
||||
#include <avr/interrupt.h>
|
||||
|
||||
#include CONFIG
|
||||
#include "std.h"
|
||||
|
||||
uint16_t cpu_time_ticks;
|
||||
|
||||
#if CLOCK == 8
|
||||
volatile uint8_t tmr2_ov_cnt;
|
||||
volatile bool_t tmr2_overflow;
|
||||
|
||||
SIGNAL(SIG_OVERFLOW2) {
|
||||
tmr2_ov_cnt++;
|
||||
tmr2_overflow = TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,127 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005 Pascal Brisset, Antoine Drouin
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
*\brief AVR timer functions
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SYS_TIME_HW_H
|
||||
#define SYS_TIME_HW_H
|
||||
|
||||
#include "std.h"
|
||||
#include <avr/io.h>
|
||||
|
||||
extern uint16_t cpu_time_ticks;
|
||||
|
||||
#define F_CPU (CLOCK*1000000UL)
|
||||
|
||||
/*
|
||||
* Enable Timer1 (16-bit) running at Clk/1 for the global system
|
||||
* clock.
|
||||
*
|
||||
* Low frequency periodic tasks will be signaled by timer 2
|
||||
* running at Clk/1024. For 16 Mhz clock, this will be every
|
||||
* 16384 microseconds, or 61.03515625 Hz.
|
||||
*/
|
||||
static inline void sys_time_init( void ) {
|
||||
|
||||
/* Timer0: Modem clock is started in modem.h in ctc mode*/
|
||||
|
||||
/* Timer1 @ Clk/1: System clock */
|
||||
TCCR1A = 0x00;
|
||||
TCCR1B = _BV(CS10);
|
||||
|
||||
/* Timer2 @ Clk/1024: Periodic clock */
|
||||
#if defined (__AVR_ATmega8__)
|
||||
TCCR2 = _BV(CS20) | _BV(CS21) | _BV(CS22);
|
||||
#elif defined (__AVR_ATmega128__)
|
||||
#if CLOCK == 16
|
||||
TCCR2 = _BV(CS20) | _BV(CS22);
|
||||
#elif CLOCK == 8
|
||||
TCCR2 = _BV(CS22);
|
||||
sbi( TIMSK, TOIE2 );
|
||||
#else
|
||||
#error "Unknwon CLOCK"
|
||||
#endif
|
||||
#else
|
||||
#warning "Unknown arch"
|
||||
#endif
|
||||
|
||||
#ifdef TIMER3
|
||||
/* Timer3 @ Clk/1: motor controller */
|
||||
TCCR3A = 0x00;
|
||||
TCCR3B = _BV(CS10);
|
||||
#endif
|
||||
|
||||
cpu_time_sec = 0;
|
||||
cpu_time_ticks = 0;
|
||||
}
|
||||
|
||||
|
||||
#define CPU_TICKS_OF_USEC(us) (uint16_t)((us)*CLOCK)
|
||||
#define SIGNED_CPU_TICKS_OF_USEC(us) (int16_t)((us)*CLOCK)
|
||||
|
||||
#if CLOCK == 8
|
||||
#define LONG_CPU_TICKS_OF_USEC(us) (uint16_t)(((uint32_t)(us)*CLOCK)/256ul)
|
||||
#else
|
||||
#define LONG_CPU_TICKS_OF_USEC(us) (uint8_t)(((uint32_t)(us)*CLOCK)/1024ul)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Periodic tasks occur when Timer2 overflows. Check and unset
|
||||
* the overflow bit. Occurs at 61.03515625 Hz with CLOCK = 16
|
||||
* Occurs at 122Hz with CLOCK = 8
|
||||
*
|
||||
*/
|
||||
|
||||
#if CLOCK == 8
|
||||
extern volatile uint8_t tmr2_ov_cnt;
|
||||
extern volatile bool_t tmr2_overflow;
|
||||
#endif
|
||||
|
||||
#define TICKS_PER_SEC (CLOCK * 1e6 / 1024)
|
||||
|
||||
#if CLOCK == 8
|
||||
static inline bool_t sys_time_periodic( void ) {
|
||||
if( !tmr2_overflow )
|
||||
return FALSE;
|
||||
tmr2_overflow = FALSE;
|
||||
|
||||
return (tmr2_ov_cnt & 0x1);
|
||||
}
|
||||
#else
|
||||
//#define TMR2_PER_SEC 7812
|
||||
static inline bool_t sys_time_periodic( void ) {
|
||||
if( !bit_is_set( TIFR, TOV2 ) )
|
||||
return FALSE;
|
||||
TIFR = _BV(TOV2);
|
||||
cpu_time_ticks += 256;
|
||||
if (cpu_time_ticks > TICKS_PER_SEC) {
|
||||
cpu_time_ticks -= TICKS_PER_SEC;
|
||||
cpu_time_sec++;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* SYS_TIME_HW_H */
|
||||
@@ -1,61 +0,0 @@
|
||||
#include <inttypes.h>
|
||||
#include <avr/io.h>
|
||||
#if (__GNUC__ == 3)
|
||||
#include <avr/signal.h>
|
||||
#endif
|
||||
#include <avr/interrupt.h>
|
||||
|
||||
#define UART_PC_PORT PORTE
|
||||
#define UART_PC_DDR DDRE
|
||||
#define UART_PC_PIN PINE
|
||||
#define UART_PC_TX 1
|
||||
#define UART_PC_RX 0
|
||||
|
||||
#define UART_PERPH_PORT PORTD
|
||||
#define UART_PERPH_DDR DDRD
|
||||
#define UART_PERPH_PIN PIND
|
||||
#define UART_PERPH_TX 3
|
||||
#define UART_PERPH_RX 2
|
||||
|
||||
#ifndef cbi
|
||||
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
|
||||
#endif
|
||||
#ifndef sbi
|
||||
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
|
||||
#endif
|
||||
|
||||
|
||||
int main( void ) {
|
||||
|
||||
/* setup PC_TX as output */
|
||||
UART_PC_DDR |= _BV(UART_PC_TX);
|
||||
|
||||
/* setup PC_RX as input, no pullup */
|
||||
UART_PC_DDR &= ~_BV(UART_PC_RX);
|
||||
UART_PC_PORT &= ~_BV(UART_PC_RX);
|
||||
|
||||
/* setup PERPH_TX as output */
|
||||
UART_PERPH_DDR |= _BV(UART_PERPH_TX);
|
||||
|
||||
/* setup PERPH_RX as input, no pullup */
|
||||
UART_PERPH_DDR &= ~_BV(UART_PERPH_RX);
|
||||
UART_PERPH_PORT &= ~_BV(UART_PERPH_RX);
|
||||
|
||||
while(1)
|
||||
{
|
||||
if (bit_is_set(UART_PERPH_PIN, UART_PERPH_RX)) {
|
||||
sbi(UART_PC_PORT, UART_PC_TX);
|
||||
} else {
|
||||
cbi(UART_PC_PORT, UART_PC_TX);
|
||||
}
|
||||
if (bit_is_set(UART_PC_PIN, UART_PC_RX)) {
|
||||
sbi(UART_PERPH_PORT, UART_PERPH_TX);
|
||||
} else {
|
||||
cbi(UART_PERPH_PORT, UART_PERPH_TX);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
#
|
||||
# modem $Id$
|
||||
# Copyright (C) 2003 Pascal Brisset, Antoine Drouin
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
ARCH = atmega8
|
||||
TARGET = modem_gnd
|
||||
TARGETDIR = modem_gnd
|
||||
LOW_FUSE = 3f
|
||||
HIGH_FUSE = cb
|
||||
EXT_FUSE= ff
|
||||
LOCK_FUSE= ff
|
||||
INCLUDES= -I../../include
|
||||
|
||||
$(TARGET).srcs = \
|
||||
main.c \
|
||||
uart.c \
|
||||
soft_uart.c \
|
||||
adc.c \
|
||||
|
||||
include ../../../conf/Makefile.local
|
||||
include ../../../conf/Makefile.avr
|
||||
|
||||
clean : avr_clean
|
||||
@@ -1,28 +0,0 @@
|
||||
#
|
||||
# $Id$
|
||||
# Copyright (C) 2004 Pascal Brisset Antoine Drouin
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
This directory contains code for the mega8 MCU in the
|
||||
ground modem.
|
||||
The mega8 drives the CMX469 modem. This is necessary because
|
||||
the crystal in the transmitting CMX469 is 4Mhz instead of
|
||||
specified 4.032 .
|
||||
This leads to incompatibility with the laptop baud generator.
|
||||
@@ -1,39 +0,0 @@
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <avr/io.h>
|
||||
#include <avr/signal.h>
|
||||
#include <avr/interrupt.h>
|
||||
|
||||
#include "avr/std.h"
|
||||
#include "adc.h"
|
||||
|
||||
#define ANALOG_PORT PORTC
|
||||
#define ANALOG_PORT_DIR DDRC
|
||||
#define VALIM 7
|
||||
|
||||
uint16_t adc_alim;
|
||||
volatile uint8_t adc_got_val;
|
||||
|
||||
void adc_init( void )
|
||||
{
|
||||
/* Ensure that our port is for input with no pull-ups */
|
||||
ANALOG_PORT &= ~_BV(VALIM);
|
||||
ANALOG_PORT_DIR &= ~_BV(VALIM);
|
||||
|
||||
/* Select our external voltage ref, which is tied to Vcc and channel VALIM*/
|
||||
ADMUX = VALIM;
|
||||
|
||||
/* Turn off the analog comparator */
|
||||
sbi( ACSR, ACD );
|
||||
|
||||
/* turn on the ADC, clock/128, interrupts, free running mode and starts conversion */
|
||||
ADCSRA = _BV(ADEN) | _BV(ADPS0) | _BV(ADPS1) | _BV(ADPS2) | _BV(ADIE) | _BV(ADFR) | _BV(ADSC);
|
||||
}
|
||||
|
||||
|
||||
SIGNAL( SIG_ADC )
|
||||
{
|
||||
/* Store result */
|
||||
adc_alim = ADCW;
|
||||
adc_got_val = TRUE;
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
#ifndef ADC_H
|
||||
#define ADC_H
|
||||
|
||||
void adc_init( void );
|
||||
extern uint16_t adc_alim;
|
||||
extern volatile uint8_t adc_got_val;
|
||||
|
||||
#endif
|
||||
@@ -1,92 +0,0 @@
|
||||
#ifndef LINK_TMTC_H
|
||||
#define LINK_TMTC_H
|
||||
|
||||
#define STX 0x02
|
||||
#define ETX 0x03
|
||||
|
||||
#define MSG_DATA 0
|
||||
#define MSG_ERROR 1
|
||||
#define MSG_CD 2
|
||||
#define MSG_DEBUG 3
|
||||
#define MSG_VALIM 4
|
||||
|
||||
|
||||
|
||||
#define LINK_TMTC_SEND_DATA(data, _len) { \
|
||||
uint8_t checksum = 0; \
|
||||
const uint8_t real_len = 2+_len; \
|
||||
uint8_t i; \
|
||||
uart_putc(STX); \
|
||||
uart_putc(real_len); \
|
||||
checksum^=real_len; \
|
||||
uart_putc(MSG_DATA); \
|
||||
checksum^=MSG_DATA; \
|
||||
for (i=0; i<_len; i++) { \
|
||||
uart_putc(data[i]); \
|
||||
checksum^=data[i]; \
|
||||
} \
|
||||
uart_putc(checksum); \
|
||||
uart_putc(ETX); \
|
||||
}
|
||||
|
||||
#define LINK_TMTC_SEND_ERROR(error) { \
|
||||
uint8_t checksum = 0; \
|
||||
const uint8_t real_len = 2+1; \
|
||||
uart_putc(STX); \
|
||||
uart_putc(real_len); \
|
||||
checksum^=real_len; \
|
||||
uart_putc(MSG_ERROR); \
|
||||
checksum^=MSG_ERROR; \
|
||||
uart_putc(error); \
|
||||
checksum^=error; \
|
||||
uart_putc(checksum); \
|
||||
uart_putc(ETX); \
|
||||
}
|
||||
|
||||
|
||||
#define LINK_TMTC_SEND_CD(cd) { \
|
||||
uint8_t checksum = 0; \
|
||||
const uint8_t real_len = 2+1; \
|
||||
uart_putc(STX); \
|
||||
uart_putc(real_len); \
|
||||
checksum^=real_len; \
|
||||
uart_putc(MSG_CD); \
|
||||
checksum^=MSG_CD; \
|
||||
uart_putc(cd); \
|
||||
checksum^=cd; \
|
||||
uart_putc(checksum); \
|
||||
uart_putc(ETX); \
|
||||
}
|
||||
|
||||
#define LINK_TMTC_SEND_DEBUG() { \
|
||||
uint8_t checksum = 0; \
|
||||
const uint8_t real_len = 2+1; \
|
||||
uart_putc(STX); \
|
||||
uart_putc(real_len); \
|
||||
checksum^=real_len; \
|
||||
uart_putc(MSG_DEBUG); \
|
||||
checksum^=MSG_DEBUG; \
|
||||
uart_putc(uart_nb_ovrrun); \
|
||||
checksum^=uart_nb_ovrrun; \
|
||||
uart_putc(checksum); \
|
||||
uart_putc(ETX); \
|
||||
}
|
||||
|
||||
#define LINK_TMTC_SEND_VALIM(_valim) { \
|
||||
uint8_t checksum = 0; \
|
||||
const uint8_t real_len = 2+2; \
|
||||
uart_putc(STX); \
|
||||
uart_putc(real_len); \
|
||||
checksum^=real_len; \
|
||||
uart_putc(MSG_VALIM); \
|
||||
checksum^=MSG_VALIM; \
|
||||
uart_putc(*(uint8_t*)(_valim)); \
|
||||
checksum^= *(uint8_t*)(_valim); \
|
||||
uart_putc(* ((uint8_t*)(_valim) + 1)); \
|
||||
checksum^= *((uint8_t*)(_valim) + 1); \
|
||||
uart_putc(checksum); \
|
||||
uart_putc(ETX); \
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,70 +0,0 @@
|
||||
#include <inttypes.h>
|
||||
#include <avr/io.h>
|
||||
#include <avr/signal.h>
|
||||
#include <avr/interrupt.h>
|
||||
#include <math.h>
|
||||
|
||||
|
||||
#include "timer.h"
|
||||
#include "soft_uart.h"
|
||||
#include "adc.h"
|
||||
#include "uart.h"
|
||||
#include "link_tmtc.h"
|
||||
|
||||
#define FALSE 0
|
||||
#define TRUE (!FALSE)
|
||||
|
||||
static uint16_t cputime = 0; // seconds
|
||||
|
||||
#define INPUT_BUF_LEN 10
|
||||
static uint8_t input_buf[INPUT_BUF_LEN];
|
||||
static uint8_t input_buf_idx = 0;
|
||||
|
||||
static uint16_t saved_valim;
|
||||
|
||||
inline void periodic_task( void ) { // 15 Hz
|
||||
static uint8_t _1Hz = 0;
|
||||
_1Hz++;
|
||||
if (_1Hz>=15) _1Hz=0;
|
||||
|
||||
if (!_1Hz) {
|
||||
uint8_t cd_status = bit_is_set(SOFT_UART_CD_PIN, SOFT_UART_CD);
|
||||
cputime++;
|
||||
LINK_TMTC_SEND_CD(cd_status);
|
||||
LINK_TMTC_SEND_VALIM(&saved_valim);
|
||||
LINK_TMTC_SEND_DEBUG();
|
||||
}
|
||||
}
|
||||
|
||||
int main( void ) {
|
||||
/* init peripherals */
|
||||
timer_init();
|
||||
uart_init();
|
||||
soft_uart_init();
|
||||
adc_init();
|
||||
sei();
|
||||
|
||||
/* enter mainloop */
|
||||
while( 1 ) {
|
||||
if(timer_periodic())
|
||||
periodic_task();
|
||||
if (soft_uart_error) {
|
||||
LINK_TMTC_SEND_ERROR(soft_uart_error);
|
||||
soft_uart_error = 0;
|
||||
}
|
||||
if (soft_uart_got_byte) {
|
||||
input_buf[input_buf_idx] = soft_uart_byte;
|
||||
input_buf_idx++;
|
||||
if (input_buf_idx >= INPUT_BUF_LEN) {
|
||||
LINK_TMTC_SEND_DATA(input_buf, input_buf_idx);
|
||||
input_buf_idx = 0;
|
||||
}
|
||||
soft_uart_got_byte = FALSE;
|
||||
}
|
||||
if (adc_got_val) {
|
||||
saved_valim = adc_alim;
|
||||
adc_got_val = FALSE;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
#include "soft_uart.h"
|
||||
|
||||
#include <avr/io.h>
|
||||
#include <avr/signal.h>
|
||||
#include <avr/interrupt.h>
|
||||
|
||||
#define FALSE 0
|
||||
#define TRUE (!FALSE)
|
||||
|
||||
|
||||
volatile uint8_t soft_uart_got_byte = FALSE;
|
||||
uint8_t soft_uart_byte;
|
||||
volatile uint8_t soft_uart_error = 0;
|
||||
|
||||
#define RX_CLOCKED_DATA_PORT PORTB
|
||||
#define RX_CLOCKED_DATA_DDR DDRB
|
||||
#define RX_CLOCKED_DATA_PIN PINB
|
||||
#define RX_CLOCKED_DATA 0
|
||||
|
||||
|
||||
void soft_uart_init(void) {
|
||||
|
||||
/* set CD pin as input, no pullup */
|
||||
SOFT_UART_CD_DDR &= ~_BV(SOFT_UART_CD);
|
||||
SOFT_UART_CD_PORT &= ~_BV(SOFT_UART_CD);
|
||||
|
||||
/* set DATA pin as input no pullup*/
|
||||
RX_CLOCKED_DATA_DDR &= ~_BV(RX_CLOCKED_DATA);
|
||||
RX_CLOCKED_DATA_PORT &= ~_BV(RX_CLOCKED_DATA);
|
||||
|
||||
/* setup rx interrupt on failing edge of clock */
|
||||
MCUCR = _BV(ISC11);
|
||||
/* clear interrupt flag */
|
||||
sbi(GIFR, INTF1);
|
||||
/* enable interrupt */
|
||||
sbi(GICR, INT1);
|
||||
}
|
||||
|
||||
|
||||
SIGNAL(SIG_INTERRUPT1) {
|
||||
static uint8_t rx_buf_idx = 0;
|
||||
static uint8_t rx_buf;
|
||||
|
||||
if (bit_is_clear(SOFT_UART_CD_PIN, SOFT_UART_CD)) {
|
||||
rx_buf_idx = 0;
|
||||
}
|
||||
else {
|
||||
if (rx_buf_idx==0) {
|
||||
// start bit
|
||||
if (bit_is_clear(RX_CLOCKED_DATA_PIN, RX_CLOCKED_DATA)) {
|
||||
rx_buf = 0;
|
||||
rx_buf_idx++;
|
||||
}
|
||||
}
|
||||
else if (rx_buf_idx < 9) {
|
||||
// data bits
|
||||
rx_buf >>= 1;
|
||||
if (bit_is_set(RX_CLOCKED_DATA_PIN, RX_CLOCKED_DATA))
|
||||
rx_buf |= 0x80;
|
||||
rx_buf_idx++;
|
||||
}
|
||||
else {
|
||||
// stop bit
|
||||
if (bit_is_set(RX_CLOCKED_DATA_PIN, RX_CLOCKED_DATA)) {
|
||||
if (soft_uart_got_byte) {
|
||||
soft_uart_error = RX_ERROR_OVERRUN;
|
||||
}
|
||||
else {
|
||||
soft_uart_byte = rx_buf;
|
||||
soft_uart_got_byte = TRUE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// framing error
|
||||
soft_uart_error = RX_ERROR_FRAMING;
|
||||
}
|
||||
rx_buf_idx = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
#ifndef SOFT_UART_H
|
||||
#define SOFT_UART_H
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
extern volatile uint8_t soft_uart_got_byte;
|
||||
extern uint8_t soft_uart_byte;
|
||||
|
||||
#define RX_ERROR_FRAMING 1
|
||||
#define RX_ERROR_OVERRUN 2
|
||||
extern volatile uint8_t soft_uart_error;
|
||||
|
||||
#define SOFT_UART_CD_PORT PORTD
|
||||
#define SOFT_UART_CD_DDR DDRD
|
||||
#define SOFT_UART_CD_PIN PIND
|
||||
#define SOFT_UART_CD 6
|
||||
|
||||
void soft_uart_init(void);
|
||||
|
||||
|
||||
#endif
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user