Commit from enseirb on branch b_eirbot (2008-03-09 15:04 CET) ======================================
Adding encoders UNIOC (Eirbot 2k7 and counting) + aversive modules/devices/encoders/encoders_unioc/Makefile 1.1.2.1 + aversive modules/devices/encoders/encoders_unioc/encoders_unioc.c 1.1.2.1 + aversive modules/devices/encoders/encoders_unioc/encoders_unioc.h 1.1.2.1 + aversive modules/devices/encoders/encoders_unioc/config/encoders_unioc_config.h 1.1.2.1 ========================================================= aversive/modules/devices/encoders/encoders_unioc/Makefile (1.1.2.1) ========================================================= @@ -0,0 +1,6 @@ +TARGET = encoders_unioc + +# List C source files here. (C dependencies are automatically generated.) +SRC = encoders_unioc.c + +include $(AVERSIVE_DIR)/mk/aversive_module.mk ================================================================= aversive/modules/devices/encoders/encoders_unioc/encoders_unioc.c (1.1.2.1) ================================================================= @@ -0,0 +1,90 @@ +/* + * Copyright Droids Corporation, Microb Technology, Eirbot (2005) + * + * This program 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 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Revision : $Id: encoders_unioc.c,v 1.1.2.1 2008-03-09 14:04:43 enseirb Exp $ + * + */ + +/** \file encoders_eirbot_unioc.c + * \brief achieves acess to incremental encoders managed by a FPGA and accessed via external ram interface + * + * \todo nothing ! + * + * \test + * + * This modules reads 8 bits encoders values on an external interface. + * there are two necessary busses with the interface logic: 8 bits data bus and a n bits selection bus. + * ( see the VDHL for the xilinx program) + * with n bits on the selection bus, you can access to 2^n encoders. + * + * Lamygale 10/10/2005 + * + */ + +#include <aversive.h> +#include "encoders_unioc.h" + +/** + * fonction utilisée 2 fois seulement, acquiert un codeur +*/ +inline encoders get_encoder(uint8_t num) +{ + encoders *val; + + val = (encoders*)(ENCODERS_BASE_ADDRESS + 4*num ); + + return *val; +} + +/** Initialisation des codeurs, variables, et ports */ +void encoders_init(u08 config) +{ + wait_ms(500); + MCUCR = MCUCR | (1 << SRE); + raz_encoders(); + ENCODERS_CONFIG = config; +} + + +/** + * Resets the values of the encoders + * + **/ +void raz_encoders(void) +{ + do + { + ENCODERS_CONFIG |= (1 << CLEAR_ENCODERS); + nop(); + ENCODERS_CONFIG &=~(1<< CLEAR_ENCODERS); + } + while( !(~ENCODERS_CONFIG & (1<<CLEAR_ENCODERS)) ); +} + +/** Extraction d'une valeur de codeur */ +encoders encoders_get_value(uint8_t number) +{ + encoders value; + uint8_t flags; + + IRQ_LOCK(flags); + value = get_encoder(number); + IRQ_UNLOCK(flags); + + return value; +} + ================================================================= aversive/modules/devices/encoders/encoders_unioc/encoders_unioc.h (1.1.2.1) ================================================================= @@ -0,0 +1,59 @@ +/* + * Copyright Droids Corporation, Microb Technology, Eirbot (2005) + * + * This program 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 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Revision : $Id: encoders_unioc.h,v 1.1.2.1 2008-03-09 14:04:43 enseirb Exp $ + * + */ + +/** \file encoders_eirbot.h + * \brief universal Interface for incremental coders + */ + +#ifndef _ENCODERS_EIRBOT_UNIOC_H_ +#define _ENCODERS_EIRBOT_UNIOC_H_ + +#include <encoders_unioc_config.h> + + +/** definition du registre interne au FPGA */ +#define ENCODERS_CONFIG _SFR_MEM8(ADDRESS_ENCODERS_CONFIG) +#define CLEAR_ENCODERS 7 + + +typedef int32_t encoders; + +/** + * Initialisation of counters, variables + * Sets the encoders rotationwise : + * each byte of the data configures one encoder. + * refer to the encoders_eirbot_unioc_config_file + * to find the corresponding byte number of each encoder + */ +void encoders_init(uint8_t config); + + +/** + *Resets the values of any encoder synthetised in the FPGA + * + * */ +void raz_encoders(void); + + +/** Extract counter value from the FPGA*/ +encoders encoders_get_value(uint8_t number); + +#endif =============================================================================== aversive/modules/devices/encoders/encoders_unioc/config/encoders_unioc_config.h (1.1.2.1) =============================================================================== @@ -0,0 +1,32 @@ +/** \file encoders_eirbot_unioc_config.h + * \brief configuration du module codeur UNIOC + */ + +#ifndef _ENCODERS_EIRBOT_UNIOC_CONFIG_ +#define _ENCODERS_EIRBOT_UNIOC_CONFIG_ + +/** adresse la plus basse à partir de laquelle se trouvent toutes les autres données codeur. + * Ceci implique des adresses consécutives pour les modules codeurs + * #define BASE_CODEUR 0x1200 +*/ + +#define ENCODERS_BASE_ADDRESS 0x1300 + +/** nombre de codeurs implantés dans le FPGA et utilisés par le µc +*/ +#define ENCODERS_NUMBER 4 + +/** Registre ENCODERS_CONFIG : + * correspondance numero de bit, codeur + */ +#define L_ENGINE_ENCODER 0 +#define R_ENGINE_ENCODER 1 +#define L_SEPARATED_ENCODER 2 +#define R_SEPARATED_ENCODER 3 + + +#define ADDRESS_ENCODERS_CONFIG 0x1400 + +#endif + +
_______________________________________________ Avr-list mailing list Avr-list@droids-corp.org CVSWEB : http://cvsweb.droids-corp.org/cgi-bin/viewcvs.cgi/aversive WIKI : http://wiki.droids-corp.org/index.php/Aversive DOXYGEN : http://zer0.droids-corp.org/doxygen_aversive/html/ BUGZILLA : http://bugzilla.droids-corp.org COMMIT LOGS : http://zer0.droids-corp.org/aversive_commitlog