root/branches/follower/libw5100/src/libw5100/types.h

Revision 140, 4.9 KB (checked in by follower, 11 months ago)

Add author, license and copyright details. (Which weren't permitted in competition entry source.)

Line 
1/*
2
3@file       type.h
4
5   Original Author:
6
7      WIZnet Inc.
8
9   Modifications by:
10
11      Philip Lindsay <follower@rancidbacon.com>
12
13   Modifications license:
14
15      Copyright 2007-2008 // LGPL
16
17*/
18
19#ifndef _TYPE_H_
20#define _TYPE_H_
21
22
23/***************************************************
24 * attribute for mcu ( types, ... )
25 ***************************************************/
26//#include "mcu_define.h"
27#define __ARDUINO__  1
28#define __MCU_AVR__ 1
29#define __MCU_TYPE__    __MCU_AVR__
30
31// TODO: We should really specify the Chip Select pin based on
32// the MCU rather than the platform.
33#ifdef __ARDUINO__
34#define CS_PIN (1 << PB2)
35#endif
36
37//---- Refer "Rom File Maker Manual Vx.x.pdf"
38#include <avr/pgmspace.h>
39
40#define _ENDIAN_LITTLE_ 0   /**<  This must be defined if system is little-endian alignment */
41#define _ENDIAN_BIG_        1
42#define     SYSTEM_ENDIAN       _ENDIAN_LITTLE_
43
44#define MAX_SOCK_NUM        4   /**< Maxmium number of socket  */
45#define CLK_CPU         8000000     /**< 8Mhz(for serial) */
46
47/* ## __DEF_IINCHIP_xxx__ : define option for iinchip driver *****************/
48#ifndef __ARDUINO__
49#define __DEF_IINCHIP_DBG__ /* involve debug code in driver (socket.c) */
50#define __DEF_IINCHIP_INT__ /**< involve interrupt service routine (socket.c) */
51#define __DEF_IINCHIP_PPP__ /* involve pppoe routine (socket.c) */
52                            /* If it is defined, the source files (md5.h,md5.c) must
53                               be included in your project.
54                               Otherwise, the source files must be removed from your
55                               project. */
56#endif
57
58#define __DEF_IINCHIP_DIRECT_MODE__ 1
59#define __DEF_IINCHIP_INDIRECT_MODE__ 2
60#define __DEF_IINCHIP_SPI_MODE__ 3
61//#define __DEF_IINCHIP_BUS__ __DEF_IINCHIP_DIRECT_MODE__
62//#define __DEF_IINCHIP_BUS__ __DEF_IINCHIP_INDIRECT_MODE__
63#define __DEF_IINCHIP_BUS__ __DEF_IINCHIP_SPI_MODE__ /*Enable SPI_mode*/
64
65
66/**
67@brief   __DEF_IINCHIP_MAP_xxx__ : define memory map for iinchip
68*/
69#define __DEF_IINCHIP_MAP_BASE__ 0x8000
70#if (__DEF_IINCHIP_BUS__ == __DEF_IINCHIP_DIRECT_MODE__)
71 #define COMMON_BASE __DEF_IINCHIP_MAP_BASE__
72#else
73 #define COMMON_BASE 0x0000
74#endif
75#define __DEF_IINCHIP_MAP_TXBUF__ (COMMON_BASE + 0x4000) /* Internal Tx buffer address of the iinchip */
76#define __DEF_IINCHIP_MAP_RXBUF__ (COMMON_BASE + 0x6000) /* Internal Rx buffer address of the iinchip */
77
78
79#if (__MCU_TYPE__ == __MCU_AVR__)
80   #ifdef __DEF_IINCHIP_INT__
81      // iinchip use external interrupt 4
82      #define IINCHIP_ISR_DISABLE() (EIMSK &= ~(0x10))
83      #define IINCHIP_ISR_ENABLE()  (EIMSK |= 0x10)
84      #define IINCHIP_ISR_GET(X)        (X = EIMSK)
85      #define IINCHIP_ISR_SET(X)        (EIMSK = X)
86   #else
87      #define IINCHIP_ISR_DISABLE()
88      #define IINCHIP_ISR_ENABLE() 
89      #define IINCHIP_ISR_GET(X)
90      #define IINCHIP_ISR_SET(X)
91   #endif
92#else
93#error "unknown MCU type"
94#endif
95
96
97/* gcc version */
98/* WinAVR-20050214-install.exe */
99#define __WINAVR_20050214__ 0
100#define __WINAVR_20060125__ 1
101#define __WINAVR_20060421__ 2
102
103/* #define __COMPILER_VERSION__ __WINAVR_20060421__ // <- move makefile*/
104
105#if (__COMPILER_VERSION__ == __WINAVR_20050214__)
106#ifndef __STDIO_FDEVOPEN_COMPAT_12
107#define __STDIO_FDEVOPEN_COMPAT_12
108#endif
109#endif
110
111#ifndef NULL
112#define NULL        ((void *) 0)
113#endif
114
115#ifndef __ARDUINO__
116typedef enum { false, true } bool;
117#endif
118
119#ifndef _SIZE_T
120#define _SIZE_T
121typedef unsigned int size_t;
122#endif
123
124/**
125 * The 8-bit signed data type.
126 */
127typedef char int8;
128/**
129 * The volatile 8-bit signed data type.
130 */
131typedef volatile char vint8;
132/**
133 * The 8-bit unsigned data type.
134 */
135typedef unsigned char uint8;
136/**
137 * The volatile 8-bit unsigned data type.
138 */
139typedef volatile unsigned char vuint8;
140
141/**
142 * The 16-bit signed data type.
143 */
144typedef int int16;
145/**
146 * The volatile 16-bit signed data type.
147 */
148typedef volatile int vint16;
149/**
150 * The 16-bit unsigned data type.
151 */
152typedef unsigned int uint16;
153/**
154 * The volatile 16-bit unsigned data type.
155 */
156typedef volatile unsigned int vuint16;
157/**
158 * The 32-bit signed data type.
159 */
160typedef long int32;
161/**
162 * The volatile 32-bit signed data type.
163 */
164typedef volatile long vint32;
165/**
166 * The 32-bit unsigned data type.
167 */
168typedef unsigned long uint32;
169/**
170 * The volatile 32-bit unsigned data type.
171 */
172typedef volatile unsigned long vuint32;
173
174/* bsd */
175typedef uint8           u_char;     /**< 8-bit value */
176typedef uint8           SOCKET;
177typedef uint16          u_short;    /**< 16-bit value */
178typedef uint16          u_int;      /**< 16-bit value */
179typedef uint32          u_long;     /**< 32-bit value */
180
181typedef union _un_l2cval {
182    u_long  lVal;
183    u_char  cVal[4];
184}un_l2cval;
185
186typedef union _un_i2cval {
187    u_int   iVal;
188    u_char  cVal[2];
189}un_i2cval;
190
191
192/** global define */
193#define FW_VERSION      0x01000001  /**< System F/W Version(test) : 0.0.0.1 */
194#define HW_PM_VERSION   "0.1"
195#define HW_NM_VERSION   "0.1"
196#define HW_MB_VERSION   "0.1"
197
198
199#define TX_RX_MAX_BUF_SIZE  2048
200#define TX_BUF  0x1100
201#define RX_BUF  (TX_BUF+TX_RX_MAX_BUF_SIZE)
202
203#define UART_DEVICE_CNT     1   /**< UART device number */
204/* #define SUPPORT_UART_ONE */
205
206#endif      /* _TYPE_H_ */
Note: See TracBrowser for help on using the browser.