Contiki-Inga 3.x
Main Page
Related Pages
Modules
Data Structures
Files
Examples
File List
Globals
platform
sensinode
disco.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2010, Loughborough University - Computer Science
3
* All rights reserved.
4
*
5
* Redistribution and use in source and binary forms, with or without
6
* modification, are permitted provided that the following conditions
7
* are met:
8
* 1. Redistributions of source code must retain the above copyright
9
* notice, this list of conditions and the following disclaimer.
10
* 2. Redistributions in binary form must reproduce the above copyright
11
* notice, this list of conditions and the following disclaimer in the
12
* documentation and/or other materials provided with the distribution.
13
* 3. Neither the name of the Institute nor the names of its contributors
14
* may be used to endorse or promote products derived from this software
15
* without specific prior written permission.
16
*
17
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
18
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
21
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27
* SUCH DAMAGE.
28
*
29
* This file is part of the Contiki operating system.
30
*/
31
32
/**
33
* \file
34
* Header file for the Disco server
35
* (embedded part of the DISCOBALL project)
36
*
37
* \author
38
* George Oikonomou - <oikonomou@users.sourceforge.net>
39
*/
40
41
#ifndef DISCO_H_
42
#define DISCO_H_
43
44
#include "contiki.h"
45
#include "contiki-net.h"
46
/*---------------------------------------------------------------------------*/
47
#define DISCO_UDP_PORT 60002
48
#define DISCO_DESCRIPTORS_LOC
/* In external Flash */
49
50
#define DATA_CHUNK_LEN 64
51
52
/* Intervals - Timeouts */
53
#define DISCO_TIMEOUT_PREPARE (CLOCK_SECOND / 2)
54
#define DISCO_TIMEOUT_ABORT (CLOCK_SECOND * 10)
55
#define DISCO_TIMEOUT_REBOOT CLOCK_SECOND
56
57
/* Disco State Machine */
58
#define DISCO_STATE_LISTENING 0x00
/* Waiting for a transaction to start */
59
#define DISCO_STATE_PREPARING 0x01
/* Erasing Sectors */
60
#define DISCO_STATE_READY 0x02
61
#define DISCO_STATE_REBOOTING 0x03
/* Reboot to BooTTY and copy new image */
62
63
/* Instructions */
64
#define DISCO_CMD_INIT 0x00
/* Prepare flash area for writes */
65
#define DISCO_CMD_SWITCH 0x01
/* Copy image from ext. to int. flash */
66
#define DISCO_CMD_WRITE 0x02
/* Write Image to Ext Flash */
67
#define DISCO_CMD_DONE 0x03
/* All Done */
68
69
/* Error Codes */
70
#define DISCO_ERR_GENERIC 0xFF
/* Generic Error */
71
#define DISCO_ERR_BAD_LEN 0xFE
/* Incorrect Length */
72
#define DISCO_ERR_NOT_READY 0xFD
/* Not Initialised */
73
#define DISCO_ERR_BAD_OFFSET 0xFC
/* Bad Offset */
74
#define DISCO_ERR_PROTECTED 0xFB
/* Target sector is protected */
75
#define DISCO_ERR_INIT_DONE 0xFA
/* Already Initialized */
76
77
/* Message Sizes */
78
#define DISCO_FLEN_CMD 1
79
#define DISCO_FLEN_IMG 1
80
#define DISCO_FLEN_ADDR 3
81
#define DISCO_FLEN_DATA 64
82
83
/* Request Lengths */
84
#define DISCO_LEN_INIT (DISCO_FLEN_CMD + DISCO_FLEN_IMG)
85
#define DISCO_LEN_DONE DISCO_FLEN_CMD
86
#define DISCO_LEN_WRITE (DISCO_FLEN_CMD + DISCO_FLEN_ADDR + DISCO_FLEN_DATA)
87
#define DISCO_LEN_SWITCH (DISCO_FLEN_CMD + DISCO_FLEN_IMG)
88
89
/* Response Lengths */
90
#define DISCO_RESPONSE_NONE 0
91
#define DISCO_RESP_LEN_ERR DISCO_FLEN_CMD
92
#define DISCO_RESP_LEN_INIT DISCO_FLEN_CMD
93
#define DISCO_RESP_LEN_DONE DISCO_FLEN_CMD
94
#define DISCO_RESP_LEN_WRITE (DISCO_FLEN_CMD + DISCO_FLEN_ADDR)
95
#define DISCO_RESP_LEN_SWITCH (DISCO_FLEN_CMD + DISCO_FLEN_IMG)
96
97
/* Tell BooTTy! what to do after we jump:
98
* BOOTY_CMD
99
* [7:5]: Command
100
* [5:4]: Reserved
101
* [4:0]: Image number
102
*/
103
#define BOOTTY_CMD_LOCATION 0xFEFF
104
105
#define BOOTTY_CMD_JUMP_TO_APP 0x80
106
#define BOOTTY_CMD_COPY_IMAGE 0x40
107
108
#define SECTOR_UNPROTECTED 0
109
#define SECTOR_PROTECTED 1
110
/*---------------------------------------------------------------------------*/
111
PROCESS_NAME
(disco_process);
112
/*---------------------------------------------------------------------------*/
113
struct
disco_request_pdu {
114
uint8_t cmd;
115
uint8_t addr[3];
116
uint8_t data[DATA_CHUNK_LEN];
117
};
118
119
struct
disco_response_pdu {
120
uint8_t status;
121
uint8_t addr[3];
122
};
123
124
struct
disco_seed {
125
uip_ipaddr_t addr;
126
uint16_t port;
127
};
128
/*---------------------------------------------------------------------------*/
129
#endif
/* DISCO_H_ */
Generated on Thu Apr 24 2014 16:26:16 for Contiki-Inga 3.x by
1.8.3.1