| Remote Access Control |

# config.h

Go to the documentation of this file.

    00001 // This file has been prepared for Doxygen automatic documentation generation.
    00050 #ifndef CONFIG_H
    00051 #define CONFIG_H
    00052
    00053
    00054 #define ASK
    00055 //#define FSK
    00056
    00058 //#define BPS_19200
    00059 #define BPS_9600
    00060 //#define BPS_4800
    00061 //#define BPS_2400
    00062
    00063
    00065 #define NOWDT
    00066
    00068 #define NOBOD
    00069
    00071 #define INVERTED_MANCHESTER
    00073 //#define USE_UART
    00074
    00075 #define KEY_BITS 128
    00076 //#define KEY_BITS 192
    00077 //#define KEY_BITS 256
    00078
    00080 #define SCHEDULE_SPLIT_BLOCKS 8
    00081
    00083 #define PREBURST_BYTES 16
    00084
    00086 #define SERIAL_NO_BYTES 4
    00087
    00089 #define COMMAND_CODE_BYTES 1
    00090
    00092 #define SEQ_COUNTER_BYTES 4
    00093
    00095 #define MAC_BYTES 4
    00096
    00098 #define CRC_POLY 0x8005 // CRC-16 standard.
    00099 //#define POLY 0x1021 // CRC-CCITT standard.
    00100
    00102 #define MAX_WATCHDOG_RESETS 3
    00103
    00105 #define BUTTON_MASK ((1<<PB1) | (1<<PB2))
    00106
    00108 #define TEACH_COMMAND ((1<<PB1) | (1<<PB2))
    00109
    00110
    00111
    00112
    00113
    00114 /* --- Calculated parameters follow, do not change --- */
    00115
    00117 #define BLOCK_SIZE 16
    00119 #define CMAC_SUBKEY_SIZE BLOCK_SIZE
    00120
    00121 // Calculate some info based on key bit count.
    00122 #if KEY_BITS == 128
    00123   #define ROUNDS 10
    00124   #define KEY_SIZE 16
    00125 #elif KEY_BITS == 192
    00126   #define ROUNDS 12
    00127   #define KEY_SIZE 24
    00128 #elif KEY_BITS == 256
    00129   #define ROUNDS 14
    00130   #define KEY_SIZE 32
    00131 #else
    00132   #error Key must be 128, 192 or 256 bits!
    00133 #endif
    00134
    00136 #define SCHEDULE_SIZE_BLOCKS (ROUNDS+1)
    00138 #define SCHEDULE_SIZE (SCHEDULE_SIZE_BLOCKS*BLOCK_SIZE)
    00140 #define SCHEDULE_SPLIT (SCHEDULE_SPLIT_BLOCKS*BLOCK_SIZE)
    00142 #define SCHEDULE_EXTRA_BLOCKS (SCHEDULE_SIZE_BLOCKS-SCHEDULE_SPLIT_BLOCKS)
    00144 #define SCHEDULE_EXTRA (SCHEDULE_EXTRA_BLOCKS*BLOCK_SIZE)
    00145
    00146 // Check validity of schedule split configuration.
    00147 #if SCHEDULE_EXTRA < 0
    00148   #error Split cannot exceed schedule length
    00149 #endif
    00150
    00152 #define MESSAGE_SIZE_WO_MAC (SERIAL_NO_BYTES+COMMAND_CODE_BYTES+SERIAL_NO_BYTES)
    00153
    00154 // Check that message payload does not exceed AES block size.
    00155 #if MESSAGE_SIZE_WO_MAC > BLOCK_SIZE
    00156   #error Message payload exceeds AES block size.
    00157 #endif
    00158
    00160 #define MESSAGE_SIZE_W_MAC (MESSAGE_SIZE_WO_MAC+MAC_BYTES)
    00161
    00162 // Prepare type and max value for serial number.
    00163 #if SERIAL_NO_BYTES == 1
    00164   #define SERIAL_NO_TYPE byte
    00165   #define SERIAL_NO_MAX 0xff
    00166 #elif SERIAL_NO_BYTES == 2
    00167   #define SERIAL_NO_TYPE uint16_t
    00168   #define SERIAL_NO_MAX 0xffff
    00169 #elif SERIAL_NO_BYTES == 4
    00170   #define SERIAL_NO_TYPE uint32_t
    00171   #define SERIAL_NO_MAX 0xffffffff
    00172 #else
    00173   #error Invalid serial number size, must be 1, 2 or 4 bytes.
    00174 #endif
    00175
    00176 // Prepare type and max value for command code.
    00177 #if COMMAND_CODE_BYTES == 1
    00178   #define COMMAND_CODE_TYPE byte
    00179   #define COMMAND_CODE_MAX 0xff
    00180 #elif COMMAND_CODE_BYTES == 2
    00181   #define COMMAND_CODE_TYPE uint16_t
    00182   #define COMMAND_CODE_MAX 0xffff
    00183 #elif COMMAND_CODE_BYTES == 4
    00184   #define COMMAND_CODE_TYPE uint32_t
    00185   #define COMMAND_CODE_MAX 0xffffffff
    00186 #else
    00187   #error Invalid command code size, must be 1, 2 or 4 bytes.
    00188 #endif
    00189
    00190 // Prepare type and max value for sequential counter.
    00191 #if SEQ_COUNTER_BYTES == 1
    00192   #define SEQ_COUNTER_TYPE byte
    00193   #define SEQ_COUNTER_MAX 0xff
    00194 #elif SEQ_COUNTER_BYTES == 2
    00195   #define SEQ_COUNTER_TYPE uint16_t
    00196   #define SEQ_COUNTER_MAX 0xffff
    00197 #elif SEQ_COUNTER_BYTES == 4
    00198   #define SEQ_COUNTER_TYPE uint32_t
    00199   #define SEQ_COUNTER_MAX 0xffffffff
    00200 #else
    00201   #error Invalid sequential counter size, must be 1, 2 or 4 bytes.
    00202 #endif
    00203
    00205 #define SERIAL_NO_ADDRESS 0
    00206
    00208 #define SEQ_COUNTER_ADDRESS (SERIAL_NO_ADDRESS+SERIAL_NO_BYTES)
    00209
    00211 #define SECRET_KEY_ADDRESS (SEQ_COUNTER_ADDRESS+SEQ_COUNTER_BYTES)
    00212
    00214 #define SHARED_KEY_ADDRESS (SECRET_KEY_ADDRESS+KEY_SIZE)
    00215
    00216
    00217
    00218 #endif
    00219

@DOC_TITLE@