root / trunk / common / tooltron.h @ 293
History | View | Annotate | Download (2.8 KB)
| 1 | /********
|
|---|---|
| 2 | * This file is part of Tooltron. |
| 3 | * |
| 4 | * Tooltron is free software: you can redistribute it and/or modify |
| 5 | * it under the terms of the Lesser GNU General Public License as published by |
| 6 | * the Free Software Foundation, either version 3 of the License, or |
| 7 | * (at your option) any later version. |
| 8 | * |
| 9 | * Tooltron is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * Lesser GNU General Public License for more details. |
| 13 | * You should have received a copy of the Lesser GNU General Public License |
| 14 | * along with Tooltron. If not, see <http://www.gnu.org/licenses/>. |
| 15 | * |
| 16 | * Copyright 2009 Kevin Woo <kwoo@2ndt.com>, Brad Neuman <bneuman@andrew.cmu.edu> |
| 17 | * |
| 18 | ********/ |
| 19 | #ifndef _TOOLTRON_H_
|
| 20 | #define _TOOLTRON_H_
|
| 21 | |
| 22 | #include <stdint.h> |
| 23 | |
| 24 | /****** Message Dictionary ******/
|
| 25 | // Commonly used message bytes
|
| 26 | #define DELIM '^' |
| 27 | #define SERVER 1 |
| 28 | |
| 29 | // These are the bytes used in the messaage types
|
| 30 | #define TT_ACK 'a' // Ack |
| 31 | #define TT_NACK 'n' // Nack |
| 32 | #define TT_KC 'x' // A transaction containing a key and a card number |
| 33 | #define TT_GRANT 'q' // Tool access granted |
| 34 | #define TT_DENY 'f' // Tool access denied |
| 35 | #define TT_TIMEOUT 't' // Packet timeout |
| 36 | #define TT_RESET 'r' // Tool reset request |
| 37 | #define TT_BOOT 'b' // Tool boot message |
| 38 | #define TT_PROGM 'p' // Program mode request |
| 39 | #define TT_PROGD 'd' // Program data |
| 40 | #define TT_PING 'g' // Ping command |
| 41 | #define TT_BAD 0 // If there was a packet parsing error |
| 42 | |
| 43 | // Depricated commands:
|
| 44 | //#define TT_GET_KEY 'k' // Get a key from the keyboard
|
| 45 | //#define TT_SEND_KEY 's' // Send a Key back (has 1 extra data packet)
|
| 46 | //#define TT_ON 'o' // Turn the tool on
|
| 47 | |
| 48 | // Number of bytes that the PROGx packets have in the payload
|
| 49 | #define MAX_PAYLOAD_SIZE 32 |
| 50 | #define SEND_KEY_PACKET_SIZE 1 |
| 51 | #define PROGD_PACKET_SIZE MAX_PAYLOAD_SIZE
|
| 52 | #define SEND_KEY_PACKET_SIZE 1 |
| 53 | |
| 54 | // Tool timeout?
|
| 55 | #define TIMEOUT_SECONDS 10 |
| 56 | |
| 57 | #define SERVER_TIMEOUT_SECONDS 3 |
| 58 | |
| 59 | // Maximum attempts to retry
|
| 60 | #define TT_MAX_RETRY 3 |
| 61 | |
| 62 | // Memory locations
|
| 63 | #define MAIN_ADDR 0x0 // User code starts here |
| 64 | #define BOOT_START 0x3C0 // Bootloader code starts here |
| 65 | #define EEPROM_ADDR1 ((void*)1) // Location of the node's address in the EEPROM |
| 66 | #define EEPROM_ADDR2 ((void*)42) // Location of the node's address in the EEPROM |
| 67 | #define EEPROM_ADDR3 ((void*)126) // Location of the node's address in the EEPROM |
| 68 | |
| 69 | // Tool ID numbers
|
| 70 | #define ID_BROKEN 0 //signified eeprom is probably broken |
| 71 | |
| 72 | // Debouncing
|
| 73 | #define BUTTON_DEBOUNCE 5 |
| 74 | |
| 75 | /****** Utility Definitions ******/
|
| 76 | #define TRUE 0x01 |
| 77 | #define FALSE 0x00 |
| 78 | #define ON 0x01 |
| 79 | #define OFF 0x00 |
| 80 | #endif
|