| Remote Access Control |

# config.h File Reference

## Detailed Description

Header file for application configuration options.

This file contains the configuration options for the Remote Keyless Entry application. First, there are a set of user configurable options, then a lot of calculations based on the user configuration. Do not change the calculations unless you really know what you are doing.

- File: config.h
- Compiler: IAR EWAVR 4.11B
- Supported devices: ATtiny45/85
- AppNote: AVR411 - Secure Rolling Code Algorithm for Wireless Link

Author:
  Atmel Corporation: http://www.atmel.com
  Support email: avr@atmel.com

Name

Revision
  1272

Date
  2006-12-06 13:01:52 +0100 (on, 06 des 2006)

Copyright (c) 2006, Atmel Corporation All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

3. The name of ATMEL may not be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY ATMEL ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Definition in file config.h.

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Defines
#define | ASK
#define | BLOCK_SIZE 16
#define | CMAC_SUBKEY_SIZE BLOCK_SIZE
#define | COMMAND_CODE_BYTES 1
#define | COMMAND_CODE_MAX 0xff
#define | COMMAND_CODE_TYPE uint8_t
#define | CPU_F 8000000
#define | INVERTED_MANCHESTER
#define | KEY_BITS 128
#define | KEY_SIZE 16
#define | LAST_ROUND_CONSTANT 0x6C
#define | LEARN_MODE_INPUT_BIT PD5
#define | LEARN_MODE_INPUT_DDR DDRD
#define | LEARN_MODE_INPUT_PULLUP_REG PORTD
#define | LEARN_MODE_INPUT_REG PIND
#define | LEARN_MODE_OUTPUT_BIT PC5
#define | LEARN_MODE_OUTPUT_DDR DDRC
#define | LEARN_MODE_OUTPUT_HIGH() LEARN_MODE_OUTPUT_REG |= (1<<LEARN_MODE_OUTPUT_BIT);
#define | LEARN_MODE_OUTPUT_LOW() LEARN_MODE_OUTPUT_REG &= ~(1<<LEARN_MODE_OUTPUT_BIT);
#define | LEARN_MODE_OUTPUT_REG PORTC
#define | LEARN_MODE_PCINT_ENABLE_BIT PCIE2
#define | LEARN_MODE_PCINT_MASK_BIT PCINT21
#define | LEARN_MODE_PCINT_MASK_REG PCMSK2
#define | LEARN_MODE_PCINT_VECT PCINT2_vect
#define | LONG_TIMEOUT_HI_VALUE 1
#define | LONG_TIMEOUT_LO_VALUE 12578
#define | MAC_BYTES 4
#define | MAX_TRANSMITTERS 5
#define | MAX_WATCHDOG_RESETS 3
#define | MESSAGE_SIZE_W_MAC (MESSAGE_SIZE_WO_MAC+MAC_BYTES)
#define | MESSAGE_SIZE_WO_MAC (SERIAL_NO_BYTES+COMMAND_CODE_BYTES+SERIAL_NO_BYTES)
#define | POLY 0x8005
#define | RF_CARRIER 433
#define | ROUNDS 10
#define | RX_LIM_MAX 31
#define | RX_LIM_MIN 20
#define | RX_PRESCALE 14
#define | RX_XTAL_HZ 6764380
#define | SCHEDULE_BLOCK_REPETITIONS 1
#define | SCHEDULE_BUFFER_SIZE (BLOCK_SIZE*SCHEDULE_BLOCK_REPETITIONS)
#define | SCHEDULE_KEY_REPETITIONS 1
#define | SEQ_COUNTER_BYTES 4
#define | SEQ_COUNTER_MAX 0xffffffff
#define | SEQ_COUNTER_TYPE uint32_t
#define | SERIAL_NO_BYTES 4
#define | SERIAL_NO_MAX 0xffffffff
#define | SERIAL_NO_TYPE uint32_t
#define | WINDOW_SIZE 100

## Define Documentation

#define ASK

