include_HEADERS = deb_led_board.h
-SUBDIRS = hwinit eb_ebb
+SUBDIRS = hwinit
+++ /dev/null
-//-------------------------------------------------\r
-Created by: Jiri Kubias - CVUT Prague\r
- \r
-\r
-\r
- servo.c use ISR vector 1 for Timer 1
\ No newline at end of file
+++ /dev/null
-# Doxyfile 1.5.4
-
-#---------------------------------------------------------------------------
-# Project related configuration options
-#---------------------------------------------------------------------------
-DOXYFILE_ENCODING = UTF-8
-PROJECT_NAME = eb_ebb
-PROJECT_NUMBER = 1
-OUTPUT_DIRECTORY = doc
-CREATE_SUBDIRS = NO
-OUTPUT_LANGUAGE = English
-BRIEF_MEMBER_DESC = YES
-REPEAT_BRIEF = YES
-ABBREVIATE_BRIEF = "The $name class " \
- "The $name widget " \
- "The $name file " \
- is \
- provides \
- specifies \
- contains \
- represents \
- a \
- an \
- the
-ALWAYS_DETAILED_SEC = NO
-INLINE_INHERITED_MEMB = NO
-FULL_PATH_NAMES = NO
-STRIP_FROM_PATH =
-STRIP_FROM_INC_PATH =
-SHORT_NAMES = NO
-JAVADOC_AUTOBRIEF = NO
-QT_AUTOBRIEF = NO
-MULTILINE_CPP_IS_BRIEF = NO
-DETAILS_AT_TOP = NO
-INHERIT_DOCS = YES
-SEPARATE_MEMBER_PAGES = NO
-TAB_SIZE = 8
-ALIASES =
-OPTIMIZE_OUTPUT_FOR_C = YES
-OPTIMIZE_OUTPUT_JAVA = NO
-BUILTIN_STL_SUPPORT = NO
-CPP_CLI_SUPPORT = NO
-SIP_SUPPORT = NO
-DISTRIBUTE_GROUP_DOC = NO
-SUBGROUPING = YES
-TYPEDEF_HIDES_STRUCT = NO
-#---------------------------------------------------------------------------
-# Build related configuration options
-#---------------------------------------------------------------------------
-EXTRACT_ALL = YES
-EXTRACT_PRIVATE = YES
-EXTRACT_STATIC = YES
-EXTRACT_LOCAL_CLASSES = YES
-EXTRACT_LOCAL_METHODS = NO
-EXTRACT_ANON_NSPACES = NO
-HIDE_UNDOC_MEMBERS = NO
-HIDE_UNDOC_CLASSES = NO
-HIDE_FRIEND_COMPOUNDS = NO
-HIDE_IN_BODY_DOCS = NO
-INTERNAL_DOCS = NO
-CASE_SENSE_NAMES = YES
-HIDE_SCOPE_NAMES = NO
-SHOW_INCLUDE_FILES = YES
-INLINE_INFO = YES
-SORT_MEMBER_DOCS = YES
-SORT_BRIEF_DOCS = NO
-SORT_BY_SCOPE_NAME = NO
-GENERATE_TODOLIST = YES
-GENERATE_TESTLIST = YES
-GENERATE_BUGLIST = YES
-GENERATE_DEPRECATEDLIST= YES
-ENABLED_SECTIONS =
-MAX_INITIALIZER_LINES = 30
-SHOW_USED_FILES = YES
-SHOW_DIRECTORIES = NO
-FILE_VERSION_FILTER =
-#---------------------------------------------------------------------------
-# configuration options related to warning and progress messages
-#---------------------------------------------------------------------------
-QUIET = NO
-WARNINGS = YES
-WARN_IF_UNDOCUMENTED = YES
-WARN_IF_DOC_ERROR = YES
-WARN_NO_PARAMDOC = NO
-WARN_FORMAT = "$file:$line: $text "
-WARN_LOGFILE =
-#---------------------------------------------------------------------------
-# configuration options related to the input files
-#---------------------------------------------------------------------------
-INPUT = .
-INPUT_ENCODING = UTF-8
-FILE_PATTERNS = *.c \
- *.cc \
- *.cxx \
- *.cpp \
- *.c++ \
- *.d \
- *.java \
- *.ii \
- *.ixx \
- *.ipp \
- *.i++ \
- *.inl \
- *.h \
- *.hh \
- *.hxx \
- *.hpp \
- *.h++ \
- *.idl \
- *.odl \
- *.cs \
- *.php \
- *.php3 \
- *.inc \
- *.m \
- *.mm \
- *.dox \
- *.py \
- *.C \
- *.CC \
- *.C++ \
- *.II \
- *.I++ \
- *.H \
- *.HH \
- *.H++ \
- *.CS \
- *.PHP \
- *.PHP3 \
- *.M \
- *.MM \
- *.PY \
- *.C \
- *.H \
- *.tlh \
- *.diff \
- *.patch \
- *.moc \
- *.xpm \
- *.dox
-RECURSIVE = YES
-EXCLUDE =
-EXCLUDE_SYMLINKS = NO
-EXCLUDE_PATTERNS =
-EXCLUDE_SYMBOLS =
-EXAMPLE_PATH =
-EXAMPLE_PATTERNS = *
-EXAMPLE_RECURSIVE = NO
-IMAGE_PATH =
-INPUT_FILTER =
-FILTER_PATTERNS =
-FILTER_SOURCE_FILES = NO
-#---------------------------------------------------------------------------
-# configuration options related to source browsing
-#---------------------------------------------------------------------------
-SOURCE_BROWSER = NO
-INLINE_SOURCES = NO
-STRIP_CODE_COMMENTS = YES
-REFERENCED_BY_RELATION = NO
-REFERENCES_RELATION = NO
-REFERENCES_LINK_SOURCE = YES
-USE_HTAGS = NO
-VERBATIM_HEADERS = NO
-#---------------------------------------------------------------------------
-# configuration options related to the alphabetical class index
-#---------------------------------------------------------------------------
-ALPHABETICAL_INDEX = NO
-COLS_IN_ALPHA_INDEX = 5
-IGNORE_PREFIX =
-#---------------------------------------------------------------------------
-# configuration options related to the HTML output
-#---------------------------------------------------------------------------
-GENERATE_HTML = YES
-HTML_OUTPUT = html
-HTML_FILE_EXTENSION = .html
-HTML_HEADER =
-HTML_FOOTER =
-HTML_STYLESHEET =
-HTML_ALIGN_MEMBERS = YES
-GENERATE_HTMLHELP = NO
-HTML_DYNAMIC_SECTIONS = NO
-CHM_FILE =
-HHC_LOCATION =
-GENERATE_CHI = NO
-BINARY_TOC = NO
-TOC_EXPAND = NO
-DISABLE_INDEX = NO
-ENUM_VALUES_PER_LINE = 4
-GENERATE_TREEVIEW = NO
-TREEVIEW_WIDTH = 250
-#---------------------------------------------------------------------------
-# configuration options related to the LaTeX output
-#---------------------------------------------------------------------------
-GENERATE_LATEX = NO
-LATEX_OUTPUT = latex
-LATEX_CMD_NAME = latex
-MAKEINDEX_CMD_NAME = makeindex
-COMPACT_LATEX = NO
-PAPER_TYPE = a4wide
-EXTRA_PACKAGES =
-LATEX_HEADER =
-PDF_HYPERLINKS = NO
-USE_PDFLATEX = NO
-LATEX_BATCHMODE = NO
-LATEX_HIDE_INDICES = NO
-#---------------------------------------------------------------------------
-# configuration options related to the RTF output
-#---------------------------------------------------------------------------
-GENERATE_RTF = NO
-RTF_OUTPUT = rtf
-COMPACT_RTF = NO
-RTF_HYPERLINKS = NO
-RTF_STYLESHEET_FILE =
-RTF_EXTENSIONS_FILE =
-#---------------------------------------------------------------------------
-# configuration options related to the man page output
-#---------------------------------------------------------------------------
-GENERATE_MAN = NO
-MAN_OUTPUT = man
-MAN_EXTENSION = .3
-MAN_LINKS = NO
-#---------------------------------------------------------------------------
-# configuration options related to the XML output
-#---------------------------------------------------------------------------
-GENERATE_XML = NO
-XML_OUTPUT = xml
-XML_SCHEMA =
-XML_DTD =
-XML_PROGRAMLISTING = YES
-#---------------------------------------------------------------------------
-# configuration options for the AutoGen Definitions output
-#---------------------------------------------------------------------------
-GENERATE_AUTOGEN_DEF = NO
-#---------------------------------------------------------------------------
-# configuration options related to the Perl module output
-#---------------------------------------------------------------------------
-GENERATE_PERLMOD = NO
-PERLMOD_LATEX = NO
-PERLMOD_PRETTY = YES
-PERLMOD_MAKEVAR_PREFIX =
-#---------------------------------------------------------------------------
-# Configuration options related to the preprocessor
-#---------------------------------------------------------------------------
-ENABLE_PREPROCESSING = YES
-MACRO_EXPANSION = NO
-EXPAND_ONLY_PREDEF = NO
-SEARCH_INCLUDES = YES
-INCLUDE_PATH =
-INCLUDE_FILE_PATTERNS =
-PREDEFINED =
-EXPAND_AS_DEFINED =
-SKIP_FUNCTION_MACROS = YES
-#---------------------------------------------------------------------------
-# Configuration::additions related to external references
-#---------------------------------------------------------------------------
-TAGFILES =
-GENERATE_TAGFILE = eb_ebb.tag
-ALLEXTERNALS = NO
-EXTERNAL_GROUPS = YES
-PERL_PATH = /usr/bin/perl
-#---------------------------------------------------------------------------
-# Configuration options related to the dot tool
-#---------------------------------------------------------------------------
-CLASS_DIAGRAMS = YES
-MSCGEN_PATH =
-HIDE_UNDOC_RELATIONS = YES
-HAVE_DOT = NO
-CLASS_GRAPH = YES
-COLLABORATION_GRAPH = YES
-GROUP_GRAPHS = YES
-UML_LOOK = NO
-TEMPLATE_RELATIONS = NO
-INCLUDE_GRAPH = YES
-INCLUDED_BY_GRAPH = YES
-CALL_GRAPH = NO
-CALLER_GRAPH = NO
-GRAPHICAL_HIERARCHY = YES
-DIRECTORY_GRAPH = YES
-DOT_IMAGE_FORMAT = png
-DOT_PATH =
-DOTFILE_DIRS =
-DOT_GRAPH_MAX_NODES = 50
-MAX_DOT_GRAPH_DEPTH = 1000
-DOT_TRANSPARENT = NO
-DOT_MULTI_TARGETS = NO
-GENERATE_LEGEND = YES
-DOT_CLEANUP = YES
-#---------------------------------------------------------------------------
-# Configuration::additions related to the search engine
-#---------------------------------------------------------------------------
-SEARCHENGINE = NO
+++ /dev/null
-# Generic directory or leaf node makefile for OCERA make framework
-
-ifndef MAKERULES_DIR
-MAKERULES_DIR := $(shell ( old_pwd="" ; while [ ! -e Makefile.rules ] ; do if [ "$$old_pwd" = `pwd` ] ; then exit 1 ; else old_pwd=`pwd` ; cd -L .. 2>/dev/null ; fi ; done ; pwd ) )
-endif
-
-ifeq ($(MAKERULES_DIR),)
-all : default
-.DEFAULT::
- @echo -e "\nThe Makefile.rules has not been found in this or parent directory\n"
-else
-include $(MAKERULES_DIR)/Makefile.rules
-endif
-
+++ /dev/null
-# -*- makefile -*-
-bin_PROGRAMS = eb_ebb
-
-eb_ebb_SOURCES = main.c
-eb_ebb_LIBS = can ebb
-
-
-lib_LIBRARIES = ebb
-ebb_SOURCES = powswitch.c uart.c servo.c engine.c adc.c adc_filtr.c
-
-include_HEADERS = engine.h powswitch.h servo.h uart.h adc.h adc_filtr.h
-
-link_VARIANTS = flash
+++ /dev/null
-#include <lpc21xx.h> // LPC21XX Peripheral Registers
-#include <types.h>
-#include "adc.h"
-#include <stdlib.h>
-
-
-#define ADCCH0 22 ///< ADC0 value for PINSEL
-#define ADCCH1 24 ///< ADC1 value for PINSEL
-#define ADCCH2 26 ///< ADC2 value for PINSEL
-#define ADCCH3 28 ///< ADC3 value for PINSEL
-
-/**
- * ADC ISR routine. This routine reads selected ADC value and
- * multiplies it by #ADC_MUL and adds #ADC_OFFSET to calculate the
- * volage (3.25mV/div). After this reading the next ADC channel is
- * set up for measuring.
- */
-void adc_isr(void) __attribute__ ((interrupt));
-void adc_isr(void)
-{
- unsigned char chan =0;
- unsigned int val =0;
-
-
- chan = (char) ((ADDR>>24) & 0x07);
- val = (((((ADDR >> 6) & 0x3FF) * ADC_MUL + ADC_OFFSET) + adc_val[chan]) >> 1) ;
-
-
-
- adc_val[chan] = val;
-
- ADCR &= ~(ADC_CR_START_OFF_m);
-
-
- switch(chan)
- {
- case 0:
- ADCR = ((ADC_CR_ADC1_m) | (ADC_CR_CLKS_11_m) | (ADC_CR_PDN_ON_m) | (ADC_CR_START_NOW_m) | (20*ADC_CR_CLK_DIV_1_m));
- break;
-
- case 1:
- ADCR = ((ADC_CR_ADC2_m) | (ADC_CR_CLKS_11_m) | (ADC_CR_PDN_ON_m) | (ADC_CR_START_NOW_m) | (20*ADC_CR_CLK_DIV_1_m));
- break;
-
- case 2:
- ADCR = ((ADC_CR_ADC3_m) | (ADC_CR_CLKS_11_m) | (ADC_CR_PDN_ON_m) | (ADC_CR_START_NOW_m) | (20*ADC_CR_CLK_DIV_1_m));
- break;
-
- case 3:
- ADCR = ((ADC_CR_ADC0_m) | (ADC_CR_CLKS_11_m) | (ADC_CR_PDN_ON_m) | (ADC_CR_START_NOW_m) | (20*ADC_CR_CLK_DIV_1_m));
- break;
- }
-
- VICVectAddr = 0;
-
-}
-
-/**
- * Inicializes ADC service for all ADC (4) channels and installs ISR routine to VIC.
- * Automaticly starts the conversion of first channel on given conversion frequency.
- */
-void init_adc(unsigned rx_isr_vect)
-{
-
- PINSEL1 |= ((PINSEL_1 << ADCCH0) | (PINSEL_1 << ADCCH1) | (PINSEL_1 << ADCCH2) | (PINSEL_1 << ADCCH3));
-
- ((uint32_t*)&VICVectCntl0)[rx_isr_vect] = 0x32;
- ((uint32_t*)&VICVectAddr0)[rx_isr_vect] = (unsigned) adc_isr;
- VICIntEnable = 0x40000;
-
- ADCR = ((ADC_CR_ADC0_m) | (ADC_CR_CLKS_11_m) | (ADC_CR_PDN_ON_m) | (ADC_CR_START_NOW_m) | (ADC_VPB_DIV*ADC_CR_CLK_DIV_1_m));
-}
+++ /dev/null
-#ifndef ADC_H
-#define ADC_H
-
-
-#define ADC_MUL 1 ///< This value multiplies mesured value from ADC
-#define ADC_OFFSET 0 ///< This valueis added to mesured value from ADC
-
-#define ADC_VPB_DIV 255 ///< VPB divisor for ADC FIXME
-
-
-
-
-volatile unsigned int adc_val[4]; ///< measured ADC values
-
-
-
-
-
-/** inicializes ADC lines and starts converion (use ISR)
- * @param rx_isr_vect ISR vector
- */
-void init_adc(unsigned rx_isr_vect);
-
-#endif
+++ /dev/null
-#include <lpc21xx.h> // LPC21XX Peripheral Registers
-#include <types.h>
-#include "adc_filtr.h"
-#include <stdlib.h>
-#include <string.h>
-#include <deb_led.h>
-
-
-
-#define ADCCH0 22 ///< ADC0 value for PINSEL
-#define ADCCH1 24 ///< ADC1 value for PINSEL
-#define ADCCH2 26 ///< ADC2 value for PINSEL
-#define ADCCH3 28 ///< ADC3 value for PINSEL
-
-
-/**
- * Comparsion function for quicksort
- *
- * @param *a first number for comparion
- * @param *b second number for comparion
- *
- * @return 1 if b is higher than a
- */
-int compare( const void *a, const void *b)
-{
- return (*((unsigned int*)a) < *(((unsigned int*)b)));
-}
-
-
-/**
- * Median filter for ADC. If new data is available the median is recalculated.
- * This function may be called from main function, it should take long time
- * to calculate the median for all ADC value.
- *
- * @param chan bit oriented (0~3) value, defines which ADC channels have new data
- */
-void adc_filter(unsigned char chan)
-{
- if(adc_update_adc & 1)
- {
- memcpy(&adc_filtr_0_m, adc_filtr_0, sizeof(uint16_t) * ADC_FILTR_SIZE );
- qsort(adc_filtr_0_m , ADC_FILTR_SIZE , sizeof(uint16_t), compare);
- adc_val[0] = adc_filtr_0_m[(ADC_FILTR_SIZE/2 + 1)];
- adc_update_adc &= ~ 1;
-
- }
- if(adc_update_adc & 2)
- {
- memcpy(&adc_filtr_1_m, adc_filtr_1, sizeof(uint16_t) * ADC_FILTR_SIZE );
- qsort(adc_filtr_1_m , ADC_FILTR_SIZE , sizeof(uint16_t), compare);
- adc_val[1] = adc_filtr_1_m[(ADC_FILTR_SIZE/2 + 1)];
- adc_update_adc &= ~ 2;
- }
- if(adc_update_adc & 4)
- {
- memcpy(&adc_filtr_2_m, adc_filtr_2, sizeof(uint16_t) * ADC_FILTR_SIZE );
- qsort(adc_filtr_2_m , ADC_FILTR_SIZE , sizeof(uint16_t), compare);
- adc_val[2] = adc_filtr_2_m[(ADC_FILTR_SIZE/2 + 1)];
- adc_update_adc &= ~ 4;
- }
- if(adc_update_adc & 8)
- {
- memcpy(&adc_filtr_3_m, adc_filtr_3, sizeof(uint16_t) * ADC_FILTR_SIZE );
- qsort(adc_filtr_3_m , ADC_FILTR_SIZE , sizeof(uint16_t), compare);
- adc_val[3] = adc_filtr_3_m[(ADC_FILTR_SIZE/2 + 1)];
- adc_update_adc &= ~ 8;
- }
-}
-
-
-
-
-/**
- * ADC ISR routine. This routine reads selected ADC value and
- * multiplies it by #ADC_MUL and adds #ADC_OFFSET to calculate the
- * volage (3.25mV/div). After this reading the next ADC channel is
- * set up for measuring.
- */
-void adc_isr_filtr(void) __attribute__ ((interrupt));
-void adc_isr_filtr(void)
-{
- unsigned char chan =0;
- unsigned int val =0;
-
-
- chan = (char) ((ADDR>>24) & 0x07);
- val = (((((ADDR >> 6) & 0x3FF) * ADC_MUL + ADC_OFFSET) + adc_val[chan]) >> 1) ;
-
-
- if(chan == 0)
- {
- adc_filtr_0[adc_filtr_p] = val;
- adc_update_adc |= 1;
- }
- else if(chan == 1)
- {
- adc_filtr_1[adc_filtr_p] = val;
- adc_update_adc |= 2;
- }
- else if(chan == 2)
- {
- adc_filtr_2[adc_filtr_p] = val;
- adc_update_adc |= 4;
- }
- else if(chan == 3)
- {
- adc_filtr_3[adc_filtr_p] = val;
- adc_update_adc |= 8;
-
- if(adc_filtr_p == (ADC_FILTR_SIZE -1 )) adc_filtr_p = 0;
- else ++adc_filtr_p;
- }
-
-
- ADCR &= ~(ADC_CR_START_OFF_m);
-
-
- switch(chan)
- {
- case 0:
- ADCR = ((ADC_CR_ADC1_m) | (ADC_CR_CLKS_11_m) | (ADC_CR_PDN_ON_m) | (ADC_CR_START_NOW_m) | (ADC_VPB_DIV*ADC_CR_CLK_DIV_1_m));
- break;
-
- case 1:
- ADCR = ((ADC_CR_ADC2_m) | (ADC_CR_CLKS_11_m) | (ADC_CR_PDN_ON_m) | (ADC_CR_START_NOW_m) | (ADC_VPB_DIV*ADC_CR_CLK_DIV_1_m));
- break;
-
- case 2:
- ADCR = ((ADC_CR_ADC3_m) | (ADC_CR_CLKS_11_m) | (ADC_CR_PDN_ON_m) | (ADC_CR_START_NOW_m) | (ADC_VPB_DIV*ADC_CR_CLK_DIV_1_m));
- break;
-
- case 3:
- ADCR = ((ADC_CR_ADC0_m) | (ADC_CR_CLKS_11_m) | (ADC_CR_PDN_ON_m) | (ADC_CR_START_NOW_m) | (ADC_VPB_DIV*ADC_CR_CLK_DIV_1_m));
- break;
- }
-
- VICVectAddr = 0;
-
-}
-
-/**
- * Inicializes ADC service for all ADC (4) channels and installs ISR routine to VIC.
- * Automaticly starts the conversion of first channel on given conversion frequency.
- */
-void init_adc_filter(unsigned rx_isr_vect)
-{
-
- PINSEL1 |= ((PINSEL_1 << ADCCH0) | (PINSEL_1 << ADCCH1) | (PINSEL_1 << ADCCH2) | (PINSEL_1 << ADCCH3));
-
- int x;
-
- for (x = 0; x < 21; ++x)
- {
- adc_filtr_0[x] = 0;
- adc_filtr_1[x] = 0;
- adc_filtr_2[x] = 0;
- adc_filtr_3[x] = 0;
- }
-
- adc_filtr_p = 0;
- adc_update_adc = 0;
-
- ((uint32_t*)&VICVectCntl0)[rx_isr_vect] = 0x32;
- ((uint32_t*)&VICVectAddr0)[rx_isr_vect] = (unsigned) adc_isr_filtr;
- VICIntEnable = 0x40000;
-
- ADCR = ((ADC_CR_ADC0_m) | (ADC_CR_CLKS_11_m) | (ADC_CR_PDN_ON_m) | (ADC_CR_START_NOW_m) | (ADC_VPB_DIV*ADC_CR_CLK_DIV_1_m));
-}
+++ /dev/null
-#ifndef ADC_FILTR_H
-#define ADC_FILTR_H
-
-#include <system_def.h>
-
-
-#define ADC_MUL 1 ///< This value multiplies mesured value from ADC
-#define ADC_OFFSET 0 ///< This valueis added to mesured value from ADC
-
-#define ACD_HZ 3000 ///< Sampling frequency
-
-#define ADC_VPB_DIV 0x80 ///< VPB divisor
-
-
-
-#if ADC_VPB_DIV & 0xffffff00
- #error Wrong ACD_HZ
-#endif
-
-
-#define ADC_FILTR_SIZE 201 ///< Size of the median filter for each channel, be aware sinal size is size * 8
-
-volatile unsigned int adc_val[4]; ///< Final ADC value
-volatile unsigned int adc_update_adc; ///< bite oriented, updated when new ADC channel is measured
-
-
-
-uint16_t adc_filtr_0_m[ADC_FILTR_SIZE]; ///<
-uint16_t adc_filtr_1_m[ADC_FILTR_SIZE];
-uint16_t adc_filtr_2_m[ADC_FILTR_SIZE];
-uint16_t adc_filtr_3_m[ADC_FILTR_SIZE];
-
-
-
-volatile uint16_t adc_filtr_0[ADC_FILTR_SIZE];
-volatile uint16_t adc_filtr_1[ADC_FILTR_SIZE];
-volatile uint16_t adc_filtr_2[ADC_FILTR_SIZE];
-volatile uint16_t adc_filtr_3[ADC_FILTR_SIZE];
-volatile uint16_t adc_filtr_p ;
-
-void adc_filter(unsigned char chan);
-
-
-
-void init_adc_filter(unsigned rx_isr_vect);
-
-#endif
+++ /dev/null
-
-
-
-
-#include <lpc21xx.h>
-#include <deb_led.h>
-#include <system_def.h>
-#include "engine.h"
-
-#define ENGINE_PIN_A 7 ///< PWM output for engine A, pin P0.7
-#define ENGINE_PIN_B 8 ///< PWM output for engine B, pin P0.8
-
-#define ENGINE_ENA 28 ///< Enable output for engine A, pin P1.28
-#define ENGINE_ENB 30 ///< Enable output for engine B, pin P1.30
-
-#define ENGINE_IN2A 27 ///< Direction output for engine A , pin P1.27
-#define ENGINE_IN2B 29 ///< Direction output for engine A , pin P1.29
-
-#define PWM_FREQ 20000 ///< PWM frequency
-#define PWM_RES 100 ///< PWM resolution
-
-#define PWM_STEP ((CPU_APB_HZ / PWM_FREQ)/PWM_RES + 1) ///< Calculates smallest step PWM for resolution 0~100%
-
-
-
-unsigned int pwm_A = 0; ///< Actual value of PWM A
-unsigned int pwm_B = 0; ///< Actual value of PWM B
-
-
-/**
- * Enables or disables the ouput on engine A. Causes smooth stop, without break.
- *
- * @param status status parameters are defined in engine.h
- *
- */
-void engine_A_en(unsigned status)
-{
- if (status == ENGINE_EN_ON)
- IO1SET |= (1<<ENGINE_ENA);
- else
- IO1CLR |= (1<<ENGINE_ENA);
-}
-
-/**
- * Enables or disables the ouput on engine B. Causes smooth stop, without break.
- *
- * @param status status parameters are defined in engine.h
- *
- */
-void engine_B_en(unsigned status)
-{
- if (status == ENGINE_EN_ON)
- IO1SET |= (1<<ENGINE_ENB);
- else
- IO1CLR |= (1<<ENGINE_ENB);
-}
-
-/**
- * Changes motor A direction
- *
- * @param dir direction parameters are defined in engine.h
- *
- */
-void engine_A_dir(unsigned dir)
-{
- if (dir == ENGINE_DIR_BW)
- IO1SET |= (1<<ENGINE_IN2A);
- else
- IO1CLR |= (1<<ENGINE_IN2A);
-
- engine_A_pwm(pwm_A);
-
-}
-
-/**
- * Changes motor B direction
- *
- * @param dir direction parameters are defined in engine.h
- *
- */
-void engine_B_dir(unsigned dir)
-{
- if (dir == ENGINE_DIR_BW)
- IO1SET |= (1<<ENGINE_IN2B);
- else
- IO1CLR |= (1<<ENGINE_IN2B);
-
- engine_B_pwm(pwm_B);
-}
-
-/**
- * Sets motor A PWM value
- *
- * @param pwm Unsigned int, 0~100%
- *
- * @note 0 causes fast stop
- */
-void engine_A_pwm(unsigned pwm)
-{
- if (pwm>100) pwm = 100;
-
- pwm_A = pwm;
- if (IO1PIN & (1<<ENGINE_IN2A)) PWMMR2 = PWM_STEP * (100 - pwm);
- else PWMMR2 = PWM_STEP * (pwm);
- PWMLER |= PWMLER_LA2_m;
-
-}
-
-/**
- * Sets motor B PWM value
- *
- * @param pwm Unsigned int, 0~100%
- *
- * @note 0 causes fast stop
- */
-void engine_B_pwm(unsigned pwm)
-{
- if (pwm>100) pwm = 100;
- pwm_B = pwm;
- if (IO1PIN & (1<<ENGINE_IN2B)) PWMMR4 = PWM_STEP * (100 - pwm);
- else PWMMR4 = PWM_STEP * (pwm);
- PWMLER |= PWMLER_LA4_m;
-
-}
-
-
-/**
- * Inicializes Engine A - enables PWM outputs and sets IOs. Uses PWM channel - PWMMR2.
- * If is somthing other set on PWM channels, it will affect the main PWM frequency
- * If the engine B is set it will afect its output for one cycle
- *
- *
- */
-void init_engine_A()
-{
- PINSEL0 &= ~((PINSEL_3 << 14) );
- PINSEL0 |= (PINSEL_2 << 14) ;
-
- IO0DIR |= (1<<ENGINE_PIN_A);
- IO1DIR |= (1<<ENGINE_ENA) | (1<<ENGINE_IN2A);
- IO1SET |= (1<<ENGINE_ENA) | (1<<ENGINE_IN2A);
-
- PWMPR = 0;
- PWMMR0 = CPU_APB_HZ / 20000;
-
- PWMMR2 =0;
-
- PWMPCR |= PWMPCR_PWMENA2_m;
- PWMLER |= PWMLER_LA0_m | PWMLER_LA2_m;
- PWMMCR |= PWMMCR_PWMMR0R_m;
- PWMTCR |= PWMTCR_CE_m | PWMTCR_EN_m;
-}
-
-/**
- * Inicializes Engine B - enables PWM outputs and sets IOs. Uses PWM channel - PWMMR2.
- * If is somthing other set on PWM channels, it will affect the main PWM frequency
- * If the engine A is set it will afect its output for one cycle
- *
- *
- */
-void init_engine_B()
-{
- PINSEL0 &= ~((PINSEL_3 << 16));
- PINSEL0 |= (PINSEL_2 << 16);
-
- IO0DIR |= (1<<ENGINE_PIN_B);
- IO1DIR |= (1<<ENGINE_ENB) | (1<<ENGINE_IN2B);
-
- IO1SET |= (1<<ENGINE_ENB) | (1<<ENGINE_IN2B);
-
-
- PWMPR = 0;
- PWMMR0 = CPU_APB_HZ / 20000;
-
- PWMMR4 = 0;
-
- PWMPCR |= PWMPCR_PWMENA4_m;
- PWMLER |= PWMLER_LA0_m | PWMLER_LA4_m;
- PWMMCR |= PWMMCR_PWMMR0R_m;
- PWMTCR |= PWMTCR_CE_m | PWMTCR_EN_m;
-}
\ No newline at end of file
+++ /dev/null
-/**
- * @file engine.h
- *
- * @brief Engines control
- * This file provides simply how-to use eb_ebb library.
- * From main function is called init_perip function
- * where is initialized servos, engines, power switch,
- * CAN,ADC and serial port. After this initialization is shown
- * how to control each devices. This sample also include simply
- * sample of sending and receiving CAN message.
- *
- * Due to small number of PWM channels are only one PWM assigned
- * to one motor. For this case there is two ways how to stop the
- * engine. If you use engine_x_pwm(0); the motors will be stopped
- * by shorting its coils. This will stop as fast as possible, but
- * it also generates huge electromagnetic noise. If you want to
- * stop smoothly use engine_x_en(ENGINE_EN_OFF); this will disconnect
- * the power from the engines.
- *
- */
-
-
-
-// Author: Jirka Kubias <jirka@Jirka-NB>, (C) 2008
-//
-// Copyright: See COPYING file that comes with this distribution
-//
-//
-
-
-
-
-
-#ifndef ENGINE_H
-#define ENGINE_H
-
-
-#define ENGINE_EN_ON 1 ///< Enables Engine
-#define ENGINE_EN_OFF 0 ///< Disables Engine
-
-
-#define ENGINE_DIR_BW 1 ///< Backward direction
-#define ENGINE_DIR_FW 0 ///< Forward direction
-
-
-void init_engine_A();
-void init_engine_B();
-
-void engine_A_en(unsigned status);
-void engine_B_en(unsigned status);
-
-void engine_A_dir(unsigned dir);
-void engine_B_dir(unsigned dir);
-
-void engine_A_pwm(unsigned pwm); // pwm is in percent, range 0~100
-void engine_B_pwm(unsigned pwm); // pwm is in percent, range 0~100
-
-
-
-#endif
+++ /dev/null
-// $Id$
-// $Name$
-// $ProjectName$
-
-/**
- * \mainpage EB-ebb code sample
- *
- * \section Introduction
- * This codes are designed for use with ebBoard developed in DCE CVUT.
- * There are two purpose of this program:
- *
- * 1) library named ebb, it contains function for handling engines,
- * servos, ADC (median or avery filtered) and power switch.
- *
- * 2) in main.c file is simply HOW-TO use this libraries
- *
- * Short description of ebb library:
- *
- * ADC \96 This library use 4 ADC channels which parameters I defined
- * in adc.h or adc_filtr.h. There is two implementation of ADC output
- * filter. First is simply averaging ((last value + actual value)/2),
- * for this filter you have to include adc.h. The Second filter is
- * median filter in adc_filtr.h . The size of this filter is defined
- * in adc_filtr.h.
- *
- * PowerSwitch \96 ebboard have one 6A power switch which can be used for
- * switching small loads (capacity or resistant recommended). In powswitch.h is defined initialization, on and off function.
- *
- * Servos \96 ebboard have three servo connectors. In servo.h is defined
- * functions for setting them. The servo range is divided into 256 (0~255)
- * steps.
- *
- * Engines \96 this part can controls up two DC motors (5A each) or in
- * special cases one motor (up to 10A). In engines.h is defined several
- * controls function. Read carefully description in this section. Is
- * important to understanding the way how to stop engines.
- *
- */
-
-/**
- * @file main.c
- *
-* @brief Demo application demonstrating use of eb_ebb library.
- * This file provides simply how-to use eb_ebb library.
- * From main function is called init_perip function
- * where is initialized servos, engines, power switch,
- * CAN,ADC and serial port. After this initialization is shown
- * how to control each devices. This sample also include simply
- * sample of sending and receiving CAN message.
- *
- */
-
-
-#include <lpc21xx.h> /* LPC21xx definitions */
-#include <errno.h>
-#include <periph/can.h>
-#include <string.h>
-#include <deb_led.h>
-#include "uart.h"
-#include "servo.h"
-#include "powswitch.h"
-#include "engine.h"
-//#include "adc.h" // header ADC with averaging filter
-#include "adc_filtr.h" // header ADC with mean filter
-
-
-
-
-#define CAN_SPEED 1000000 ///< CAN speed
-
-#define CAN_SERVO 0x32 ///< CAN ID for servo message
-
-/**
- * Variables ISR values
- */
-/*@{*/
-#define CAN_ISR 0
-#define ENG_ISR 1
-#define ADC_ISR 3
-#define SERVO_ISR 5
-/*@}*/
-
-#define SPEED 30 ///< Motor speed
-
-
-/**
- * Dummy wait (busy wait)
- * This function shoul be removed in future
- */
-void dummy_wait(void)
-{
- int i = 1000000;
-
- while(--i);
-}
-
-/**
- * This function is called when we recieve CAN message.
- * Its called from CAN ISR
- *
- * @param *msg structure of can message (can_msg_t)
- *
- */
-void can_rx(can_msg_t *msg) {
- can_msg_t rx_msg;
-
- memcpy(&rx_msg, msg, sizeof(can_msg_t));
-
- switch (rx_msg.id) { // demo sample parsing recieved message by ID
- case CAN_SERVO:
-
- set_servo(0, rx_msg.data[0]);
- set_servo(1, rx_msg.data[1]);
- set_servo(2, rx_msg.data[2]);
- break;
-
- default:
- break;
- }
-}
-
-
-/**
- * Inicializes pepherials used in ebb library - sample use
- *
- */
-void init_perip(void)
-{
- init_servo(SERVO_ISR);
- init_pow_switch();
-
- init_engine_A();
- init_engine_B();
-
- init_uart0((int)9600 ,UART_BITS_8, UART_STOP_BIT_1, UART_PARIT_OFF, 0 );
- //init_adc(ADC_ISR); // inicialization ADC with averaging filter
- init_adc_filter(ADC_ISR); // inicialization ADC with mean filter
- can_init_baudrate(CAN_SPEED, CAN_ISR, can_rx);
-}
-
-
-/**
- * Main function contains a small sample how to use ebb library.
- *
- */
-int main (void) {
-
- init_perip(); // sys init MCU
-
- set_servo(0, 0x80); // set servo 1 to center position
- set_servo(1, 0x80); // set servo 2 to center position
- set_servo(2, 0x80); // set servo 3 to center position
-
- engine_A_dir(ENGINE_DIR_FW); // set engine A to direction forward
- engine_B_dir(ENGINE_DIR_BW); // set engine B to direction backward
- engine_A_en(ENGINE_EN_ON); // enables engine A
- engine_B_en(ENGINE_EN_ON); // enables engine B
- engine_A_pwm(SPEED); // sets speed on Engine A
- engine_B_pwm(SPEED); // sets speed on Engine B
-
-
- can_msg_t msg; // This part is sending CAN messge
- msg.id = 0xAA; // CAN message ID
- msg.flags = 0;
- msg.dlc = 1; // number of transmited data bytes
- msg.data[0] = 0x55; // data byte
- while(can_tx_msg(&msg)); // sending function
-
-
- while(1) // this will blink for ever
- {
- __deb_led_on(LEDG);
- dummy_wait();
- __deb_led_off(LEDG);
- dummy_wait();
- }
-}
-
-
-
+++ /dev/null
-#include <lpc21xx.h> /* LPC21xx definitions */
-#include "powswitch.h"
-
-
-
-
-
-#define ESW (1<<16) ///< Pin define
-
-
-
-void init_pow_switch(void)
-{
- IO0DIR |= ESW; // enable output
- IO0CLR |= ESW; // sets to LOW level
-
-
- PINSEL1 &= ~(PINSEL_3 << 0); // set as GPIO
-}
-
-void pow_switch_on(void)
-{
- IO0SET |= ESW; // sets to LOW level
-}
-
-
-void pow_switch_off(void)
-{
- IO0CLR |= ESW; // sets to LOW level
-}
+++ /dev/null
-#ifndef POWSWITCH_H
-#define POWSWITCH_H
-
-/** Initializes power switch
- */
-void init_pow_switch(void);
-
-
-/** Power switch ON
- */
-void pow_switch_on(void);
-
-/** Power switch OFF
- */
-void pow_switch_off(void);
-
-#endif
+++ /dev/null
-
-
-#include <lpc21xx.h> // LPC21XX Peripheral Registers
-#include <deb_led.h>
-#include <system_def.h>
-#include "servo.h"
-
-
-#define SERVO2 (1<<10)
-#define SERVO0 (1<<12)
-#define SERVO1 (1<<13)
-
-
-
-#define TIM_EMR_NOTHING 0
-#define TIM_EMR_CLEAR 1
-#define TIM_EMR_SET 2
-#define TIM_EMR_TOGLE 3
-
-#define TIM_EMR_PIN_ON 1
-#define TIM_EMR_PIN_OFF 0
-
-#define TIME20MS ((CPU_APB_HZ) / 50)
-#define SERVOTICK (((CPU_APB_HZ / 50) / 20) / 256)
-
-
-unsigned char servo[3];
-
-
-
-// ---------------- SERVO PART -------------------------------
-
-
-void tc1 (void) __attribute__ ((interrupt));
-
-void tc1 (void) {
-
- time_ms +=20;
-
- T1EMR |= (TIM_EMR_PIN_ON<<0) | (TIM_EMR_PIN_ON<<1) | (TIM_EMR_PIN_ON<<3);
-
- T1MR0 = (servo[0] + 256) * SERVOTICK;
- T1MR1 = (servo[1] + 256) * SERVOTICK;
- T1MR3 = (servo[2] + 256) * SERVOTICK;
-
- if (T1IR != 4)
- {
- __deb_led_on(LEDR);
- }
-
- T1IR = 4; // Vynulovani priznaku preruseni
- VICVectAddr = 0; // Potvrzeni o obsluze preruseni
-}
-
-void set_servo(char serv, char position)
-{
- if (serv == 0) servo[0] = position;
- if (serv == 1) servo[1] = position;
- if (serv == 2) servo[2] = position;
-}
-
-/* Setup the Timer Counter 1 Interrupt */
-void init_servo (unsigned rx_isr_vect)
-{
-
- IO0DIR |= (SERVO0 | SERVO1 | SERVO2); // enables servo output
- IO0SET |= (SERVO0 | SERVO1 | SERVO2); // sets to High level
-
- PINSEL0 &= ~((PINSEL_3 << 24) | (PINSEL_3 << 26));
- PINSEL0 |= (PINSEL_2 << 24) | (PINSEL_2 << 26);
- PINSEL1 &= ~(PINSEL_3 << 8);
- PINSEL1 |= (PINSEL_1 << 8);
-
-
- servo[0] = 0;
- servo[1] = 127;
- servo[2] = 0xFF;
-
- T1PR = 0;
- T1MR2 = TIME20MS;
- T1MR0 = (servo[0] + 256) * SERVOTICK;
- T1MR1 = (servo[1] + 256) * SERVOTICK;
- T1MR3 = (servo[2] + 256)* SERVOTICK;
- T1MCR = (3<<6); // interrupt on MR1
-
- T1EMR = (TIM_EMR_PIN_ON<<0) | (TIM_EMR_PIN_ON<<1) | (TIM_EMR_PIN_ON<<3) \
- | (TIM_EMR_CLEAR << 4) | (TIM_EMR_CLEAR << 6) | (TIM_EMR_CLEAR << 10);
-
-
- T1TCR = 1; // Starts Timer 1
-
-
- ((uint32_t*)&VICVectAddr0)[rx_isr_vect] = (unsigned long)tc1; // Nastaveni adresy vektotu preruseni
- ((uint32_t*)&VICVectCntl0)[rx_isr_vect] = 0x20 | 0x5; // vyber casovece pro preruseni
- VICIntEnable = (1<<5); // Povoli obsluhu preruseni
-}
-
-
-// ---------------- powSitch PART -------------------------------
-
+++ /dev/null
-/**
- * @file servo.h
- *
- * @brief FIXME
- * This file provides simply how-to use eb_ebb library.
- * From main function is called init_perip function
- * where is initialized servos, engines, power switch,
- * CAN,ADC and serial port. After this initialization is shown
- * how to control each devices. This sample also include simply
- * sample of sending and receiving CAN message.
- *
- */
-
-
-
-#ifndef SERVO_H
-#define SERVO_H
-
-
-
-/** gobal time
- * @note incremented twenty 20ms, overrun every 1194hours
- */
-volatile unsigned int time_ms;
-
-/** Initialize servos
- * @note All three servos - should be fixed FIXME
- */
-void init_servo(unsigned rx_isr_vect);
-
-
-/** Sets serv position
- * @return 0
- * @note VPB = APB - name conflict FIXME
- * @param servo define servo
- * @param position new position for servo
- */
-void set_servo(char servo, char position);
-
-#endif
+++ /dev/null
-\r
- #include <lpc21xx.h> \r
- #include "uart.h"\r
- #include <system_def.h>\r
-\r
-\r
-\r
-\r
- #define UART_DLAB 0x80\r
-\r
-\r
-void init_uart0(int baudrate, char bits, char stopbit, char parit_en, char parit_mode ) \r
-{ \r
-\r
- int pom , vala, valb;\r
-\r
- PINSEL0 |= ( PINSEL_1<< 0) | ( PINSEL_1 << 2); \r
-\r
- U0LCR =UART_DLAB | bits | stopbit | parit_en | parit_mode; // nastaven� datov�ho slova na 8 bit� a jeden stop bit bez parity, nastaven� DLAB na log "1"\r
- \r
- \r
- pom = (CPU_APB_HZ)/(16 * baudrate);\r
- \r
- vala = (CPU_APB_HZ)/(16 * pom);\r
- valb = (CPU_APB_HZ)/(16 * (pom + 1));\r
-\r
- vala = baudrate - vala;\r
- valb = baudrate - valb;\r
-\r
- if (vala < 0) vala *= -1;\r
- if (valb < 0) valb *= -1;\r
- \r
- if (vala > valb) pom += 1;\r
-\r
- U0DLL = (char) (pom & 0xFF);\r
- U0DLM = (char) ((pom >> 8) & 0xFF); // nastaven� p�edd�li�ky na 57600Bd\r
- \r
- U0LCR &= ~UART_DLAB; // vynulov�n� DLAB \r
-\r
- }\r
-\r
-\r
-unsigned char uart1GetCh(void) // Nuceny prijem z uart1\r
-{\r
- while (!(U1LSR & 1)); // cekani na prichozi byte\r
- return (unsigned char)U1RBR; // navraceni prijateho byte\r
-}\r
-\r
-unsigned char uart0GetCh(void) // Nuceny prijem z uart1\r
-{\r
- while (!(U0LSR & 1)); // cekani na prichozi byte\r
- return (unsigned char)U0RBR; // navraceni prijateho byte\r
-}\r
-\r
-void uart1SendCh(char ch) // vyslani znaku na uart1\r
-{\r
- while (!(U1LSR & 0x20)); // ceka na odeslani predchozich dat\r
- U1THR=ch; // odeslani Byte\r
- \r
-}\r
-\r
-void uart0SendCh(char ch) // vyslani znaku na uart0\r
-{\r
- while (!(U0LSR & 0x20)); // ceka na odeslani predchozich dat\r
- U0THR=ch; // odeslani Byte\r
-}\r
-\r
-\r
-void init_uart1(int baudrate, char bits, char stopbit, char parit_en, char parit_mode ) \r
-{ \r
-\r
- int pom , vala, valb;\r
-\r
- PINSEL0 |= ( PINSEL_1<< 16) | ( PINSEL_1 << 18); \r
-\r
- U1LCR =UART_DLAB | bits | stopbit | parit_en | parit_mode; // nastaven� datov�ho slova na 8 bit� a jeden stop bit bez parity, nastaven� DLAB na log "1"\r
- \r
- \r
- pom = (CPU_APB_HZ)/(16 * baudrate);\r
- \r
- vala = (CPU_APB_HZ)/(16 * pom);\r
- valb = (CPU_APB_HZ)/(16 * (pom + 1));\r
-\r
- vala = baudrate - vala;\r
- valb = baudrate - valb;\r
-\r
- if (vala < 0) vala *= -1;\r
- if (valb < 0) valb *= -1;\r
- \r
- if (vala > valb) pom += 1;\r
-\r
- U1DLL = (char) (pom & 0xFF);\r
- U1DLM = (char) ((pom >> 8) & 0xFF); // nastaven� p�edd�li�ky na 57600Bd\r
- \r
- U1LCR &= ~UART_DLAB; // vynulov�n� DLAB \r
-\r
- }\r
-\r
-\r
-\r
+++ /dev/null
-#ifndef UART_H\r
-#define UART_H\r
-\r
-#define UART_BITS_5 0x0\r
-#define UART_BITS_6 0x1\r
-#define UART_BITS_7 0x2\r
-#define UART_BITS_8 0x3\r
-\r
-#define UART_STOP_BIT_1 (0x0 << 2)\r
-#define UART_STOP_BIT_2 (0x1 << 2)\r
-\r
-#define UART_PARIT_ENA (0x1 << 3)\r
-#define UART_PARIT_OFF (0x0 << 3)\r
-#define UART_PARIT_ODD (0x0 << 4)\r
-#define UART_PARIT_EVEN (0x1 << 4)\r
-#define UART_PARIT_FORCE_1 (0x2 << 4)\r
-#define UART_PARIT_FORCE_0 (0x3 << 4)\r
-\r
-\r
-\r
-\r
-void init_uart1(int baudrate, char bits, char stopbit, char parit_en, char parit_mode );\r
-void init_uart0(int baudrate, char bits, char stopbit, char parit_en, char parit_mode );\r
-unsigned char uart1GetCh(void);\r
-unsigned char uart0GetCh(void);\r
-void uart1SendCh(char ch);\r
-void uart0SendCh(char ch);\r
-\r
-#endif\r