examples/AVR/Slave/hardware.h
author Edouard Tisserant
Mon, 03 Aug 2015 18:01:58 +0200
changeset 794 8bfe0ac00cdb
parent 413 57c7a451c671
permissions -rw-r--r--
merged
413
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
     1
/*
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
     2
This file is part of CanFestival, a library implementing CanOpen Stack.
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
     3
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
     4
Copyright (C): Edouard TISSERANT and Francis DUPIN
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
     5
AVR Port: Andreas GLAUSER and Peter CHRISTEN
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
     6
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
     7
See COPYING file for copyrights details.
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
     8
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
     9
This library is free software; you can redistribute it and/or
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    10
modify it under the terms of the GNU Lesser General Public
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    11
License as published by the Free Software Foundation; either
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    12
version 2.1 of the License, or (at your option) any later version.
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    13
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    14
This library is distributed in the hope that it will be useful,
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    15
but WITHOUT ANY WARRANTY; without even the implied warranty of
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    16
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    17
Lesser General Public License for more details.
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    18
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    19
You should have received a copy of the GNU Lesser General Public
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    20
License along with this library; if not, write to the Free Software
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    21
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    22
*/
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    23
/******************************************************************************
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    24
MCU ports and Bits
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    25
Makros for access on hardware
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    26
******************************************************************************/
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    27
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    28
#ifndef _HARDWARE_INCLUDED
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    29
#define _HARDWARE_INCLUDED
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    30
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    31
/******************************************************************************
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    32
Makros for bit access on the ports and registers
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    33
******************************************************************************/
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    34
// Macros for set and clear bits in I/O registers
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    35
#define setbit(address,bit) ((address) |= (1<<(bit)))
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    36
#define clearbit(address,bit) ((address) &= ~(1<<(bit)))
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    37
#define togglebit(address,bit) ((address) ^= (1<<(bit)))
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    38
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    39
// Macro for testing of a single bit in an I/O location
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    40
#define checkbit(address,bit) ((address) & (1<<(bit)))
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    41
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    42
/************************** Hardware Makros **********************************/
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    43
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    44
// Read the inputs
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    45
#define get_inputs()		(~PINA)
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    46
#define read_bcd()		(~PINC & 0x0F)
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    47
// Write the outputs
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    48
#define set_outputs(val)	PORTB = ~(val)
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    49
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    50
#endif	// _HARDWARE_INCLUDED
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    51
57c7a451c671 New named folder, first DS401 profile module, Makefile
peter
parents:
diff changeset
    52