Do not erase transmitters upon valid teach message reception. Uncomment to use Amplitude Shift Keying.

Definition at line 68 of file config.h.

#define BLOCK_SIZE 16

AES state block size in number of bytes.

Definition at line 174 of file config.h.

Referenced by calcCMAC(), calcCMACSubkey(), cipher(), invCipher(), invKeyExpansion(), keyExpansion(), and learnMode().

#define CMAC_SUBKEY_SIZE BLOCK_SIZE

Subkey used for calculating AES-CMAC value.

Definition at line 176 of file config.h.

#define COMMAND_CODE_BYTES 1

Size in bytes of command code (1, 2 or 4).

Definition at line 84 of file config.h.

Referenced by main().

#define COMMAND_CODE_MAX 0xff

Definition at line 232 of file config.h.

#define COMMAND_CODE_TYPE uint8_t

Definition at line 231 of file config.h.

#define CPU_F 8000000

AVR CPU Frequency in Hz.

Definition at line 63 of file config.h.

Referenced by errorLoop().

#define INVERTED_MANCHESTER

Invert manchester output polarity, ie. 0 = 1->0, 1 = 0->1.

Definition at line 72 of file config.h.

#define KEY_BITS 128

Use UART asynchronous reception instead of Manchester. Use AES128.

Definition at line 76 of file config.h.

#define KEY_SIZE 16

Key length in number of bytes.

Definition at line 181 of file config.h.

Referenced by cipher(), invKeyExpansion(), keyExpansion(), learnMode(), main(), and prepareInvCipher().

#define LAST_ROUND_CONSTANT 0x6C

Definition at line 184 of file config.h.

Referenced by invCipher().

#define LEARN_MODE_INPUT_BIT PD5

Learn-Mode Input Bit.

Definition at line 125 of file config.h.

Referenced by learnModeSwitchHandler(), and setupLearnModeIO().

#define LEARN_MODE_INPUT_DDR DDRD

Learn-Mode Input Direction Register.

Definition at line 119 of file config.h.

Referenced by setupLearnModeIO().

#define LEARN_MODE_INPUT_PULLUP_REG PORTD

Learn-Mode Pull-up Enable Reg.

Definition at line 123 of file config.h.

Referenced by setupLearnModeIO().

#define LEARN_MODE_INPUT_REG PIND

Learn-Mode Input Register.

Definition at line 121 of file config.h.

Referenced by learnModeSwitchHandler().

#define LEARN_MODE_OUTPUT_BIT PC5

Learn-Mode Output Bit.

Definition at line 131 of file config.h.

Referenced by errorLoop(), and setupLearnModeIO().

#define LEARN_MODE_OUTPUT_DDR DDRC

Learn-Mode Output Direction Register.

Definition at line 127 of file config.h.

Referenced by errorLoop(), and setupLearnModeIO().

#define LEARN_MODE_OUTPUT_HIGH | ( |  | ) | LEARN_MODE_OUTPUT_REG |= (1<<LEARN_MODE_OUTPUT_BIT);

Macro to set Learn-Mode Output high.

Definition at line 133 of file config.h.

Referenced by errorLoop(), learnMode(), and setupLearnModeIO().

#define LEARN_MODE_OUTPUT_LOW | ( |  | ) | LEARN_MODE_OUTPUT_REG &= ~(1<<LEARN_MODE_OUTPUT_BIT);

Macro to set Learn-Mode Output low.

Definition at line 135 of file config.h.

Referenced by errorLoop(), and learnMode().

#define LEARN_MODE_OUTPUT_REG PORTC

Learn-Mode Output Register.

Definition at line 129 of file config.h.

#define LEARN_MODE_PCINT_ENABLE_BIT PCIE2

Learn-Mode PCINT enable bit.

Definition at line 113 of file config.h.

Referenced by setupLearnModeIO().

#define LEARN_MODE_PCINT_MASK_BIT PCINT21

Learn-Mode PCINT mask bit.

Definition at line 117 of file config.h.

