| 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
  1269

Date
  2006-12-06 12:37:09 +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 | BPS_9600
#define | BUTTON_MASK ((1<<PB1) | (1<<PB2))
#define | CMAC_SUBKEY_SIZE BLOCK_SIZE
#define | COMMAND_CODE_BYTES 1
#define | COMMAND_CODE_MAX 0xff
#define | COMMAND_CODE_TYPE byte
#define | CRC_POLY 0x8005
#define | INVERTED_MANCHESTER
#define | KEY_BITS 128
#define | KEY_SIZE 16
#define | MAC_BYTES 4
#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 | NOBOD
#define | NOWDT
#define | PREBURST_BYTES 16
#define | ROUNDS 10
#define | SCHEDULE_EXTRA (SCHEDULE_EXTRA_BLOCKS*BLOCK_SIZE)
#define | SCHEDULE_EXTRA_BLOCKS (SCHEDULE_SIZE_BLOCKS-SCHEDULE_SPLIT_BLOCKS)
#define | SCHEDULE_SIZE (SCHEDULE_SIZE_BLOCKS*BLOCK_SIZE)
#define | SCHEDULE_SIZE_BLOCKS (ROUNDS+1)
#define | SCHEDULE_SPLIT (SCHEDULE_SPLIT_BLOCKS*BLOCK_SIZE)
#define | SCHEDULE_SPLIT_BLOCKS 8
#define | SECRET_KEY_ADDRESS (SEQ_COUNTER_ADDRESS+SEQ_COUNTER_BYTES)
#define | SEQ_COUNTER_ADDRESS (SERIAL_NO_ADDRESS+SERIAL_NO_BYTES)
#define | SEQ_COUNTER_BYTES 4
#define | SEQ_COUNTER_MAX 0xffffffff
#define | SEQ_COUNTER_TYPE uint32_t
#define | SERIAL_NO_ADDRESS 0
#define | SERIAL_NO_BYTES 4
#define | SERIAL_NO_MAX 0xffffffff
#define | SERIAL_NO_TYPE uint32_t
#define | SHARED_KEY_ADDRESS (SECRET_KEY_ADDRESS+KEY_SIZE)
#define | TEACH_COMMAND ((1<<PB1) | (1<<PB2))

## Define Documentation

#define ASK

Uncomment to use Amplitude Shift Keying.

Definition at line 54 of file config.h.

#define BLOCK_SIZE 16

AES state block size in number of bytes.

Definition at line 117 of file config.h.

Referenced by calcCMAC(), calcCMACSubkey(), calcKeySchedule(), cipherLookup(), and transmitTeachMessage().

#define BPS_9600

Bits per second. Note: Manchester uses to bits per data bit.

Definition at line 59 of file config.h.

#define BUTTON_MASK ((1<<PB1) | (1<<PB2))

Bitmask to use when masking out unwanted inputs when reading buttons.

Definition at line 105 of file config.h.

Referenced by pinChangeHandler(), setupPeripherals(), and sleepAndGetCommand().

#define CMAC_SUBKEY_SIZE BLOCK_SIZE

Subkey used for calculating AES-CMAC value.

Definition at line 119 of file config.h.

#define COMMAND_CODE_BYTES 1

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

Definition at line 89 of file config.h.

#define COMMAND_CODE_MAX 0xff

Definition at line 179 of file config.h.

#define COMMAND_CODE_TYPE byte

Definition at line 178 of file config.h.

Referenced by main(), pinChangeHandler(), and sleepAndGetCommand().

#define CRC_POLY 0x8005

CRC generator polynomial.

Definition at line 98 of file config.h.

Referenced by calcCRC().

#define INVERTED_MANCHESTER

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

Definition at line 71 of file config.h.

#define KEY_BITS 128

Use UART asynchronous transmission instead of Manchester. Use AES128.

Definition at line 75 of file config.h.

#define KEY_SIZE 16

Key length in number of bytes.

Definition at line 124 of file config.h.