Referenced by setupLearnModeIO().

#define LEARN_MODE_PCINT_MASK_REG PCMSK2

Learn-Mode PCINT mask register.

Definition at line 115 of file config.h.

Referenced by setupLearnModeIO().

#define LEARN_MODE_PCINT_VECT PCINT2_vect

Learn-Mode PCINT handler.

Definition at line 111 of file config.h.

#define LONG_TIMEOUT_HI_VALUE 1

High part of long delay = 1 * 8.39 s = 8.39 s.

Definition at line 104 of file config.h.

Referenced by startLongTimeout().

#define LONG_TIMEOUT_LO_VALUE 12578

Low part of long delay = 12578 * 0.128 ms = 1.61 s.

Definition at line 106 of file config.h.

Referenced by longTimeoutHandler().

#define MAC_BYTES 4

Size in bytes of MAC (must be less than or equal to AES BLOCK_SIZE).

Definition at line 90 of file config.h.

Referenced by main().

#define MAX_TRANSMITTERS 5

Maximum number of transmitters associated with one receiver.

Definition at line 93 of file config.h.

Referenced by learnMode().

#define MAX_WATCHDOG_RESETS 3

Maximum number of watchdog resets before entering error loop.

Definition at line 99 of file config.h.

Referenced by handleResetFlags().

#define MESSAGE_SIZE_W_MAC (MESSAGE_SIZE_WO_MAC+MAC_BYTES)

Total message size in bytes, including the MAC.

Definition at line 213 of file config.h.

#define MESSAGE_SIZE_WO_MAC (SERIAL_NO_BYTES+COMMAND_CODE_BYTES+SERIAL_NO_BYTES)

Message payload size in byte, excluding the MAC.

Definition at line 205 of file config.h.

Referenced by calcCMAC().

#define POLY 0x8005

CRC generator polynomial.

Definition at line 138 of file config.h.

Referenced by calcCRC().

#define RF_CARRIER 433

Use 433.9 MHz RF carrier.

Definition at line 56 of file config.h.

#define ROUNDS 10

Number of rounds/iterations in algorithm.

Definition at line 180 of file config.h.

Referenced by calcLastRoundKey(), cipher(), and invCipher().

#define RX_LIM_MAX 31

Definition at line 156 of file config.h.

Referenced by initReceiver().

#define RX_LIM_MIN 20

Definition at line 155 of file config.h.

Referenced by initReceiver().

#define RX_PRESCALE 14

Definition at line 154 of file config.h.

#define RX_XTAL_HZ 6764380

Definition at line 153 of file config.h.

#define SCHEDULE_BLOCK_REPETITIONS 1

Definition at line 182 of file config.h.

Referenced by calcLastRoundKey().

#define SCHEDULE_BUFFER_SIZE (BLOCK_SIZE*SCHEDULE_BLOCK_REPETITIONS)

Number of bytes needed for on-the-fly key schedule calculation.

Definition at line 202 of file config.h.

Referenced by invKeyExpansion(), and keyExpansion().

#define SCHEDULE_KEY_REPETITIONS 1

Definition at line 183 of file config.h.

#define SEQ_COUNTER_BYTES 4

Size in bytes of sequential counter (1, 2 or 4).

Definition at line 87 of file config.h.

Referenced by main().

#define SEQ_COUNTER_MAX 0xffffffff

Definition at line 252 of file config.h.

#define SEQ_COUNTER_TYPE uint32_t

Definition at line 251 of file config.h.

#define SERIAL_NO_BYTES 4

Size in bytes of serial number (1, 2 or 4).

Definition at line 81 of file config.h.

Referenced by main().

#define SERIAL_NO_MAX 0xffffffff

Definition at line 224 of file config.h.

#define SERIAL_NO_TYPE uint32_t

Definition at line 223 of file config.h.

#define WINDOW_SIZE 100

Size of rolling window of acceptance for counter values.

Definition at line 96 of file config.h.

Referenced by main().

@DOC_TITLE@