Referenced by calcKeySchedule(), and transmitTeachMessage().

#define MAC_BYTES 4

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

Definition at line 95 of file config.h.

Referenced by transmitCommandMessage().

#define MAX_WATCHDOG_RESETS 3

Maximum number of watchdog resets before entering error loop.

Definition at line 102 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 160 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 152 of file config.h.

Referenced by calcCMAC().

#define NOBOD

Disable BOD Reset Flag checking during startup, to avoid lock-up during debugging.

Definition at line 68 of file config.h.

#define NOWDT

Disable all use of watchdog timer except in error loop.

Definition at line 65 of file config.h.

#define PREBURST_BYTES 16

Number of preburst bytes for waking up the receiver. Empirical value.

Definition at line 83 of file config.h.

Referenced by transmitCommandMessage(), and transmitTeachMessage().

#define ROUNDS 10

Number of rounds/iterations in algorithm.

Definition at line 123 of file config.h.

Referenced by cipherLookup().

#define SCHEDULE_EXTRA (SCHEDULE_EXTRA_BLOCKS*BLOCK_SIZE)

How many bytes of schedule in secondary memory.

Definition at line 144 of file config.h.

#define SCHEDULE_EXTRA_BLOCKS (SCHEDULE_SIZE_BLOCKS-SCHEDULE_SPLIT_BLOCKS)

How many BLOCK_SIZE blocks of eschedule in secondary memory.

Definition at line 142 of file config.h.

#define SCHEDULE_SIZE (SCHEDULE_SIZE_BLOCKS*BLOCK_SIZE)

Number of bytes in precalculated key schedule.

Definition at line 138 of file config.h.

Referenced by calcKeySchedule().

#define SCHEDULE_SIZE_BLOCKS (ROUNDS+1)

Number of BLOCK_SIZE blocks in precalculated key schedule.

Definition at line 136 of file config.h.

#define SCHEDULE_SPLIT (SCHEDULE_SPLIT_BLOCKS*BLOCK_SIZE)

How many bytes before splitting schedule to secondary memory.

Definition at line 140 of file config.h.

Referenced by calcKeySchedule().

#define SCHEDULE_SPLIT_BLOCKS 8

How many BLOCK_SIZE blocks of precalculated key schedule in SRAM (rest in EEPROM).

Definition at line 80 of file config.h.

Referenced by cipherLookup().

#define SECRET_KEY_ADDRESS (SEQ_COUNTER_ADDRESS+SEQ_COUNTER_BYTES)

EEPROM address of secret key.

Definition at line 211 of file config.h.

#define SEQ_COUNTER_ADDRESS (SERIAL_NO_ADDRESS+SERIAL_NO_BYTES)

EEPROM address of sequential counter.

Definition at line 208 of file config.h.

#define SEQ_COUNTER_BYTES 4

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

Definition at line 92 of file config.h.

Referenced by startCounterUpdate(), and transmitTeachMessage().

#define SEQ_COUNTER_MAX 0xffffffff

Definition at line 199 of file config.h.

#define SEQ_COUNTER_TYPE uint32_t

Definition at line 198 of file config.h.

#define SERIAL_NO_ADDRESS 0

EEPROM address of serial number.

Definition at line 205 of file config.h.

#define SERIAL_NO_BYTES 4

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

Definition at line 86 of file config.h.

Referenced by transmitTeachMessage().

#define SERIAL_NO_MAX 0xffffffff

Definition at line 171 of file config.h.

#define SERIAL_NO_TYPE uint32_t

Definition at line 170 of file config.h.

#define SHARED_KEY_ADDRESS (SECRET_KEY_ADDRESS+KEY_SIZE)

EEPROM address of shared key.

Definition at line 214 of file config.h.

#define TEACH_COMMAND ((1<<PB1) | (1<<PB2))

Bitpattern indicating the button combination to use for teach mode.

Definition at line 108 of file config.h.

Referenced by main().

@DOC_TITLE@