[Tinyos-contrib-commits]
CVS: tinyos-1.x/contrib/imote2/tools/src/bootloader/include
AttrAccess.h, NONE, 1.1 BLAttrDefines.h, NONE,
1.1 BLAttributeVal.h, NONE, 1.1 BinImageHandler.h, NONE,
1.1 BootLoader.h, NONE, 1.1 CC2420Const.h, NONE, 1.1 Crc.h,
NONE, 1.1 Flash.h, NONE, 1.1 FlashAccess.h, NONE,
1.1 HPLInit.h, NONE, 1.1 Leds.h, NONE, 1.1 MMU.h, NONE,
1.1 MessageDefines.h, NONE, 1.1 PMIC.h, NONE,
1.1 PMICDefines.h, NONE, 1.1 PXA27XClock.h, NONE,
1.1 PXA27XGPIOInt.h, NONE, 1.1 PXA27XInterrupt.h, NONE,
1.1 PXA27XUDCRegAddrs.h, NONE, 1.1 PXA27XUSBClient.h, NONE,
1.1 PXA27XUSBdata.h, NONE, 1.1 PXA27Xdynqueue.h, NONE,
1.1 TOSSched.h, NONE, 1.1 USBClient.h, NONE, 1.1 arm_defs.h,
NONE, 1.1 hardware.h, NONE, 1.1 pxa27x_registers.h, NONE,
1.1 pxa27xhardware.h, NONE, 1.1 types.h, NONE, 1.1
Lama Nachman
lnachman at users.sourceforge.net
Tue Oct 10 15:33:26 PDT 2006
- Previous message: [Tinyos-contrib-commits]
CVS: tinyos-1.x/contrib/imote2/tools/src/bootloader/blinclude
BootLoaderAttrVal.h, NONE, 1.1 BootLoaderInc.h, NONE, 1.1
- Next message: [Tinyos-contrib-commits]
CVS: tinyos-1.x/contrib/imote2/tools/src/bootloader/src
AttrAccess.c, NONE, 1.1 BinImageHandler.c, NONE,
1.1 BootLoader.c, NONE, 1.1 Crc.c, NONE, 1.1 FlashAccess.c,
NONE, 1.1 HPLInit.c, NONE, 1.1 Leds.c, NONE, 1.1 Makefile,
NONE, 1.1 PMIC.c, NONE, 1.1 PXA27XClock.c, NONE,
1.1 PXA27XGPIOInt.c, NONE, 1.1 PXA27XHardware.c, NONE,
1.1 PXA27XInterrupt.c, NONE, 1.1 PXA27Xdynqueue.c, NONE,
1.1 TOSSched.c, NONE, 1.1 USBClient.c, NONE, 1.1 bare.x, NONE,
1.1 barecrt.s, NONE, 1.1 binarymover.s, NONE, 1.1 flash.s,
NONE, 1.1 main.c, NONE, 1.1 mmu_table.s, NONE, 1.1 util.s, NONE, 1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/tinyos/tinyos-1.x/contrib/imote2/tools/src/bootloader/include
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv22400
Added Files:
AttrAccess.h BLAttrDefines.h BLAttributeVal.h
BinImageHandler.h BootLoader.h CC2420Const.h Crc.h Flash.h
FlashAccess.h HPLInit.h Leds.h MMU.h MessageDefines.h PMIC.h
PMICDefines.h PXA27XClock.h PXA27XGPIOInt.h PXA27XInterrupt.h
PXA27XUDCRegAddrs.h PXA27XUSBClient.h PXA27XUSBdata.h
PXA27Xdynqueue.h TOSSched.h USBClient.h arm_defs.h hardware.h
pxa27x_registers.h pxa27xhardware.h types.h
Log Message:
Pushed out new release , OCT 2006
--- NEW FILE: AttrAccess.h ---
/* tab:4
* "Copyright (c) 2000-2003 The Regents of the University of California.
* All rights reserved.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose, without fee, and without written agreement is
* hereby granted, provided that the above copyright notice, the following
* two paragraphs and the author appear in all copies of this software.
*
* IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
* OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
* CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
* ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
*
* Copyright (c) 2002-2003 Intel Corporation
* All rights reserved.
*
* This file is distributed under the terms in the attached INTEL-LICENSE
* file. If you do not find these files, copies can be found by writing to
* Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
* 94704. Attention: Intel License Inquiry.
*/
/**
* @file AttrAccess.c
* @author Junaith Ahemed Shahabdeen
*
* Attributes are parameters that is used by the system to make it
* flexible and configurable with out recompiling the source, few
* examples will be <I>Number of Retries on a command failure</I> and
* <I>timeout values for a response</I> etc.
*
* This file provides functions for getting and setting atrributes together
* with helper functions for locating the position of an attribute or a
* table that contains a particular attribute. The attributes, length, and
* its table size is defined in <I>BLAttrDefines</I>.
*
* The currently active attribute tables are maintained in two different
* flash blocks other than the default table. Attribute update occurs on
* one the block which hold the current invalid value and is marked as valid,
* and the old valid value is marked invalid. This mechanism is to share the
* load between flash block holding the tables.
*/
#ifndef ATTR_ACCESS_H
#define ATTR_ACCESS_H
#include <BLAttrDefines.h>
#include <types.h>
#include <FlashAccess.h>
#define ATTR_SET_LIMIT 20
/**
* struct AttrSet
*
* Set of attributes that has to be set or read from the
* attribute table.
*/
typedef struct AttrSet
{
uint8_t NumAttributes;
uint16_t AttrId [ATTR_SET_LIMIT];
uint32_t AttrVal [ATTR_SET_LIMIT];
}AttrSet;
/**
* Read_Attribute_Data
*
* Read the attribute from the flash.
* The function copies the whole attribute to the buffer.
*
* @param attr Id of the Attribute which has to be retrived.
* @parma data Buffer to which the entire attribute struct will be copied to.
*
* @return SUCCESS | FAIL
*/
result_t Read_Attribute (uint16_t attr, void* data);
/**
* Read_Attribute_Value
*
* Read the value of a particular attribute from the flash.
* The function copies only the value of the attribute to the parameter
* passed. As a <I>precondition</I> the user has to get the length of the
* attribute and create a buffer which can hold that length before
* passing the buffer as a parameter to this fucntion.
*
* @param attr The Attribute Id.
* @param data Pointer to the buffer to which the value will be copied to.
*
* @return SUCCESS | FAIL
*/
result_t Read_Attribute_Value (uint16_t attr, void* data);
/**
* Write_Attribute_Value
*
* This function will update an attribute with a new value. The
* attribute id and the value of the attribute is passed as
* parameter.
*
* @param AttrID ID of the Attribute that is updated.
* @param Val new Value to be updated.
*
* @return SUCCESS | ERROR
*/
result_t Write_Attribute_Value (uint16_t AttrID, uint32_t Val);
/**
* Write_Attribute_Set
*
* The function provides an efficiently updating a list of
* attributes that belong to the same table in a single pass. The
* AttrSet values must be set before it is passed to the function and
* the number of attributes in the set cannot exceed ATTR_SET_LIMIT (20).
* <B>It is absolutely required that the attributes must belong to
* the same table. </B>
*
* As a <I>precondition</I> the AttrSet has to be populated with
* the required information and the table id of the attributes has
* to be obtained.
*
* @param table Table Id for the set.
* @param aset Attribute set with the list of attr and its values.
*
* @return SUCCESS | ERROR
*/
result_t Write_Attribute_Set (ATTR_Address_Table table, AttrSet* aset);
/**
* Recover_Default_Table
*
* Reset a particular table to its default state. Usually performed
* during disaster recovery.
*
* @param table The table to be reset.
* @return SUCCESS | FAIL
*/
result_t Recover_Default_Table (ATTR_Address_Table table);
/**
* Read_Attribute_Table
*
* The function copies the entire attribute table in to the
* second parameter. The higher level is responsible for
* allocating the data and passing the required length.
*
* @param TblAddr Starting Address of the table has to be read.
* @param length Length of the table.
* @param data RAM location to copy the table to.
*
* @return SUCCESS | FAIL
*/
result_t Read_Attribute_Table (uint32_t TblAddr, uint32_t length, void* data);
/**
* Write_Attribute_Table
*
* Write the entire table back to the flash memory. The entire flash
* block will be erase and the table will be rewritten.
*
* @param TblAddr Starting Address of the table.
* @param length Length of the table.
* @param data Pointer to the table in memory.
*
* @return SUCCESS | ERROR
*/
result_t Write_Attribute_Table (uint32_t TblAddr, uint32_t length, void* data);
/**
* Get_Table_ID
*
* Returns a table ID for a particular attribute type. The BLAttrDefines.h
* file defines the attribute type ranges.
*
* @param attr Attribute Type for which the table name is required.
* @return TABLE ID | 0 on error
*/
ATTR_Address_Table Get_Attribute_TableID (uint16_t attr);
/**
* Get_Attribute_Length
*
* Get the length of the attribute by passing the attribute type.
*
* @param attr Attribute Type for which to find the Length.
* @return Length | 0 on error
*/
uint8_t Get_Attribute_Length (uint16_t attr);
/**
* Get_Attr_Flash_Address
*
* Given the table name and the attribute id the function will
* calculate the current flash address location of the attribute.
*
* @param TblID The table Id in which the attribute belongs.
* @param AttrID The ID of the attribute.
*
* @return Addr Address of the attribute.
*/
uint32_t Get_Attr_Flash_Address (ATTR_Address_Table TblID, uint16_t AttrID);
#endif
--- NEW FILE: BLAttrDefines.h ---
/* tab:4
* "Copyright (c) 2000-2003 The Regents of the University of California.
* All rights reserved.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose, without fee, and without written agreement is
* hereby granted, provided that the above copyright notice, the following
* two paragraphs and the author appear in all copies of this software.
*
* IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
* OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
* CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
* ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
*
* Copyright (c) 2002-2003 Intel Corporation
* All rights reserved.
*
* This file is distributed under the terms in the attached INTEL-LICENSE
* file. If you do not find these files, copies can be found by writing to
* Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
* 94704. Attention: Intel License Inquiry.
*/
/**
* @file BLAttrDefines.h
* @author Junaith Ahemed Shahabdeen
*
* The file defines the attribute details like location
* name, default value etc.
*
* CAUTION: This file is used by the boot loader for
* the attribute location etc. You cannot change this
* parameters in the file unless all of the failure
* cases are considered carefully. Also chaning or
* repositioning the attributes or attribute table will
* make it incompatible with the existing version.
*/
#ifndef BL_ATTR_DEFINES_H
#define BL_ATTR_DEFINES_H
#include <BootLoaderInc.h>
/* 32k for each table */
//#define BL_TABLE_SIZE 0x8000
#define BL_TABLE_SIZE 0x20000
#define BL_ATTR_ADDRESS_TABLE 0x1E00000
#define BL_ATTR_DEF_BOOTLOADER 0x1E20000
#define BL_ATTR_BOOTLOADER 0x1E40000
/* Default and the updatable shared location */
#define BL_ATTR_DEF_SHARED 0x1E80000
#define BL_ATTR_SHARED 0x1EA0000
/**
* Image Locations
*/
#define BL_PRIMARY_IMAGE_LOCATION 0x01C00000
#define BL_SECONDARY_IMAGE_LOCATION 0x01D00000
#define BL_DEF_SELF_TEST_IMG_LOC 0x1F00000
#define BL_ATTR_BOOT_LOC 0x20 /* Ignore the Vector table*/
#define BL_SELF_TEST_SIZE 0x8000 /* FIXME may be we should fix me*/
/*WD Timeout value for Self Test*/
#define BL_SELF_TEST_TIMEOUT 0x40000000
#define CMD_TIMEOUT_VAL 2000 /* 2 Seconds by default*/
#define BIN_TIMEOUT_VAL 10000 /* 10 Seconds by default*/
typedef enum ATTR_VALIDITY_DEF
{
BL_VALID_ATTR = 0x1F,
BL_INVALID_ATTR = 0x01
} ATTR_VALIDITY_DEF;
#define ATTR_ADDRESS_TABLE_START_VALUE 1
#define ATTR_ADDRESS_TABLE_END_VALUE 49
/**
* The enum basically defines the Attribute type of the
* parameters in the BL_ATTR_ADDRESS_TABLE.
*/
typedef enum ATTR_Address_Table
{
BL_ATTR_TYP_ADDRESS_TABLE = 1, /* Address location of all tables */
BL_ATTR_TYP_DEF_BOOTLOADER = 2, /* Default BootLoader Table */
BL_ATTR_TYP_BOOTLOADER = 3, /* BootLoader Updatable region */
BL_ATTR_TYP_DEF_SHARED = 4, /* Shared attributes for communicaiton with app*/
BL_ATTR_TYP_SHARED = 5, /* Shared attributes for communicaiton with app*/
BL_ATTR_TYP_BOOT_LOCATION = 6, /* Current Boot Location*/
} ATTR_Address_Table;
/**
* Number of attributes that are currently defined in the
* BL_ATTR_ADDRESS_TABLE. If you add a new attribute in the
* ATTR_Address_Table, then it is essential to increment this
* number.
*/
#define BL_ATTR_ADDRESS_TABLE_NUM 6
/***********************************************************************************
* BOOT LOADER TABLE *
***********************************************************************************/
#define ATTR_BOOTLOADER_START_VALUE 50
#define ATTR_BOOTLOADER_END_VALUE 350
/**
* This enum defines the attribute types of the parameters in
* the BL_ATTR_TYP_BOOTLOADER (the bootloader table).
*/
typedef enum ATTR_Bootloader_Table
{
BL_ATTR_TYP_SYNC_TIMEOUT = 50, /*Time out in ms for PC App sync mechanism */
BL_ATTR_TYP_BOOTLOADER_STATE = 51, /*Boot Loader State*/
BL_ATTR_TYP_CMD_FAIL_RETRY = 52, /*Number of retries for command failures */
BL_ATTR_TYP_CRC_FAIL_RETRY = 53, /*Number of retries for CRC failures */
BL_ATTR_TYP_DATA_WINDOW = 54, /*Number of retries for CRC failures */
BL_ATTR_TYP_SELF_TEST_TIMEOUT = 55, /*Time out value for self test mode*/
BL_ATTR_TYP_CMD_TIMEOUT = 56, /*Time out value for Commands*/
BL_ATTR_TYP_BIN_TIMEOUT = 57, /*Time out value for Binary data*/
BL_ATTR_TYP_PRIMARY_IMG_LOCATION = 150, /*Primary Image Location*/
BL_ATTR_TYP_PRIMARY_IMG_CRC = 151, /*CRC of Primary Image*/
BL_ATTR_TYP_PRIMARY_IMG_SIZE = 152, /*Size of Primary Image*/
BL_ATTR_TYP_PRIMARY_IMG_VALIDITY = 153, /*Is Primary Image Valid*/
BL_ATTR_TYP_SECONDARY_IMG_LOCATION = 154, /*Secondary Image Location*/
BL_ATTR_TYP_SECONDARY_IMG_CRC = 155, /*CRC of Secondary Image*/
BL_ATTR_TYP_SECONDARY_IMG_SIZE = 156, /*Size of Secondary Image*/
BL_ATTR_TYP_SECONDARY_IMG_VALIDITY = 157, /*Is Secondary Image Valid*/
BL_ATTR_TYP_BOOT_IMG_CRC = 158, /*CRC of Boot Image*/
BL_ATTR_TYP_BOOT_IMG_SIZE = 159, /*Size of Boot Image*/
BL_ATTR_TYP_BOOT_IMG_VALIDITY = 160, /*Is Boot Image Valid*/
BL_ATTR_TYP_DEF_SELF_TEST_IMG_LOC = 161, /*Self Test Image Location*/
BL_ATTR_TYP_DEF_SELF_TEST_IMG_CRC = 162, /*Self Test Image Crc*/
BL_ATTR_TYP_DEF_SELF_TEST_IMG_SIZE = 163, /*Self Test Image Size*/
} ATTR_Bootloader;
/**
* Number of attributes that are currently defined in the
* Boot Loader table.<B> If you add a new attribute in the
* ATTR_Bootloader_Table, then it is essential to increment this
* number.</B>
*/
#define BL_ATTR_BOOTLOADER_TABLE_NUM 22
#endif
--- NEW FILE: BLAttributeVal.h ---
/* tab:4
* "Copyright (c) 2000-2003 The Regents of the University of California.
* All rights reserved.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose, without fee, and without written agreement is
* hereby granted, provided that the above copyright notice, the following
* two paragraphs and the author appear in all copies of this software.
*
* IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
* OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
* CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
* ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
*
* Copyright (c) 2002-2003 Intel Corporation
* All rights reserved.
*
* This file is distributed under the terms in the attached INTEL-LICENSE
* file. If you do not find these files, copies can be found by writing to
* Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
* 94704. Attention: Intel License Inquiry.
*/
/**
* @file BLAttributeVal.h
* @author Junaith Ahemed Shahabdeen
*
* This file defines the attribute value table and the length
* of each attribute in an array.
*
* This file is mainly used for generating attribute binary and
* also provides an easy way to add new attributes.
*
*/
#ifndef BL_ATTRIBUTE_VAL_H
#define BL_ATTRIBUTE_VAL_H
#include <BLAttrDefines.h>
#include <BootLoaderAttrVal.h>
/**
* This size of the array is limited to BL_ATTR_ADDRESS_TABLE_NUM, if
* you are adding a new value then confirm that you can incremented
* the BL_ATTR_ADDRESS_TABLE_NUM.
*/
unsigned short Gen_ATTR_Addr_Table [BL_ATTR_ADDRESS_TABLE_NUM] [2] =
{
{BL_ATTR_TYP_ADDRESS_TABLE, 4},
{BL_ATTR_TYP_DEF_BOOTLOADER, 4},
{BL_ATTR_TYP_BOOTLOADER, 4},
{BL_ATTR_TYP_DEF_SHARED, 4},
{BL_ATTR_TYP_SHARED, 4},
{BL_ATTR_TYP_BOOT_LOCATION, 4},
};
/*Current size of the address table (only the valid part)*/
#define ADDRESS_TABLE_SIZE ((BL_ATTR_ADDRESS_TABLE_NUM*sizeof (Attribute)) + 24)
/**
* This size of the array is limited to BL_ATTR_BOOTLOADER_TABLE_NUM, <B>if
* you are adding a new value then confirm that you can incremented
* the BL_ATTR_ADDRESS_TABLE_NUM.</B>
*/
unsigned short Gen_ATTR_Bootloader_Table [BL_ATTR_BOOTLOADER_TABLE_NUM][2] =
{
{BL_ATTR_TYP_SYNC_TIMEOUT, 4},
{BL_ATTR_TYP_BOOTLOADER_STATE, 4},
{BL_ATTR_TYP_CMD_FAIL_RETRY, 4},
{BL_ATTR_TYP_CRC_FAIL_RETRY, 4},
{BL_ATTR_TYP_DATA_WINDOW, 4},
{BL_ATTR_TYP_SELF_TEST_TIMEOUT, 4},
{BL_ATTR_TYP_CMD_TIMEOUT, 4},
{BL_ATTR_TYP_BIN_TIMEOUT, 4},
{BL_ATTR_TYP_PRIMARY_IMG_LOCATION, 4},
{BL_ATTR_TYP_PRIMARY_IMG_CRC, 4},
{BL_ATTR_TYP_PRIMARY_IMG_SIZE, 4},
{BL_ATTR_TYP_PRIMARY_IMG_VALIDITY, 4},
{BL_ATTR_TYP_SECONDARY_IMG_LOCATION, 4},
{BL_ATTR_TYP_SECONDARY_IMG_CRC, 4},
{BL_ATTR_TYP_SECONDARY_IMG_SIZE, 4},
{BL_ATTR_TYP_SECONDARY_IMG_VALIDITY, 4},
{BL_ATTR_TYP_BOOT_IMG_CRC, 4},
{BL_ATTR_TYP_BOOT_IMG_SIZE, 4},
{BL_ATTR_TYP_BOOT_IMG_VALIDITY, 4},
{BL_ATTR_TYP_DEF_SELF_TEST_IMG_LOC, 4},
{BL_ATTR_TYP_DEF_SELF_TEST_IMG_CRC, 4},
{BL_ATTR_TYP_DEF_SELF_TEST_IMG_SIZE, 4},
};
/*Current size of the bootloader table (only the valid part)*/
/*FIXME Automate the length calculation*/
#define BOOTLOADER_TABLE_SIZE ((BL_ATTR_BOOTLOADER_TABLE_NUM*sizeof (Attribute)) + 88)
/***************************************************************************
*
* THESE VALUES ARE USED FOR ATTRIBUTE GENERATION PURPOSES ONLY
*
* DONT NOT USE THIS IN THE SOURCE FILE, IT WILL DEFEAT THE PURPOSE
*
***************************************************************************/
unsigned int Gen_ATTR_Addr_Table_Data [BL_ATTR_ADDRESS_TABLE_NUM] =
{BL_ATTR_ADDRESS_TABLE,
BL_ATTR_DEF_BOOTLOADER,
BL_ATTR_BOOTLOADER,
BL_ATTR_DEF_SHARED,
BL_ATTR_SHARED,
BL_ATTR_BOOT_LOC
};
unsigned int Gen_ATTR_Bootloader_Table_Data [BL_ATTR_BOOTLOADER_TABLE_NUM] =
{ 500, /*Timeout in MS */
1, /*Boot_State = NORMAL*/
3, /*Retry thrice on command failure*/
3, /*Retry thrice on CRC failure*/
546, /*Data Window Size in (546*61) */
BL_ATTR_TYP_SELF_TEST_TIMEOUT, /*WD Timeout value for Self Test*/
CMD_TIMEOUT_VAL,
BIN_TIMEOUT_VAL,
BL_PRIMARY_IMAGE_LOCATION, /* Primary Image Location*/
0, /*CRC is 0*/
0, /*Size is 0*/
0, /*Image not valid*/
BL_SECONDARY_IMAGE_LOCATION, /* Secondary Image Location*/
0, /*CRC is 0*/
0, /*Size is 0*/
0, /*Image not valid*/
0, /*Boot Img CRC is 0*/
0, /*Boot Img Size is 0*/
0, /*Boot Image not valid*/
BL_DEF_SELF_TEST_IMG_LOC, /*Self Test Image Locaiton*/
0, /*Self Test Image CRC*/
0, /*Self Test Image Size*/
};
unsigned int ATTR_Shared_Table_Data [ATTR_SHARED_TABLE_NUM] =
{ 0, /*Default Value is False*/
0, /*Default Value is False*/
BL_SECONDARY_IMAGE_LOCATION,
0, /*CRC is zero*/
0, /*Size is zero*/
SELF_TEST_IMG_LOC, /*Self test image location*/
0, /*Self Test image CRC*/
0, /*Self Test image Size*/
};
#endif
--- NEW FILE: BinImageHandler.h ---
/* tab:4
* "Copyright (c) 2000-2003 The Regents of the University of California.
* All rights reserved.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose, without fee, and without written agreement is
* hereby granted, provided that the above copyright notice, the following
* two paragraphs and the author appear in all copies of this software.
*
* IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
* OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
* CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
* ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
*
* Copyright (c) 2002-2003 Intel Corporation
* All rights reserved.
*
* This file is distributed under the terms in the attached INTEL-LICENSE
* file. If you do not find these files, copies can be found by writing to
* Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
* 94704. Attention: Intel License Inquiry.
*/
/**
* @file BinImageHandler.h
* @author Junaith Ahemed Shahabdeen
*
* This file serves as a layer above the <I>USB driver</I> which
* receives a the USB Packet and parses the data part to
* identify a command or binary data. The <B>boot loader state
* machine</B> is directly controlled by this file based on the
* current download context or error conditions.
*
*/
#ifndef BIN_IMAGE_HANDLER_H
#define BIN_IMAGE_HANDLER_H
#include <FlashAccess.h>
#include <USBClient.h>
#include <MessageDefines.h>
/**
* Binary_Image_Packet_Received
*
* The function is a signal from the USB Driver when a binary
* data packet is received. The function stores the binary data in
* the RAM Buffer till the BIN_DATA_WINDOW_SIZE is reached. If the
* sequence number matches with the windown size then the function
* changes the <B>boot loader internal state</B> to <B>VERIFY_CURRENT_BUFFER</B>.
* The state change indicates that the current buffer is completely
* downloaded and the next command from the PC app (CRC Check) can
* be executed on the RAM Buffer.
*
* @param data Data Payload of the USB Packet.
* @parma length Length of the Payload.
* @param seq Sequence number of the packet.
*/
void Binary_Image_Packet_Received (uint8_t* data, uint8_t length, uint32_t seq);
/**
* Request_Next_Binary_Chunk
*
* The function requests the next binary chunk of size
* <I>BIN_DATA_WINDOW_SIZE</I> from the PC app. This function is
* invoked from the boot loader state machine when the current state
* is <I>REQUEST_USB_PACKETS</I>.
* It also sets the time out value for the buffer download.
*
* @return SUCCESS | FAIL
*/
result_t Request_Next_Binary_Chunk ();
/**
* Command_Packet_Received
*
* Signal from the USB Driver when a command packet is received.
* The payload is parsed to identify the command type and based
* on the command type the rest of the data is handled.
* The commands and the data structure for each command is
* defined in <B>MessageDefines.h</B>.
*
* @param data Data Payload of the USB Packet.
* @param length Length of the payload.
*
* @return SUCCESS | FAIL
*/
result_t Command_Packet_Received (uint8_t* data, uint8_t length);
/**
* Command_Timeout
*
* The function is a signal from the timer module to indicate
* that timeout value has reached for a particular operation.
* The action required for the signal is determined by the
* message type and the number of retires.
*
* NOTE:
* If the number of retries expired then it usually indicates
* a fatal comminucation error in the current code, the board
* will send a fata error message and will reboot.
*
* @param MsgId Message Type (command, or binary etc)
* @parma Typ Type of command or any other message.
* @param retries Number of retries left. (usually reducing).
*
*/
void Command_Timeout (uint8_t MsgId, uint8_t Typ, uint8_t retries);
/**
* Request_Next_Binary_Packet
*
* While in the MMU Disabled mode it is impossible to receive chunks
* of data from the PC app, because the processing is not fast enough to
* keep up with the data rate. It is easier to switch to request
* each packet.
*
* @return SUCCESS | FAIL
*
*/
result_t Request_Next_Binary_Packet ();
/**
* Check_Buffer_Crc
*
* Check the CRC of the current RAM buffer and return the
* result.
*
* @param start Current Start packet.
* @param numpck number of packets downloaded in to the current buffer.
* @param crc CRC of the current buffer.
*
* @return SUCCESS| FAIL
*/
result_t Check_Buffer_Crc (uint32_t start, uint32_t numpck, uint16_t crc);
/**
* Prepare_Self_Test
*
* If the application requests a self test for the newly
* downloaded image, then the new image will be copied to
* the boot location temporarily. The watch dog timer is
* set to ensure that the app will reboot for the second
* verification phase.
* After the reboot the boot loader verifies the test result
* and decides if the image has to be made golden or not.
*
* @return SUCCESS | ERROR
*/
result_t Prepare_Self_Test ();
/**
* Handle_Cmd_Verify_Buffer_Crc
*
* The function caluculates the crc of a given buffer
* and compares it with the crc passed. If the data in
* the buffer is determined valid through the crc check the
* buffer data is transfered to the current load location.
*
* @parma chkcrc Data structure contaning number of packets
* and the crc of the current buffer.
*
* @return SUCCESS | FAIL
*/
result_t Handle_Cmd_Verify_Buffer_Crc (CmdCrcData* chkcrc);
/**
* Handle_Cmd_Verify_Image_Crc
*
* After the download is completed the bootloader verifies
* the CRC of the image by reading the Image from the
* flash. The current load location has to be specified
* to the boot loader through CURRENT_LOAD_LOCATION attribute.
* This function starts reading chunks of size DATA_WINDOW_SIZE
* from the address passed as the first parameter from the flash and
* calculates a cumulative crc of the chunks up to the
* specified size (numpck number of ).
*
* @param StartAddr Starting address of the image.
* @param Size The total size of the image.
* @param rcvCRC The crc received or to be verified.
*
* @return SUCCESS | FAIL
*/
result_t Handle_Cmd_Verify_Image_Crc (uint32_t StartAddr, uint32_t Size,
uint16_t rcvCrc);
/**
* Handle_Cmd_Get_Buffer_Data
*
* This command enables the PC application to request the data from
* the current internal buffer (rcvBuffer). This command is usally preceded by a
* DUMP_FLASH_DATA command.
*
* @param sequence Sequence number of the packet requested.
*/
void Handle_Cmd_Get_Buffer_Data (uint16_t sequence);
/**
* Handle_Cmd_Flash_Dump
*
* The verification mechanism of flash programming requires a flash dump of the
* currently programmed location. The PC application can request a flash
* dump of either the primary or the secondary flash image.
* The function expects the CurrentAddress to be set to the address where
* the chunk has to be read. The chunk size is same as the download
* (BIN_DATA_WINDOW_SIZE).
*
*/
void Handle_Cmd_Flash_Dump ();
/**
* Send_Command_Packet
*
* The abstraction function which takes a command and converts it in to
* byte array and calls the lower level send function in USBClient.
*
* @param cmd Command to be send.
* @param length Size of the struct pointed by cmd.
*
* @return SUCCESS | FAIL
*/
result_t Send_Command_Packet (USBCommand* cmd, int len);
/**
* Send_USB_Command_Packet
*
* Send an command message to the PC.
*
* @param err Error codes defined in the enum (see MessageDefines.h).
* @param clen Length of the command data.
* @param cdata Command data in array format.
*/
result_t Send_USB_Command_Packet (Commands cmd, uint8_t clen, void* cdata);
/**
* Send_USB_Error_Packet
*
* Send an error message and a description about the error to the
* PC application.
*
* @param err Error codes defined in the enum (see MessageDefines.h).
* @param dlen Length of the descriptor string.
* @param desc A description about the error.
*/
result_t Send_USB_Error_Packet (Errors err, uint8_t dlen, void* desc);
/**
* Send_USB_Binary_Packet
*
* Send Binary data to the pc application. This function is used mainly
* to dump data from flash or the internal buffer to the pc applicaiton for
* image verification purposes.
*
* The function currently follows the JTPacket format which means that
* every packet can transmit a length of IMOTE_HID_SHORT_MAXPACKETDATA and
* packet will contain the sequence number.
*
* @param data Data to be transmitted.
* @return SUCCESS | FAIL
*/
result_t Send_USB_Binary_Packet (uint8_t* data, uint32_t length);
#endif
--- NEW FILE: BootLoader.h ---
/* tab:4
* "Copyright (c) 2000-2003 The Regents of the University of California.
* All rights reserved.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose, without fee, and without written agreement is
* hereby granted, provided that the above copyright notice, the following
* two paragraphs and the author appear in all copies of this software.
*
* IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
* OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
* CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
* ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
*
* Copyright (c) 2002-2003 Intel Corporation
* All rights reserved.
*
* This file is distributed under the terms in the attached INTEL-LICENSE
* file. If you do not find these files, copies can be found by writing to
* Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
* 94704. Attention: Intel License Inquiry.
*/
/**
* @file BootLoader.h
* @author Junaith Ahemed Shahabdeen
*
* Boot loader state machine, recovery mechanism and
* the application test mechanisms like SELF_TEST and
* Image verify are implemented in this file.
*/
#ifndef BOOT_LOADER_H
#define BOOT_LOADER_H
#include <HPLInit.h>
/**
* Boot Loader State.
*/
typedef enum BootLoaderState
{
NORMAL = 1, /*default mode for the bootloader*/
CODE_LOAD = 2, /*Internal mode for the bootloader during code load*/
VERIFY_IMAGE = 3, /*App reqests to verify secondary image*/
VERIFY_SELF_TEST = 4, /*SELF_TEST requested from the application*/
BOOT_IMAGE = 5, /*Internal mode for bootloader for booting the image*/
CPY_TO_BOOT = 6, /*Copy Secondary to boot location*/
SET_LOADED_TO_GOLDEN = 7, /*Swap Secondary to primary attributes*/
SET_BOOT_TO_GOLDEN = 8, /*Copy CRC and Size of Primary to Boot Attribute*/
COMMAND_LINE = 9, /*Internal mode, copy secondary to boot location*/
}BootLoaderState;
/**
* CodeLoadState
*
* Internal states of the bootloader while it is
* loading code through the USB. These states will
* not be written to the attribute in FLASH.
*/
typedef enum CodeLoadState
{
REQUEST_IMAGE_DETAIL = 1,
REQUEST_USB_PACKETS = 2,
VERIFY_CURRENT_BUFFER = 3,
VERIFY_CURRENT_IMAGE = 4
} CodeLoadState;
/**
* Set_Image_Details
*
* The details of the current downloaded image stored
* in the secondary location is passed to the boot loader
* state machine for moving the image to boot location
* and marking the image as golden. Though the values
* are stored in the flash as attributes, it is easier and
* quicker to deal with ram variables.
* This function is basically a utility to pass the image
* details from BinImageHandler module to the BootLoaderState
* module.
*
* @param isize Size of the image.
* @parma iaddr Starting address of the image location.
* @parma icrc Crc of the image.
*
*/
void Set_Image_Details (uint32_t isize, uint32_t iaddr, uint32_t icrc);
//result_t Enable_Mem_Test ();
//result_t Post_BootLoader_State ();
/**
* Reboot_Device
*
* Set the watch dog and the OSMR3 registers and wait till
* the board reboots.
*/
inline void Reboot_Device ();
//void USB_Send_Done ();
/**
* Change_BootLoader_State_Attribute
*
* Change the current boot loader state to the value of first parameter and
* also synch it with the BootLoader State Attribute in flash.
* The value of the parameter passed must be one of the values in
* the BootLoaderState enumerated list.
*
* @param state The new state of the boot loader.
* @return SUCCESS | FAIL
*/
uint8_t Change_BootLoader_State_Attribute (BootLoaderState state);
/**
* Change_BootLoader_State
*
* Change the current boot loader state to the value of first parameter.
* The value of the parameter passed must be one of the values in
* the BootLoaderState enumerated list.
*
* @param state The new state of the boot loader.
* @return SUCCESS | FAIL
*/
uint8_t Change_BootLoader_State (BootLoaderState state);
/**
* Get_BootLoader_State
*
* Get the current boot loader state, The function returns the current
* state of the boot loader.
*
* @return CurrentState of the boot loader.
*/
BootLoaderState Get_BootLoader_State ();
/**
* Change_Internal_CodeLoad_State
*
* The code load state is internally maintained by the bootloader after the
* PC application places it in CodeLoad state. Currently there are
* two states in which the boot loader requests the image details to be
* loaded and requests the usb packets.
*
* @param cls The new internal state of Code_Load.
* @return SUCCESS | FAIL
*/
uint8_t Change_Internal_CodeLoad_State (CodeLoadState cls);
/**
* Get_Internal_CodeLoad_State
*
* The funciton returns the CLoaderState variable, which is the
* current internal state of Code_Loader.
*
* @return CLoaderState Current state of Code_Loader.
*/
CodeLoadState Get_Internal_CodeLoad_State ();
/**
* Prepare_Self_Test
*
* If the application requests a self test for the newly
* downloaded image, then the new image will be copied to
* the boot location temporarily. The watch dog timer is
* set to ensure that the app will reboot for the second
* verification phase.
* After the reboot the boot loader verifies the test result
* and decides if the image has to be made golden or not.
*
* @return SUCCESS | ERROR
*/
result_t Prepare_Self_Test ();
/**
* Self_Test_Failed
*
* If the self test fails then the boot loader has to recover the
* previous golden image and replace the current boot image (self test image).
*
* @return SUCCESS | FAIL
*/
result_t Self_Test_Failed ();
/**
* Self_Test_Succeeded
*
* Self test succeeded so make the current image as golden image
* and set the right attributes.
*
* @return SUCCESS | ERROR
*/
result_t Self_Test_Succeeded ();
/**
* Validate_Self_Test_Image
*
* Validate the CRC of the self test image and determine if the
* self test passed or failed.
*
* @return SUCCESS | FAIL
*/
result_t Validate_Self_Test_Image ();
/**
* Verify_Image_And_Make_Golden
*
* The application can download an image and store it in the
* secondary location and requests the boot loader to validate (CRC)
* the make and convert it to bootable image.
* If the CRC Check passed then the image is made bootable and
* copied to the primary location.
*
* @return SUCCESS | FAIL
*/
result_t Verify_Image_And_Make_Golden ();
/**
* Move_Image_To_Boot_Loc
*
* Move the image at imgAddr to the boot location. This
* function holds a copy of the vector table. If incase there is
* a failure then it will try to replace the vector table to
* save the boot loader.
*
* @param imgAddr Starting address of the image to be moved.
* @param imgSiz Size of the image at imgAddr.
*
* @return SUCCESS | FAIL
*/
result_t Move_Image_To_Boot_Loc (uint32_t imgAddr, uint32_t imgSiz);
/**
* BootLoader_Recovery_State_Machine
*
* State machine that is invoked while we are recovering from
* a crash. The actions that has to be taken after a crash differs
* from the normal one, just to prevent an infinite loop.
* Also there are only few states in which the boot loader
* crash could crash.
* NOTE:
* if the function doesnt recognize the crash state or if there is a
* possibility of an infinite loop then stall.
*/
void BootLoader_Recovery_State_Machine ();
/**
* BootLoader_State_Machine
*
* The state machine for the boot loader which performs certain tasks
* based on the current state of the boot loader. The current state must
* be changed appropriately before calling this fuction.
*
*/
void BootLoader_State_Machine ();
#endif
--- NEW FILE: CC2420Const.h ---
// $Id: CC2420Const.h,v 1.1 2006/10/10 22:33:23 lnachman Exp $
/* -*- Mode: C; c-basic-indent: 2; indent-tabs-mode: nil -*- */
/* tab:4
* IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. By
* downloading, copying, installing or using the software you agree to
* this license. If you do not agree to this license, do not download,
* install, copy or use the software.
*
* Intel Open Source License
*
* Copyright (c) 2002 Intel 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:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 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.
* Neither the name of the Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``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 DISCLAIMED. IN NO EVENT SHALL THE INTEL OR ITS
* CONTRIBUTORS 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.
*
*
*/
/*
*
* Authors: Joe Polastre, Alan Broad
*
*/
/**
* @author Joe Polastre
* @author Alan Broad
*/
#ifndef _CC2420CONST_H
#define _CC2420CONST_H
// times for the CC2420 in microseconds
enum {
CC2420_TIME_BIT = 4,
CC2420_TIME_BYTE = CC2420_TIME_BIT << 3,
CC2420_TIME_SYMBOL = 16
};
#ifndef CC2420_DEF_RFPOWER
#define CC2420_DEF_RFPOWER 0x1F
#endif
#ifndef CC2420_DEF_CHANNEL
#define CC2420_DEF_CHANNEL 11 //channel select
#endif
enum {
CC2420_MIN_CHANNEL = 11,
CC2420_MAX_CHANNEL = 26
};
#define CC2420_DEF_PRESET 2405 //freq select
#define CC2420_DEF_FCF_LO 0x08
#define CC2420_DEF_FCF_HI 0x01 // without ACK
#define CC2420_DEF_FCF_HI_ACK 0x21 // with ACK
#define CC2420_DEF_FCF_TYPE_BEACON 0x00
#define CC2420_DEF_FCF_TYPE_DATA 0x01
#define CC2420_DEF_FCF_TYPE_ACK 0x02
#define CC2420_DEF_FCF_BIT_ACK 5
#define CC2420_DEF_BACKOFF 500
#define CC2420_SYMBOL_TIME 16 // 2^4
// 20 symbols make up a backoff period
// 10 jiffy's make up a backoff period
// due to timer overhead, 30.5us is close enough to 32us per 2 symbols
#define CC2420_SYMBOL_UNIT 10
// delay when waiting for the ack
#ifndef CC2420_ACK_DELAY
#define CC2420_ACK_DELAY 75
#endif
#ifndef CC2420_XOSC_TIMEOUT
#define CC2420_XOSC_TIMEOUT 200 //times to chk if CC2420 crystal is on
#endif
#define CC2420_SNOP 0x00
#define CC2420_SXOSCON 0x01
#define CC2420_STXCAL 0x02
#define CC2420_SRXON 0x03
#define CC2420_STXON 0x04
#define CC2420_STXONCCA 0x05
#define CC2420_SRFOFF 0x06
#define CC2420_SXOSCOFF 0x07
#define CC2420_SFLUSHRX 0x08
#define CC2420_SFLUSHTX 0x09
#define CC2420_SACK 0x0A
#define CC2420_SACKPEND 0x0B
#define CC2420_SRXDEC 0x0C
#define CC2420_STXENC 0x0D
#define CC2420_SAES 0x0E
#define CC2420_MAIN 0x10
#define CC2420_MDMCTRL0 0x11
#define CC2420_MDMCTRL1 0x12
#define CC2420_RSSI 0x13
#define CC2420_SYNCWORD 0x14
#define CC2420_TXCTRL 0x15
#define CC2420_RXCTRL0 0x16
#define CC2420_RXCTRL1 0x17
#define CC2420_FSCTRL 0x18
#define CC2420_SECCTRL0 0x19
#define CC2420_SECCTRL1 0x1A
#define CC2420_BATTMON 0x1B
#define CC2420_IOCFG0 0x1C
#define CC2420_IOCFG1 0x1D
#define CC2420_MANFIDL 0x1E
#define CC2420_MANFIDH 0x1F
#define CC2420_FSMTC 0x20
#define CC2420_MANAND 0x21
#define CC2420_MANOR 0x22
#define CC2420_AGCCTRL 0x23
#define CC2420_AGCTST0 0x24
#define CC2420_AGCTST1 0x25
#define CC2420_AGCTST2 0x26
#define CC2420_FSTST0 0x27
#define CC2420_FSTST1 0x28
#define CC2420_FSTST2 0x29
#define CC2420_FSTST3 0x2A
#define CC2420_RXBPFTST 0x2B
#define CC2420_FSMSTATE 0x2C
#define CC2420_ADCTST 0x2D
#define CC2420_DACTST 0x2E
#define CC2420_TOPTST 0x2F
#define CC2420_RESERVED 0x30
#define CC2420_TXFIFO 0x3E
#define CC2420_RXFIFO 0x3F
#define CC2420_RAM_SHORTADR 0x16A
#define CC2420_RAM_PANID 0x168
#define CC2420_RAM_IEEEADR 0x160
#define CC2420_RAM_CBCSTATE 0x150
#define CC2420_RAM_TXNONCE 0x140
#define CC2420_RAM_KEY1 0x130
#define CC2420_RAM_SABUF 0x120
#define CC2420_RAM_RXNONCE 0x110
#define CC2420_RAM_KEY0 0x100
#define CC2420_RAM_RXFIFO 0x080
#define CC2420_RAM_TXFIFO 0x000
// MDMCTRL0 Register Bit Positions
#define CC2420_MDMCTRL0_FRAME 13 // 0 : reject reserved frame types, 1 = accept
#define CC2420_MDMCTRL0_PANCRD 12 // 0 : not a PAN coordinator
#define CC2420_MDMCTRL0_ADRDECODE 11 // 1 : enable address decode
#define CC2420_MDMCTRL0_CCAHIST 8 // 3 bits (8,9,10) : CCA hysteris in db
#define CC2420_MDMCTRL0_CCAMODE 6 // 2 bits (6,7) : CCA trigger modes
#define CC2420_MDMCTRL0_AUTOCRC 5 // 1 : generate/chk CRC
#define CC2420_MDMCTRL0_AUTOACK 4 // 1 : Ack valid packets
#define CC2420_MDMCTRL0_PREAMBL 0 // 4 bits (0..3): Preamble length
// MDMCTRL1 Register Bit Positions
#define CC2420_MDMCTRL1_CORRTHRESH 6 // 5 bits (6..10) : correlator threshold
#define CC2420_MDMCTRL1_DEMOD_MODE 5 // 0: lock freq after preamble match, 1: continous udpate
#define CC2420_MDMCTRL1_MODU_MODE 4 // 0: IEEE 802.15.4
#define CC2420_MDMCTRL1_TX_MODE 2 // 2 bits (2,3) : 0: use buffered TXFIFO
#define CC2420_MDMCTRL1_RX_MODE 0 // 2 bits (0,1) : 0: use buffered RXFIFO
// RSSI Register Bit Positions
#define CC2420_RSSI_CCA_THRESH 8 // 8 bits (8..15) : 2's compl CCA threshold
// TXCTRL Register Bit Positions
#define CC2420_TXCTRL_BUFCUR 14 // 2 bits (14,15) : Tx mixer buffer bias current
#define CC2420_TXCTRL_TURNARND 13 // wait time after STXON before xmit
#define CC2420_TXCTRL_VAR 11 // 2 bits (11,12) : Varactor array settings
#define CC2420_TXCTRL_XMITCUR 9 // 2 bits (9,10) : Xmit mixer currents
#define CC2420_TXCTRL_PACUR 6 // 3 bits (6..8) : PA current
#define CC2420_TXCTRL_PADIFF 5 // 1: Diff PA, 0: Single ended PA
#define CC2420_TXCTRL_PAPWR 0 // 5 bits (0..4): Output PA level
// Mask for the CC2420_TXCTRL_PAPWR register for RF power
#define CC2420_TXCTRL_PAPWR_MASK (0x1F << CC2420_TXCTRL_PAPWR)
// RXCTRL0 Register Bit Positions
#define CC2420_RXCTRL0_BUFCUR 12 // 2 bits (12,13) : Rx mixer buffer bias current
#define CC2420_RXCTRL0_HILNAG 10 // 2 bits (10,11) : High gain, LNA current
#define CC2420_RXCTRL0_MLNAG 8 // 2 bits (8,9) : Med gain, LNA current
#define CC2420_RXCTRL0_LOLNAG 6 // 2 bits (6,7) : Lo gain, LNA current
#define CC2420_RXCTRL0_HICUR 4 // 2 bits (4,5) : Main high LNA current
#define CC2420_RXCTRL0_MCUR 2 // 2 bits (2,3) : Main med LNA current
#define CC2420_RXCTRL0_LOCUR 0 // 2 bits (0,1) : Main low LNA current
// RXCTRL1 Register Bit Positions
#define CC2420_RXCTRL1_LOCUR 13 // Ref bias current to Rx bandpass filter
#define CC2420_RXCTRL1_MIDCUR 12 // Ref bias current to Rx bandpass filter
#define CC2420_RXCTRL1_LOLOGAIN 11 // LAN low gain mode
#define CC2420_RXCTRL1_MEDLOGAIN 10 // LAN low gain mode
#define CC2420_RXCTRL1_HIHGM 9 // Rx mixers, hi gain mode
#define CC2420_RXCTRL1_MEDHGM 8 // Rx mixers, hi gain mode
#define CC2420_RXCTRL1_LNACAP 6 // 2 bits (6,7) Selects LAN varactor array setting
#define CC2420_RXCTRL1_RMIXT 4 // 2 bits (4,5) Receiver mixer output current
#define CC2420_RXCTRL1_RMIXV 2 // 2 bits (2,3) VCM level, mixer feedback
#define CC2420_RXCTRL1_RMIXCUR 0 // 2 bits (0,1) Receiver mixer current
// FSCTRL Register Bit Positions
#define CC2420_FSCTRL_LOCK 14 // 2 bits (14,15) # of clocks for synch
#define CC2420_FSCTRL_CALDONE 13 // Read only, =1 if cal done since freq synth turned on
#define CC2420_FSCTRL_CALRUNING 12 // Read only, =1 if cal in progress
#define CC2420_FSCTRL_LOCKLEN 11 // Synch window pulse width
#define CC2420_FSCTRL_LOCKSTAT 10 // Read only, = 1 if freq synthesizer is loced
#define CC2420_FSCTRL_FREQ 0 // 10 bits, set operating frequency
// SECCTRL0 Register Bit Positions
#define CC2420_SECCTRL0_PROTECT 9 // Protect enable Rx fifo
#define CC2420_SECCTRL0_CBCHEAD 8 // Define 1st byte of CBC-MAC
#define CC2420_SECCTRL0_SAKEYSEL 7 // Stand alone key select
#define CC2420_SECCTRL0_TXKEYSEL 6 // Tx key select
#define CC2420_SECCTRL0_RXKEYSEL 5 // Rx key select
#define CC2420_SECCTRL0_SECM 2 // 2 bits (2..4) # of bytes in CBC-MAX auth field
#define CC2420_SECCTRL0_SECMODE 0 // Security mode
// SECCTRL1 Register Bit Positions
#define CC2420_SECCTRL1_TXL 8 // 7 bits (8..14) Tx in-line security
#define CC2420_SECCTRL1_RXL 0 // 7 bits (0..7) Rx in-line security
// BATTMON Register Bit Positions
#define CC2420_BATTMON_OK 6 // Read only, batter voltage OK
#define CC2420_BATTMON_EN 5 // Enable battery monitor
#define CC2420_BATTMON_VOLT 0 // 5 bits (0..4) Battery toggle voltage
// IOCFG0 Register Bit Positions
#define CC2420_IOCFG0_FIFOPOL 10 // Fifo signal polarity
#define CC2420_IOCFG0_FIFOPPOL 9 // FifoP signal polarity
#define CC2420_IOCFG0_SFD 8 // SFD signal polarity
#define CC2420_IOCFG0_CCAPOL 7 // CCA signal polarity
#define CC2420_IOCFG0_FIFOTHR 0 // 7 bits, (0..6) # of Rx bytes in fifo to trg fifop
// IOCFG1 Register Bit Positions
#define CC2420_IOCFG1_HSSD 10 // 2 bits (10,11) HSSD module config
#define CC2420_IOCFG1_SFDMUX 5 // 5 bits (5..9) SFD multiplexer pin settings
#define CC2420_IOCFG1_CCAMUX 0 // 5 bits (0..4) CCA multiplexe pin settings
// Current Parameter Arrray Positions
enum{
CP_MAIN = 0,
CP_MDMCTRL0,
CP_MDMCTRL1,
CP_RSSI,
CP_SYNCWORD,
CP_TXCTRL,
CP_RXCTRL0,
CP_RXCTRL1,
CP_FSCTRL,
CP_SECCTRL0,
CP_SECCTRL1,
CP_BATTMON,
CP_IOCFG0,
CP_IOCFG1
} ;
// STATUS Bit Posititions
#define CC2420_XOSC16M_STABLE 6
#define CC2420_TX_UNDERFLOW 5
#define CC2420_ENC_BUSY 4
#define CC2420_TX_ACTIVE 3
#define CC2420_LOCK 2
#define CC2420_RSSI_VALID 1
#endif /* _CC2420CONST_H */
--- NEW FILE: Crc.h ---
/* tab:4
* "Copyright (c) 2000-2003 The Regents of the University of California.
* All rights reserved.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose, without fee, and without written agreement is
* hereby granted, provided that the above copyright notice, the following
* two paragraphs and the author appear in all copies of this software.
*
* IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
* OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
* CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
* ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
*
* Copyright (c) 2002-2003 Intel Corporation
* All rights reserved.
*
* This file is distributed under the terms in the attached INTEL-LICENSE
* file. If you do not find these files, copies can be found by writing to
* Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
* 94704. Attention: Intel License Inquiry.
*/
/**
* @file Crc.h
* @author Junaith Ahemed Shahabdeen
*
* Module provides various CRC calculation functions like bufferCRC,
* byte-by-byte CRC etc which could be used based on the requirements.
* The CRC is calculated based on a static table, which reduces the
* calculation cost.
*
* CAUTION:
* This file is included in the PC application for compatibility
* with the bootloader. <B>NEVER EVER CHANGE THIS FILE FOR ANY REASON
* with out considering the cases in either sides.</B>
* It could easily lead to an incompatible code, please use caution.
*/
#ifndef CRC_H
#define CRC_H
#include <types.h>
/**
* Crc_Buffer
*
* Calculate 16-bit CRC of the buffer pointed to by buff and return the value.
* For cumulative CRC Calculation of various buffers the old crc could be sent
* as the last parameter.
*
* @param buff A pointer to the buffer for which the CRC is calculated.
* @param len Length of the buffer.
* @param oldCRC Append the current calculation to a previous buffer.
*
* @return crc CRC of the buffer appended to the old Buffer.
*/
uint16_t Crc_Buffer (uint8_t* buff, uint32_t len, uint16_t oldCRC);
#endif
--- NEW FILE: Flash.h ---
/* tab:4
* "Copyright (c) 2000-2003 The Regents of the University of California.
* All rights reserved.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose, without fee, and without written agreement is
* hereby granted, provided that the above copyright notice, the following
* two paragraphs and the author appear in all copies of this software.
*
* IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
* OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
* CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
* ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
*
* Copyright (c) 2002-2003 Intel Corporation
* All rights reserved.
*
* This file is distributed under the terms in the attached INTEL-LICENSE
* file. If you do not find these files, copies can be found by writing to
* Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
* 94704. Attention: Intel License Inquiry.
*/
/**
* @file Flash.h
* @Author Josh Herbach
* Revision: 1.0
* Date 09/02/2005
*
* This code is ported from the TinyOS repository.
* ported by; Junaith Ahemed Shahabdeen.
*/
#ifndef __FLASH_H__
#define __FLASH_H__
#define DEBUG 0
#define ASSERT 0
#define FLASH_PARTITION_COUNT 16
#define FLASH_PARTITION_SIZE 0x200000
#define FLASH_STATE_READ_INACTIVE 0
#define FLASH_STATE_PROGRAM 1
#define FLASH_STATE_ERASE 2
#define FLASH_STATE_READ_ACTIVE 3
#define FLASH_BLOCK_COUNT 256
#define FLASH_BLOCK_SIZE 0x20000
#define FLASH_PARAM_BLOCK_SIZE 0x8000
#define FLASH_BLOCK_CLEAN 0
#define FLASH_BLOCK_USED 1
#define FLASH_PROGRAM_BUFFER_SIZE 32
#define FLASH_NOT_SUPPORTED 0x100
#define FLASH_NORMAL 0
#define FLASH_OVERWRITE 1
//anything below FLASH_PROTECTED_REGION will not be written/erased by FlashC
//#define FLASH_PROTECTED_REGION 0x00200000
#define FLASH_PROTECTED_REGION 0x20000
/**
* FIXME
* Temporary start address for copying the primary image
*/
//#define PRIMARY_IMAGE_ADDRESS 0x1C00000
//#define BOOT_IMAGE_ADDRESS 0x20000
//#define PRIMARY_IMAGE_ADDRESS 0x1800000
#endif
--- NEW FILE: FlashAccess.h ---
/* tab:4
* "Copyright (c) 2000-2003 The Regents of the University of California.
* All rights reserved.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose, without fee, and without written agreement is
* hereby granted, provided that the above copyright notice, the following
* two paragraphs and the author appear in all copies of this software.
*
* IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
* OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
* CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
* ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
*
* Copyright (c) 2002-2003 Intel Corporation
* All rights reserved.
*
* This file is distributed under the terms in the attached INTEL-LICENSE
* file. If you do not find these files, copies can be found by writing to
* Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
* 94704. Attention: Intel License Inquiry.
*/
/**
* @file FlashAccess.h
* @Author Josh Herbach
*
* Ported by: Junaith Ahemed Shahabdeen
*
* Higher level functions for Flash Access. The file provides a C
* abstraction for the assembly code in the flash.s file.
* <I>The implementation is ported from the flash write module of
* tinyos repository.</I>
*/
#ifndef __FLASH_ACCESS_H
#define __FLASH_ACCESS_H
#include <Flash.h>
#include <types.h>
/**
* FlashAccess_Init
*
* Intialize the internal states of the blocks and the partitions.
* The fuction also defines the global variables for the
* inline assembly codes of certain functions.
*
* @return SUCCESS | FAIL
*/
result_t FlashAccess_Init();
/**
* Flash_Write
*
* The function provides a wrapper for the actual write word or
* write buffer functions in flash.s. At the higher level the
* function determines if a buffer write is possible in the
* given address, and falls back to word writes. The control
* is passed to the write helper function after the above
* test for placing the rest of the data in flash.
*
* @param addr Starting address to which the buffer has to be written.
* @param data Pointer to the buffer that has to be written to the flash.
* @param numBytes Length of the buffer.
*
* @return SUCCESS | FAIL
*/
result_t Flash_Write(uint32_t addr, uint8_t* data, uint32_t numBytes);
/**
* Flash_Erase
*
* Erase the entire block in which the first parameter is located.
*
* @param addr Starting Address of a flash block.
* @return SUCCESS | FAIL
*/
result_t Flash_Erase (uint32_t addr);
/**
* Flash_Read
*
* The function will read from a flash location and store
* it in a buffer. The function does 16 bit reads till length.
*
* @param Addr Starting Flash Address to read from.
* @param Length Number of bytes to read.
* @param buff Pointer to the buffer where the data is stored.
*
* @return SUCCESS | FAIL
*/
result_t Flash_Read (uint32_t Addr, uint32_t Length, uint8_t* buff);
/**
* Flash_Param_Partition_Erase
*
* The top most partition of the flash is configured as
* parameter partition.
*
* @param addr Starting address of a block that has to be erased.
* @return SUCCESS | FAIL
*/
result_t Flash_Param_Partition_Erase (uint32_t addr);
//result_t Flash_Parameter_Write(uint32_t addr, uint8_t* data, uint32_t numBytes);
/**
* Flash_Unlock
*
* The function performs all the steps required to
* unlock a flash block. The commands and steps are defined
* in the memory subsystem data sheet for the processor.
* The Block address has to be passed as a parameter to the
* function.
*
* @param addr Address of the block that has to be unlocked.
*
* @return status The status register value.
*/
uint16_t Flash_Unlock(uint32_t addr);
/**
* Flash_Lock
*
* The function performs all the steps required to
* lock a flash block. The commands and steps are defined
* in the memory subsystem data sheet for the processor.
* The Block address has to be passed as a parameter to the
* function.
*
* @param addr Address of the block that has to be locked.
*
* @return status The status register value.
*/
uint16_t Flash_Lock(uint32_t addr);
/**
* Erase_Flash
*
* The function performs all the steps required to
* erase a flash block. The commands and steps are defined
* in the memory subsystem data sheet for the processor.
* The Block address has to be passed as a parameter to the
* function.
*
* @param addr Address of the block that has to be erased.
*
* @return status The status register value.
*
*/
uint16_t Erase_Flash(uint32_t addr);
/**
* Program_Word
*
* The function performs all the steps required to
* write a word to flash. The commands and steps are defined
* in the memory subsystem data sheet for the processor.
*
* @parma addr Flash Address in which the word has to be written.
* @param data The Data that has to be written to the flash.
*
* @return status The status register value.
*/
uint16_t Program_Word(uint32_t addr, uint16_t data);
/**
* Program_Buffer
*
* The function performs all the steps required to
* write a buffer to flash. The commands and steps are defined
* in the memory subsystem data sheet for the processor.
*
* <B>
* NOTE;
* The address has to be aligned in 32 byte boundary for the
* buffered write to work.
* </B>
*
* @parma addr Flash Address in which the word has to be written.
* @param data The Data that has to be written to the flash.
* @param datalen Length of the data.
*
* @return status The status register value.
*/
uint16_t Program_Buffer(uint32_t addr, uint16_t data[], uint8_t datalen);
/**
* Write_Helper
*
* This function is actually a continuation of the Flash_Write. It
* picks up the data gathered by the Flash_Write function like if
* a buffered write is possible in a given address location and
* compeltes the flash write request.
*
* @parma addr Flash Address in which the data has to be written.
* @param data The Data that has to be written to the flash.
* @param numBytes Length of the data.
*
* @return status The status register value.
*/
uint16_t Write_Helper(uint32_t addr, uint8_t* data, uint32_t numBytes,
uint8_t prebyte, uint8_t postbyte);
/**
* Write_Exit_Helper
*
* The funciton completes Flash_Write by changing all the internal
* states of the affected blocks by Flash_Write to READ_INACTIVE.
* This state change is puerly driver specific and not a HW
* requirement.
*
* @parma addr Flash Address in which the data has to be written.
* @param numBytes Length of the data.
*
*/
void Write_Exit_Helper(uint32_t addr, uint32_t numBytes);
/**
* __Flash_Erase
*
* The function performs all the steps required to
* erase a flash block. The commands and steps are defined
* in the memory subsystem data sheet for the processor.
* The Block address has to be passed as a parameter to the
* function.
* The function is implemented in flash.s.
*
* @param addr Address of the block that has to be erased.
*
* @return status The status register value.
*
*/
extern uint8_t __Flash_Erase(uint32_t addr) __attribute__ ((noinline));
/**
* __Flash_Program_Word
*
* The function performs all the steps required to
* write a word to flash. The commands and steps are defined
* in the memory subsystem data sheet for the processor.
*
* The function is implemented in flash.s.
*
* @parma addr Flash Address in which the word has to be written.
* @param data The Data that has to be written to the flash.
*
* @return status The status register value.
*/
extern uint8_t __Flash_Program_Word (uint32_t addr,
uint16_t word) __attribute__ ((noinline));
/**
* __Flash_Program_Buffer
*
* The function performs all the steps required to
* write a buffer to flash. The commands and steps are defined
* in the memory subsystem data sheet for the processor.
*
* <B>
* NOTE;
* The address has to be aligned in 32 byte boundary for the
* buffered write to work.
* </B>
*
* @parma addr Flash Address in which the word has to be written.
* @param data The Data that has to be written to the flash.
* @param datalen Length of the data.
*
* @return status The status register value.
*/
extern uint8_t __Flash_Program_Buffer (uint32_t addr,
uint16_t *data,
uint8_t datalen) __attribute__ ((noinline));
extern uint32_t __Flash_Erase_true_end ();
extern uint32_t __Flash_Program_Word_true_end ();
extern uint32_t __Flash_Program_Buffer_true_end ();
#endif
--- NEW FILE: HPLInit.h ---
/* tab:4
* "Copyright (c) 2000-2003 The Regents of the University of California.
* All rights reserved.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose, without fee, and without written agreement is
* hereby granted, provided that the above copyright notice, the following
* two paragraphs and the author appear in all copies of this software.
*
* IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
* OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
* CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
* ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
*
* Copyright (c) 2002-2003 Intel Corporation
* All rights reserved.
*
* This file is distributed under the terms in the attached INTEL-LICENSE
* file. If you do not find these files, copies can be found by writing to
* Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
* 94704. Attention: Intel License Inquiry.
*/
/**
* @file HPLInit.h
* @author
*
* The file provides various hardware initialization routines.
* Ported from TinyOS repository - Junaith
*
*/
#ifndef BL_HPL_INIT_H
#define BL_HPL_INIT_H
#include <types.h>
/**
* TOSH_SET_PIN_DIRECTIONS
*
* Set the pin directions in the processor as a part of
* the hardware initialization process.
*
*/
void TOSH_SET_PIN_DIRECTIONS(void);
/**
* This function is ported from DVFS TinyOS Module.
* Set the Frequency of the clock.
*
* NOTE:
* If the Frequency has to be incremented about 104Mhz then
* the CoreVoltage has to be increased accordingly. Refer to
* http://download.intel.com/design/pca/applicationsprocessors/datashts/28000304.pdf
*
* @param coreFreq Clock frequency to be set.
* @param sysBusFreq Bus Frequency.
*
* @return SUCCESS | FAIL
*/
result_t SetCoreFreq (uint32_t coreFreq, uint32_t sysBusFreq);
/**
* HPLInit
*
* Intialize the hardware clock, set clock frequency and set
* pin directions.
*
* @return SUCCESS | FAIL
*/
result_t HPLInit();
/**
* Enable_MMU
*
* The function enables the MMU, ICache and
* DCache. The clock frequency is set to 104Mhz for
* fast execution and improves performance.
*
* @return SUCCESS | FAIL
*/
result_t Enable_MMU ();
#endif
--- NEW FILE: Leds.h ---
/* tab:4
* "Copyright (c) 2000-2003 The Regents of the University of California.
* All rights reserved.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose, without fee, and without written agreement is
* hereby granted, provided that the above copyright notice, the following
* two paragraphs and the author appear in all copies of this software.
*
* IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
* OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
* CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
* ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
*
* Copyright (c) 2002-2003 Intel Corporation
* All rights reserved.
*
* This file is distributed under the terms in the attached INTEL-LICENSE
* file. If you do not find these files, copies can be found by writing to
* Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
* 94704. Attention: Intel License Inquiry.
*/
/**
* @file Leds.h
* @author Junaith Ahemed Shahabdeen
*
* This file Initialize the LED's and provides
* functions to toggle the each individual LED's.
*/
#ifndef LEDS_H
#define LEDS_H
#include <hardware.h>
extern uint8_t STATE_RED_LED;
extern uint8_t STATE_GREEN_LED;
extern uint8_t STATE_YELLOW_LED;
/**
* TOGGLE_LED
*
* Switch a LED from ON to OFF and vice versa depending
* on the current state of the LED.
*/
#define TOGGLE_LED(name) ({ \
if (STATE_##name##_LED) \
TOSH_CLR_##name##_LED_PIN (); \
else \
TOSH_SET_##name##_LED_PIN (); \
STATE_##name##_LED = ! STATE_##name##_LED; \
});
/**
* Leds_Init
*
* Intialize the Leds and create macros for
* controlling the LED pins.
*/
result_t Leds_Init ();
#endif
--- NEW FILE: MMU.h ---
/* tab:4
* "Copyright (c) 2000-2003 The Regents of the University of California.
* All rights reserved.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose, without fee, and without written agreement is
* hereby granted, provided that the above copyright notice, the following
* two paragraphs and the author appear in all copies of this software.
*
* IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
* OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
* CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
* ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
*
* Copyright (c) 2002-2003 Intel Corporation
* All rights reserved.
*
* This file is distributed under the terms in the attached INTEL-LICENSE
* file. If you do not find these files, copies can be found by writing to
* Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
* 94704. Attention: Intel License Inquiry.
*/
/**
* @file MMU.h
* @author
*
* Ported By: Junaith Ahemed Shahabdeen
*
* This file is ported from the TinyOS repository. The file
* contains functions that are required to handle
* MMU and Cache (ICache and DCache).
*
*/
#ifndef __MMU_H__
#define __MMU_H__
void initSyncFlash();
/**
* initMMU
*
* The function which is implemented in util.s performs
* the following tasks.
*
* 1. Enable Read/Write permission for Domain 0 in the
* CP15 Domain Register 3.
* 2. Set Translation Table Base Register with the MMU
* table address. MMU Table is defined in mmu_table.s
* which enables C, B bits for flash partition 1 (where
* the boot loader code is located), SRAM and the
* register addresses.
* 3. Sets MMU enable bit (1st bit) in the Control and
* Auxiliary control registers (CP15 register 1) to
* enable MMU.
*/
void initMMU();
/**
* enableICache
*
* The function which is implemented in util.s performs
* the following
*
* 1. Unlocks the ICache and Itlb.
* 2. Invalidates ICache, BTB, and Itlb.
* 3. Enable Icache and BTB in the CP15 register1.
*/
void enableICache();
/**
* enableDCache
*
* The function is implemented in util.s.
*
* 1. Unlocks Dtlb and DCache.
* 2. Invalidata DCache, mini-dcache and DTlb.
* 3. Enable dcache in the CP15 register1.
*/
void enableDCache();
/**
* disableDCache
*
* The function cleans the entire data cache to restore the dirty
* bits and invalidates the cache before disabling it.
*/
void disableDCache();
/**
* invalidateDCache
*
* The function invalidates the DCache for the given buffer.
* @param address Virtual address to evict.
* @param numbytes Size of the buffer.
*/
void invalidateDCache(uint8_t *address, int32_t numbytes);
/**
* cleanDCache
*
*/
void cleanDCache(uint8_t *address, int32_t numbytes);
/**
*
*/
void globalCleanAndInvalidateDCache();
#endif
--- NEW FILE: MessageDefines.h ---
/* tab:4
* "Copyright (c) 2000-2003 The Regents of the University of California.
* All rights reserved.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose, without fee, and without written agreement is
* hereby granted, provided that the above copyright notice, the following
* two paragraphs and the author appear in all copies of this software.
*
* IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
* OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
* CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
* ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
*
* Copyright (c) 2002-2003 Intel Corporation
* All rights reserved.
*
* This file is distributed under the terms in the attached INTEL-LICENSE
* file. If you do not find these files, copies can be found by writing to
* Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
* 94704. Attention: Intel License Inquiry.
*/
/**
* MessageDefines.h
*
* The file contains the definitions of the commands, errors
* and the data structure used to form a command information.
*
* CAUTION;
* This file is shared between the boot loader and the
* pc application. <B> DO NOT CHANGE THIS FILE without
* considering the failure cases on both the sides.</B>
*
*/
#ifndef MESSAGE_DEFINES_H
#define MESSAGE_DEFINES_H
#include <types.h>
/**
* The window size is reperesented in number of USB packets
* required to for 32k chunk of data (excluding the headers). The
* down side of this definitions is that it ASSUMES that the USB
* communicates with the PC as a HID Client and the maximum packet
* size is 64 bytes.
* If the USB Communication changes, then this value has to be
* changed.
*/
#define BIN_DATA_WINDOW_SIZE 546 /* Close to 32k*/
/**
* CodeLoadType
*
* The type of image being loaded. It could be
* the binary image of an application or a
* self test image.
*/
typedef enum CodeLoadType
{
APPLICATION = 1,
SELFTEST = 2
}CodeLoadType;
typedef struct USBImagePck
{
uint16_t seq; /* Sequence Number of the packet*/
uint8_t data []; /* The binary data of the packet*/
}USBImagePck;
typedef struct USBCommand
{
uint8_t type; /*Command Type (enum Commands)*/
uint8_t data []; /*Idea is to plug in and data possible*/
} USBCommand;
/**
* struct USBError
*
* The data structure which communicates the error between the
* boot loader and the PC application
*/
typedef struct USBError
{
uint8_t type; /* Error Type (see enum Errors)*/
uint8_t desclen; /* Description Length*/
uint8_t description []; /* Description or required data related to the error*/
} USBError;
/**
* struct CmdImageDetail
*
* Defines the details that are passed from the PC to the
* IMote in response to GET_IMAGE_DETAILS
*/
typedef struct RspImageDetail
{
uint32_t ImageSize; /* Size of the Image being uploaded*/
uint32_t NumUSBPck; /* Number of USB Packets*/
} RspImageDetail;
/**
* struct CmdReqBinData
*
* Command Structure for requesting binary image data from
* the PC. The image is requested as chuncks of USB packets.
*/
typedef struct CmdReqBinData
{
uint32_t PckStart; /* Packet number to start from*/
uint32_t NumUSBPck; /* Number of USB Packets to form the chunk*/
uint32_t ChunkSize; /* Size of the Chunk*/
}CmdReqBinData;
/**
* struct CmdCrcData
*
* This stucture is used if the boot loader has to request crc for a chunk of
* data from the PC application or if the pc application sends the crc
* after uploading a chunk.
*/
typedef struct CmdCrcData
{
uint32_t chunkStart; /* Starting point of the chunk (in usb packets)*/
uint32_t NumUSBPck; /* Number of USB Packets. Mostly for size*/
uint16_t ChunkCRC; /* CRC of the chunk between pckstart and size*/
}CmdCrcData;
/**
* Defines the commands to the PC applicaiton (CMD_*) and response
* from the PC application (RSP_*)
* Note the implementation the embedded side only implements the
* RSP_* because it has to understand only those and the PC side
* implements all the CMD_*.
* This is to make the code less ambiguous.
*/
typedef enum Commands
{
/* Usually commands that originate from the bootloader*/
RSP_REBOOT = 1, /*Reboot the Device*/
CMD_BOOT_ANNOUNCE = 2, /*Announce the reboot to PC*/
RSP_USB_CODE_LOAD = 3, /*Place the boot loader in Code Load*/
CMD_GET_IMAGE_DETAILS = 4, /*Request Image detail from PC app*/
RSP_GET_IMAGE_DETAILS = 5, /*Response from PC app about the image*/
CMD_REQUEST_BIN_DATA = 6, /*Request binary chunk from PC*/
CMD_CRC_CHECK = 7, /*Request CRC for the current chunk*/
RSP_CRC_CHECK = 8, /*CRC for the current chunk from PC app*/
CMD_IMG_UPLOAD_COMPLETE = 9, /*Inform PC app that Image download is complete*/
CMD_IMG_VERIFY_COMPLETE = 10, /*Image passed the CRC test*/
CMD_REQUEST_BIN_PCK = 11,
CMD_CREATED_GOLDEN_IMG = 12, /*Image download is complete*/
/* Commands that originate from the PC and expects a response*/
RSP_GET_ATTRIBUTE = 100, /*PC asks for the attribute value*/
CMD_RSP_GET_ATTRIBUTE = 101, /*The boot loader responds with Attr Value*/
RSP_DUMP_FLASH_DATA = 102, /*PC app is requesting data from flash */
RSP_SET_ATTRIBUTE = 103, /*Response for setattr request from PC app*/
CMD_RSP_SET_ATTRIBUTE = 104, /*setattr Request from PC app*/
RSP_SET_BOOTLOADER_STATE = 105, /*Set boot loader state*/
CMD_TEST_IMG_DUMP= 200, /*Dump an image from the secondary location*/
RSP_TEST_GET_BUFFER_DATA = 201, /*Dump the current buffer*/
RSP_FLASH_MEM_TEST = 202, /**/
CMD_BOOTLOADER_MSG = 203 /*Send a string to the PC app (dbg message)*/
} Commands;
/**
* The enumerated values are the possible errors that are communicated
* between the bootloader and the PC application.
*/
typedef enum Errors
{
ERR_FLASH_WRITE = 1, /*Error writing to flash memory*/
ERR_FLASH_ERASE = 27, /*Error erasing flash block*/
ERR_FLASH_READ = 28, /*Error reading from Flash*/
ERR_COMMAND_FAILED = 29, /*The command sent by pc app failed*/
ERR_NO_MORE_BINARY_DATA = 100,
TEST_CRC_FAILURE = 201, /*CRC does not match for the current buffer or Image*/
ERR_FATAL_ERROR_ABORT = 250 /*Error that prevent execution impossible*/
} Errors;
#endif
--- NEW FILE: PMIC.h ---
/* tab:4
* "Copyright (c) 2000-2003 The Regents of the University of California.
* All rights reserved.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose, without fee, and without written agreement is
* hereby granted, provided that the above copyright notice, the following
* two paragraphs and the author appear in all copies of this software.
*
* IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
* OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
* CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
* ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
*
* Copyright (c) 2002-2003 Intel Corporation
* All rights reserved.
*
* This file is distributed under the terms in the attached INTEL-LICENSE
* file. If you do not find these files, copies can be found by writing to
* Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
* 94704. Attention: Intel License Inquiry.
*/
/**
* @file PMIC.h
* @author Lama Nachman, Robbie Adler
*
* The file provices PMIC intialization and settings together with
* the interrupts from the PMIC.
*/
#ifndef PMIC_H
#define PMIC_H
#include <hardware.h>
#include <PMICDefines.h>
#define RESET_DELAY 10000 // delay in 1/3.25 MHz increments = ~3 ms
/**
* PMIC_Init
*
* Setup the I2C to talk to the PMIC and allocate the I2C interrupt.
* This code is ported from the tinyos repository and combines both
* the init and the start routine of the tinyos version.
*
*/
void PMIC_Init();
/**
* PMIC_Stop
*
* Disable the interrupts related to the PMIC and undo
* all the register settings.
*
* @return SUCCESS | FAIL
*/
result_t PMIC_Stop();
/**
* readPMIC
*
* The function reads data from the PMIC using the I2C
* and stores it in a buffer ("value")
*
* @param address Address to read from.
* @param value The data will be stored in this buffer.
* @param numBytes Number of bytes to be read.
*
* @return SUCCESS | FAIL
*/
result_t readPMIC(uint8_t address, uint8_t *value, uint8_t numBytes);
/**
* writePMIC
*
* Write a byte value to a particular address using I2C. The value and
* the address has to be passed as parameter to the function.
*
* @param address
* @param value
*
* @return SUCCESS | FAIL
*/
result_t writePMIC (uint8_t address, uint8_t value);
/**
* startLDOs
*
* Code ported from TinyOS,
*
* @@@@FIXME I am not sure which of the LDOs we will need and
* which ones we dont care about. need to fix it.
*/
void startLDOs();
/**
* PMIC_SetCoreVoltage
*
* The Buck2 controls the core voltage, set to appropriate trim value
*
* @param trimValue
*
* @return SUCCESS | FAIL
*/
result_t PMIC_SetCoreVoltage (uint8_t trimValue);
/**
* PMICInterrupt_Fired
*
* The init routine enables only the reset interrupt and
* all the other interrupts are explicitly disabled. So
* the function is invoked only when the reset button is
* activated.
*
*/
void PMICInterrupt_Fired();
/**
* PI2CInterrupt_Fired
*
* The settings to the PMIC chip is through the
* I2C. The interrupt indicates either a write
* or read done from the I2C bus.
*/
void PI2CInterrupt_Fired();
/**
* WDReset
*
* Enables the watchdog and sets the compare register
* with the value of the first parameter and waits till
* the timeout occurs. The processor reboots once a
* timeout.
*
* @parm delay Value for a compare register.
*/
void WDReset (int delay);
#endif
--- NEW FILE: PMICDefines.h ---
/* tab:4
*
*
* "Copyright (c) 2000-2002 The Regents of the University of California.
* All rights reserved.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose, without fee, and without written agreement is
* hereby granted, provided that the above copyright notice, the following
* two paragraphs and the author appear in all copies of this software.
*
* IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
* OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
* CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
* ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
*
*/
/* tab:4
* IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. By
* downloading, copying, installing or using the software you agree to
* this license. If you do not agree to this license, do not download,
* install, copy or use the software.
*
* Intel Open Source License
*
* Copyright (c) 2002 Intel 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:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 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.
* Neither the name of the Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``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 DISCLAIMED. IN NO EVENT SHALL THE INTEL OR ITS
* CONTRIBUTORS 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.
*
*
*/
/**
* @file PMICDefines.h
* @author Lama Nachman, Robbie Adler
* Ported from the TinyOS Repository
*
* This file includes the PMIC command defintions. We are using the Dialog
* DA9030 part.
*
*/
#ifndef PMIC_DEFINES_H
#define PMIC_DEFINES_H
// I2C slave addr
#define PMIC_SLAVE_ADDR 0x49
// Register BUCK2 with DVC1
#define PMIC_BUCK2_REG1 0x15
// Register BUCK2 with DVC2
#define PMIC_BUCK2_REG2 0x16
// LDO on/off control in App Reg space
#define PMIC_A_REG_CONTROL_1 0x17
#define PMIC_A_REG_CONTROL_2 0x18
#define PMIC_EVENTS (0x01) // 3 byte array
#define PMIC_EVENTA (0x01)
#define PMIC_EVENTB (0x02)
#define PMIC_EVENTC (0x03)
#define PMIC_STATUS (0x04)
#define PMIC_IRQ_MASK_A (0x05)
#define PMIC_IRQ_MASK_B (0x06)
#define PMIC_IRQ_MASK_C (0x07)
#define PMIC_SYS_CONTROL_A (0x08)
#define PMIC_SYS_CONTROL_C (0x80)
#define PMIC_CHARGE_CONTROL (0x28)
#define PMIC_CC_CHARGE_ENABLE (1<<7)
#define PMIC_CC_ISET(_x) (((_x) & 0xF) << 3)
#define PMIC_CC_VSET(_x) (((_x) & 0x7))
#define PMIC_TCTR_CONTROL (0x2A)
#define PMIC_ADC_MAN_CONTROL (0x30)
#define PMIC_AMC_ADCMUX(_x) ((_x & 0x7))
#define PMIC_AMC_MAN_CONV (1<<3)
#define PMIC_AMC_LDO_INT_Enable (1<<4)
#define PMIC_ADC_AUTO_CONTROL (0x31)
#define PMIC_MAN_RES (0x40)
#define PMIC_VBAT_RES (0x41)
#define PMIC_VBATMIN_RES (0x42)
#define PMIC_VBATMINTXON_RES (0x43)
#define PMIC_ICHMAX_RES (0x44)
#define PMIC_ICHMIN_RES (0x45)
#define PMIC_ICHAVERAGE_RES (0x46)
#define PMIC_VCHMAX_RES (0x47)
#define PMIC_VCHMIN_RES (0x48)
#define PMIC_TBAT_RES (0x49)
#define PMIC_ADC_IN4_RES (0x4A)
#define PMIC_ADC_IN5_RES (0x4B)
#define PMIC_LED1_CONTROL (0x20)
// LDO on/off control in Baseband Reg space
#define PMIC_B_REG_CONTROL_1 0x97
#define PMIC_B_REG_CONTROL_2 0x98
#define PMIC_B_SLEEP_CONTROL_1 0x99
#define PMIC_B_SLEEP_CONTROL_2 0x9A
#define PMIC_B_SLEEP_CONTROL_3 0x9B
// IRQ_MASK_A
#define IMA_ONKEY_N 0x1
#define IMA_PWREN1 0x2
#define IMA_EXTON 0x4
#define IMA_CHDET 0x8
#define IMA_TBAT 0x10
#define IMA_VBATMON_1 0x20
#define IMA_VBATMON_2 0x40
#define IMA_CHIOVER 0x80
//IRQ_MASK_B
#define IMB_TCTO 0x1
#define IMB_CCTO 0x2
#define IMB_ADC_READY 0x4
#define IMB_VBUS_VALID_4_4 0x8
#define IMB_VBUS_VALID_4_0 0x10
#define IMB_SESSION_VALID 0x20
#define IMB_SRP_DETECT 0x40
#define IMB_WDOG 0x80
// SYS_CONTROL_A
#define SCA_SLEEP_N_EN 0x1
#define SCA_SHUTDOWN 0x2
#define SCA_HWRES_EN 0x4
#define SCA_WDOG_ACTION 0x8
#define SCA_TWDSCALE(_x) (((_x) & 7) << 4)
#define SCA_RESET_WDOG 0x80
// Events registers A, B, C
#define EVENTS_A_OFFSET 0
#define EA_ONKEY_N 0x1
#define EA_PWREN1 0x2
#define EA_EXTON 0x4
#define EA_CHDET 0x8
#define EA_TBAT 0x10
#define EA_VBATMON 0x20
#define EA_VBATMON_TXON 0x40
#define EA_CHIOVER 0x80
#define EVENTS_B_OFFSET 1
#define EVENTS_C_OFFSET 2
// BUCK2 Reg 1
#define B2R1_TRIM_MASK 0x1f
#define B2R1_TRIM_P85_V 0x0
#define B2R1_TRIM_P875_V 0x1
#define B2R1_TRIM_P9_V 0x2
#define B2R1_TRIM_P925_V 0x3
#define B2R1_TRIM_P95_V 0x4
#define B2R1_TRIM_P975_V 0x5
#define B2R1_TRIM_1_V 0x6
#define B2R1_TRIM_1_125_V 0xB
#define B2R1_TRIM_1_25_V 0x10
#define B2R1_SLEEP 0x40
#define B2R1_GO 0x80
// Reg Control 1 for App processor reg space: Enable/Disable LDOs
#define ARC1_BUCK2_EN 0x1 // on
#define ARC1_LDO10_EN 0x2 // off
#define ARC1_LDO11_EN 0x4 // off
#define ARC1_LDO13_EN 0x8 // off
#define ARC1_LDO14_EN 0x10 // off
#define ARC1_LDO15_EN 0x20 // on
#define ARC1_LDO16_EN 0x40 // on
#define ARC1_LDO17_EN 0x80 // off
// Reg Control 2 for App processor reg space : Enable/Disable LDOs
#define ARC2_LDO18_EN 0x1 // on
#define ARC2_LDO19_EN 0x2 // on
#define ARC2_SIMCP_EN 0x40 // off
// Reg Control 1 for Baseband reg space
#define BRC1_BUCK_EN 0x1 // off
#define BRC1_LDO1_EN 0x2 // off
#define BRC1_LDO2_EN 0x4 // off
#define BRC1_LDO3_EN 0x8 // BB
#define BRC1_LDO4_EN 0x10 // off
#define BRC1_LDO5_EN 0x20 // radio
#define BRC1_LDO6_EN 0x40 // off
#define BRC1_LDO7_EN 0x80 // off
// Reg Control 2 for Baseband reg space
#define BRC2_LDO8_EN 0x1 // off
#define BRC2_LDO9_EN 0x2 // off
#define BRC2_LDO10_EN 0x4 // sensor board
#define BRC2_LDO11_EN 0x8 // sensor board
#define BRC2_LDO12_EN 0x10 // BB_IO
#define BRC2_LDO14_EN 0x20 // off
#define BRC2_SIMCP_EN 0x40 // off
#define BRC2_SLEEP 0x80 // off
// Sleep control 1 for Baseband reg space
#define BSC1_LDO1(_x) (((_x) & 0x3) << 0)
#define BSC1_LDO2(_x) (((_x) & 0x3) << 2)
#define BSC1_LDO3(_x) (((_x) & 0x3) << 4)
#define BSC1_LDO4(_x) (((_x) & 0x3) << 6)
// Sleep control 2 for Baseband reg space
#define BSC2_LDO5(_x) (((_x) & 0x3) << 0)
#define BSC2_LDO7(_x) (((_x) & 0x3) << 2)
#define BSC2_LDO8(_x) (((_x) & 0x3) << 4)
#define BSC2_LDO9(_x) (((_x) & 0x3) << 6)
// Sleep control 3 for Baseband reg space
#define BSC3_LDO12(_x) (((_x) & 0x3) << 0)
#endif //PMIC_H
--- NEW FILE: PXA27XClock.h ---
/* tab:4
* "Copyright (c) 2000-2003 The Regents of the University of California.
* All rights reserved.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose, without fee, and without written agreement is
* hereby granted, provided that the above copyright notice, the following
* two paragraphs and the author appear in all copies of this software.
*
* IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
* OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
* CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
* ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
*
* Copyright (c) 2002-2003 Intel Corporation
* All rights reserved.
*
* This file is distributed under the terms in the attached INTEL-LICENSE
* file. If you do not find these files, copies can be found by writing to
* Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
* 94704. Attention: Intel License Inquiry.
*/
/**
* @file PXA27XClock.h
* @author
*
* Ported from TinyOS repository and modified as per
* the requirements - Junaith Ahemed
*
* This file provides the clock routines ported from the tinyos repository from
* PXA27XClockM.nc.
*/
#ifndef PXA27X_CLOCK_H
#define PXA27X_CLOCK_H
#include <types.h>
#include <pxa27xhardware.h>
#include <stdlib.h>
/**
* There are situations where we have to set the
* clock for a non MsgId type which is not an Error
* or a command.
*/
typedef enum ExtendedClockDef
{
SYNC_TIMEOUT = 10000,
}ExtendedClockDef;
typedef struct TimeoutDetail
{
uint32_t TimeoutMS; /*Timeout in MS*/
uint16_t MsgId; /* To distinguish higher level message (command, error etc)*/
uint8_t Type; /* The type of message (one of Commands, Errors etc)*/
uint8_t ExpectedType; /* What response type is need to stop this timeout cycle*/
uint8_t NumRetries; /* Number of retires*/
void (*NotifyFunc) (uint8_t id, uint8_t typ, uint8_t ret);
} TimeoutDetail;
/**
* OSTIrq_Fired
*
* This method is called from the IRQ handler when ever there is a
* clock interrupt. The higher level Clock_Fire function maintains
* the higher resolution.
*
*/
void OSTIrq_Fired();
/**
* Enable_Timeout
*
* Function will enable the timeout mechanism for a particular
* command or other message types. The struct passed as parameter
* will contain the details of timeout value and call back
* functions etc.
*
* @param tout Structure which contains the time out details. The
* function requesting the timeout must provide all the
* required details.
*
* @return SUCCESS | FAIL
*/
result_t Enable_Timeout (TimeoutDetail* tout);
/**
* Check_Timeout_Disable
*
* This function is called whenever a message
* is received, If the received message type matches
* with the 'ExpectedType' then the time out
* mechanism is not required anymore. So the timer
* will be disabled.
*
* @param msgId Message Id
* @param type Type of the message received (eg a particular command)
*
* @return SUCCESS | FAIL
*/
result_t Check_Timeout_Disable (uint8_t msgId, uint8_t type);
/***************************************************************
*********** INTERNAL FUNCTIONS FOR NOW *********************
***************************************************************/
/**
* PXA27XClock_Start
*
* Initializes the required regiesters and enables the clock interrupt.
* Currently an interrupt will occur every 1ms.
*
* @return SUCESS | FAIL
*/
result_t PXA27XClock_Start(uint32_t interval);
/**
* PXA27XClock_Stop
*
* Disable the OMCR5 match interrupt and disable the counter.
*
* @return SUCESS | FAIL
*/
result_t PXA27XClock_Stop();
void PXA27XClock_SetInterval (uint32_t interval);
#endif
--- NEW FILE: PXA27XGPIOInt.h ---
/* tab:4
* "Copyright (c) 2000-2003 The Regents of the University of California.
* All rights reserved.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose, without fee, and without written agreement is
* hereby granted, provided that the above copyright notice, the following
* two paragraphs and the author appear in all copies of this software.
*
* IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
* OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
* CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
* ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
*
* Copyright (c) 2002-2003 Intel Corporation
* All rights reserved.
*
* This file is distributed under the terms in the attached INTEL-LICENSE
* file. If you do not find these files, copies can be found by writing to
* Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
* 94704. Attention: Intel License Inquiry.
*/
/**
* @file PXA27XGPIOInt.h
* @author
*
* ported from TinyOS repository - Junaith
*
*/
#ifndef PXA27X_GPIO_INT_H
#define PXA27X_GPIO_INT_H
#include <hardware.h>
result_t PXA27XGPIOInt_Init();
result_t PXA27XGPIOInt_Stop();
void PXA27XGPIOInt_Enable(uint8_t pin, uint8_t mode);
void PXA27XGPIOInt_Disable (uint8_t pin);
void PXA27XGPIOInt_Clear (uint8_t pin);
void GPIOIrq_Fired();
void GPIOIrq0_Fired();
void GPIOIrq1_Fired();
#endif
--- NEW FILE: PXA27XInterrupt.h ---
/* tab:4
* "Copyright (c) 2000-2003 The Regents of the University of California.
* All rights reserved.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose, without fee, and without written agreement is
* hereby granted, provided that the above copyright notice, the following
* two paragraphs and the author appear in all copies of this software.
*
* IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
* OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
* CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
* ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
*
* Copyright (c) 2002-2003 Intel Corporation
* All rights reserved.
*
* This file is distributed under the terms in the attached INTEL-LICENSE
* file. If you do not find these files, copies can be found by writing to
* Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
* 94704. Attention: Intel License Inquiry.
*/
/**
* @file PXA27XInterrupt.h
* @author
*
* ported from TinyOS repository - junaith
*/
#ifndef PXA27X_INTERRUPT_H
#define PXA27X_INTERRUPT_H
#include <hardware.h>
#include <stdlib.h>
#include <string.h>
//void hplarmv_irq_redirect () __attribute__ ((interrupt ("IRQ")));
void hplarmv_pabort () __attribute__((interrupt ("PABORT")));
/**
* hplarmv_irq
*
* The function is an interrupt handler. The compiler will
* generate function entry and exit sequences suitable for use in an
* interrupt handler.
*/
void hplarmv_irq() __attribute__ ((interrupt ("IRQ")));
//void hplarmv_irq();
//void hpl_irq_redir () __attribute__ ((interrupt ("IRQ")));
/**
* hplarmv_fiq
*
* The function is an interrupt handler. The compiler will
* generate function entry and exit sequences suitable for use in an
* interrupt handler.
*/
void hplarmv_fiq() __attribute__ ((interrupt ("FIQ")));
result_t allocate(uint8_t id, bool level, uint8_t priority);
void enable(uint8_t id);
void disable (uint8_t id);
result_t PXA27XIrq_Allocate (uint8_t id);
void PXA27XIrq_Enable (uint8_t id);
void PXA27XIrq_Disable (uint8_t id);
result_t PXA27XFiq_Allocate(uint8_t id);
void PXA27XFiq_Enable (uint8_t id);
void PXA27XFiq_Disable (uint8_t id);
//inline __nesc_atomic_t __nesc_atomic_start(void);
//inline void __nesc_atomic_end(__nesc_atomic_t oldState);
#endif
--- NEW FILE: PXA27XUDCRegAddrs.h ---
/* tab:4
* "Copyright (c) 2000-2003 The Regents of the University of California.
* All rights reserved.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose, without fee, and without written agreement is
* hereby granted, provided that the above copyright notice, the following
* two paragraphs and the author appear in all copies of this software.
*
* IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
* OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
* CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
* ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
*
* Copyright (c) 2002-2003 Intel Corporation
* All rights reserved.
*
* This file is distributed under the terms in the attached INTEL-LICENSE
* file. If you do not find these files, copies can be found by writing to
* Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
* 94704. Attention: Intel License Inquiry.
*/
/*
* @file PXA27XUDCRegAddrs.h
* @author: Josh Herbach
* Revision: 1.0
* Date: 09/02/2005
*/
#ifndef __UDCREGADDRS_H
#define __UDCREGADDRS_H
#define _udccr ((volatile unsigned long * const) 0x40600000)
#define _udcicr0 ((volatile unsigned long * const) 0x40600004)
#define _udcicr1 ((volatile unsigned long * const) 0x40600008)
#define _udcisr0 ((volatile unsigned long * const) 0x4060000C)
#define _udcisr1 ((volatile unsigned long * const) 0x40600010)
#define _udcfnr ((volatile unsigned long * const) 0x40600014)
#define _udcotgicr ((volatile unsigned long * const) 0x40600018)
#define _udcotgisr ((volatile unsigned long * const) 0x4060001C)
#define _up2ocr ((volatile unsigned long * const) 0x40600020)
#define _up3ocr ((volatile unsigned long * const) 0x40600024)
#define _udccsr0 ((volatile unsigned long * const) 0x40600100)
#define _udccsra ((volatile unsigned long * const) 0x40600104)
#define _udccsrb ((volatile unsigned long * const) 0x40600108)
#define _udccsrc ((volatile unsigned long * const) 0x4060010C)
#define _udccsrd ((volatile unsigned long * const) 0x40600110)
#define _udccsre ((volatile unsigned long * const) 0x40600114)
#define _udccsrf ((volatile unsigned long * const) 0x40600118)
#define _udccsrg ((volatile unsigned long * const) 0x4060011C)
#define _udccsrh ((volatile unsigned long * const) 0x40600120)
#define _udccsri ((volatile unsigned long * const) 0x40600124)
#define _udccsrj ((volatile unsigned long * const) 0x40600128)
#define _udccsrk ((volatile unsigned long * const) 0x4060012C)
#define _udccsrl ((volatile unsigned long * const) 0x40600130)
#define _udccsrm ((volatile unsigned long * const) 0x40600134)
#define _udccsrn ((volatile unsigned long * const) 0x40600138)
#define _udccsrp ((volatile unsigned long * const) 0x4060013C)
#define _udccsrq ((volatile unsigned long * const) 0x40600140)
#define _udccsrr ((volatile unsigned long * const) 0x40600144)
#define _udccsrs ((volatile unsigned long * const) 0x40600148)
#define _udccsrt ((volatile unsigned long * const) 0x4060014C)
#define _udccsru ((volatile unsigned long * const) 0x40600150)
#define _udccsrv ((volatile unsigned long * const) 0x40600154)
#define _udccsrw ((volatile unsigned long * const) 0x40600158)
#define _udccsrx ((volatile unsigned long * const) 0x4060015C)
#define _udcbcr0 ((volatile unsigned long * const) 0x40600200)
#define _udcbcra ((volatile unsigned long * const) 0x40600204)
#define _udcbcrb ((volatile unsigned long * const) 0x40600208)
#define _udcbcrc ((volatile unsigned long * const) 0x4060020C)
#define _udcbcrd ((volatile unsigned long * const) 0x40600210)
#define _udcbcre ((volatile unsigned long * const) 0x40600214)
#define _udcbcrf ((volatile unsigned long * const) 0x40600218)
#define _udcbcrg ((volatile unsigned long * const) 0x4060021C)
#define _udcbcrh ((volatile unsigned long * const) 0x40600220)
#define _udcbcri ((volatile unsigned long * const) 0x40600224)
#define _udcbcrj ((volatile unsigned long * const) 0x40600228)
#define _udcbcrk ((volatile unsigned long * const) 0x4060022C)
#define _udcbcrl ((volatile unsigned long * const) 0x40600230)
#define _udcbcrm ((volatile unsigned long * const) 0x40600234)
#define _udcbcrn ((volatile unsigned long * const) 0x40600238)
#define _udcbcrp ((volatile unsigned long * const) 0x4060023C)
#define _udcbcrq ((volatile unsigned long * const) 0x40600240)
#define _udcbcrr ((volatile unsigned long * const) 0x40600244)
#define _udcbcrs ((volatile unsigned long * const) 0x40600248)
#define _udcbcrt ((volatile unsigned long * const) 0x4060024C)
#define _udcbcru ((volatile unsigned long * const) 0x40600250)
#define _udcbcrv ((volatile unsigned long * const) 0x40600254)
#define _udcbcrw ((volatile unsigned long * const) 0x40600258)
#define _udcbcrx ((volatile unsigned long * const) 0x4060025C)
#define _udcdr0 ((volatile unsigned long * const) 0x40600300)
#define _udcdra ((volatile unsigned long * const) 0x40600304)
#define _udcdrb ((volatile unsigned long * const) 0x40600308)
#define _udcdrc ((volatile unsigned long * const) 0x4060030C)
#define _udcdrd ((volatile unsigned long * const) 0x40600310)
#define _udcdre ((volatile unsigned long * const) 0x40600314)
#define _udcdrf ((volatile unsigned long * const) 0x40600318)
#define _udcdrg ((volatile unsigned long * const) 0x4060031C)
#define _udcdrh ((volatile unsigned long * const) 0x40600320)
#define _udcdri ((volatile unsigned long * const) 0x40600324)
#define _udcdrj ((volatile unsigned long * const) 0x40600328)
#define _udcdrk ((volatile unsigned long * const) 0x4060032C)
#define _udcdrl ((volatile unsigned long * const) 0x40600330)
#define _udcdrm ((volatile unsigned long * const) 0x40600334)
#define _udcdrn ((volatile unsigned long * const) 0x40600338)
#define _udcdrp ((volatile unsigned long * const) 0x4060033C)
#define _udcdrq ((volatile unsigned long * const) 0x40600340)
#define _udcdrr ((volatile unsigned long * const) 0x40600344)
#define _udcdrs ((volatile unsigned long * const) 0x40600348)
#define _udcdrt ((volatile unsigned long * const) 0x4060034C)
#define _udcdru ((volatile unsigned long * const) 0x40600350)
#define _udcdrv ((volatile unsigned long * const) 0x40600354)
#define _udcdrw ((volatile unsigned long * const) 0x40600358)
#define _udcdrx ((volatile unsigned long * const) 0x4060035C)
#define _udccra ((volatile unsigned long * const) 0x40600404)
#define _udccrb ((volatile unsigned long * const) 0x40600408)
#define _udccrc ((volatile unsigned long * const) 0x4060040C)
#define _udccrd ((volatile unsigned long * const) 0x40600410)
#define _udccre ((volatile unsigned long * const) 0x40600414)
#define _udccrf ((volatile unsigned long * const) 0x40600418)
#define _udccrg ((volatile unsigned long * const) 0x4060041C)
#define _udccrh ((volatile unsigned long * const) 0x40600420)
#define _udccri ((volatile unsigned long * const) 0x40600424)
#define _udccrj ((volatile unsigned long * const) 0x40600428)
#define _udccrk ((volatile unsigned long * const) 0x4060042C)
#define _udccrl ((volatile unsigned long * const) 0x40600430)
#define _udccrm ((volatile unsigned long * const) 0x40600434)
#define _udccrn ((volatile unsigned long * const) 0x40600438)
#define _udccrp ((volatile unsigned long * const) 0x4060043C)
#define _udccrq ((volatile unsigned long * const) 0x40600440)
#define _udccrr ((volatile unsigned long * const) 0x40600444)
#define _udccrs ((volatile unsigned long * const) 0x40600448)
#define _udccrt ((volatile unsigned long * const) 0x4060044C)
#define _udccru ((volatile unsigned long * const) 0x40600450)
#define _udccrv ((volatile unsigned long * const) 0x40600454)
#define _udccrw ((volatile unsigned long * const) 0x40600458)
#define _udccrx ((volatile unsigned long * const) 0x4060045C)
#endif
--- NEW FILE: PXA27XUSBClient.h ---
/* tab:4
* "Copyright (c) 2000-2003 The Regents of the University of California.
* All rights reserved.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose, without fee, and without written agreement is
* hereby granted, provided that the above copyright notice, the following
* two paragraphs and the author appear in all copies of this software.
*
* IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
* OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
* CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
* ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
*
* Copyright (c) 2002-2003 Intel Corporation
* All rights reserved.
*
* This file is distributed under the terms in the attached INTEL-LICENSE
* file. If you do not find these files, copies can be found by writing to
* Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
* 94704. Attention: Intel License Inquiry.
*/
/**
* @file: PXA27XUSBClient.h
* @author: Josh Herbach
* Revision: 1.0
* Date: 09/02/2005
*/
#ifndef __PXA27XUSBCLIENT_H__
#define __PXA27XUSBCLIENT_H__
#define DEBUG 0
#define ASSERT 0
#define USBPOWER 125 // 1/2 of the actually requested power, so 250 ma
#define _PXAREG8(_addr) (*((volatile uint8_t *)(_addr)))
#define _PXAREG16(_addr) (*((volatile uint16_t *)(_addr)))
#define _UDC_bit(_udc) (1 << ((_udc) & 0x1f))
#define USB_ENDPOINT_IN 7
// These define offsets within certain register bitmaps
//UDCCR
//#define UDCCR_UDE 0 // defined in pxa27x_registers.h , should move all
#define UDCCR_EMCE 3
#define UDCCR_SMAC 4
#define UDCCR_ACN 11
//UDCCSR0
#define UDCCSR0_ACM 9
#define UDCCSR0_AREN 8
#define UDCCSR0_SA 7
#define UDCCSR0_FST 5
#define UDCCSR0_DME 3
#define UDCCSR0_FTF 2
#define UDCCSR0_IPR 1
#define UDCCSR0_OPC 0
//UDCCSRAX
#define UDCCSRAX_DPE 9
#define UDCCSRAX_FEF 8
#define UDCCSRAX_SP 7
#define UDCCSRAX_BNEBNF 6
#define UDCCSRAX_FST 5
#define UDCCSRAX_SST 4
#define UDCCSRAX_DME 3
#define UDCCSRAX_TRN 2
#define UDCCSRAX_PC 1
#define UDCCSRAX_FS 0
//UDCCRAX
#define UDCCRAX_CN 25
#define UDCCRAX_IN 22
#define UDCCRAX_AISN 19
#define UDCCRAX_EN 15
#define UDCCRAX_ET 13
#define UDCCRAX_ED 12
#define UDCCRAX_MPS 2
#define UDCCRAX_DE 1
#define UDCCRAX_EE 0
//Interrupts
#define INT_IRCC 31 // SET_CONFIGURATION or SET_INTERRUPT command received
#define INT_IRSOF 30 // Start-of-frame received
#define INT_IRRU 29 // Resume detected
#define INT_IRSU 28 // Suspend detected
#define INT_IRRS 27 // USB reset detected
#define INT_END0 0 //Endpoint 0 packet complete bit
#define INT_ENDA 2 //Endpoint A packet complete bit
#define INT_ENDB 4 //Endpoint B packet complete bit
// USB control Setup request, Standard
#define USB_GETDESCRIPTOR 0x06
#define USB_SETCONFIGURATION 0x09
// USB control Setup request, Hid
#define USB_HID_GETREPORT 0x01
#define USB_HID_GETIDLE 0x02
#define USB_HID_GETPROTOCOL 0x03
#define USB_HID_SETREPORT 0x09
#define USB_HID_SETIDLE 0x0A
#define USB_HID_SETPROTOCOL 0x0B
// USB Descriptors
#define USB_DESCRIPTOR_DEVICE 0x01
#define USB_DESCRIPTOR_CONFIGURATION 0x02
#define USB_DESCRIPTOR_STRING 0x03
#define USB_DESCRIPTOR_INTERFACE 0x04
#define USB_DESCRIPTOR_ENDPOINT 0x05
#define USB_DESCRIPTOR_DEVICE_QUALIFIER 0x06
#define USB_DESCRIPTOR_OTHER_SPEED_CONFIG 0x07
#define USB_DESCRIPTOR_INTERFACE_POWER 0x08
#define USB_DESCRIPTOR_HID 0x21
#define USB_DESCRIPTOR_HID_REPORT 0x22
//Sending Data states, defined as bit flags
#define INPROGRESS 0
#define MIDSEND 1
//States, defined as full numbers, not flags
//0 is nothing
#define POWERED 1 //means attached and powered by the USB host
#define DEFAULT 2 //finished resetting
#define CONFIGURED 3 //ready to be used for communication
#define isFlagged(_BITFIELD, _FLAG) (((_BITFIELD) & (_FLAG)) != 0)
#define getByte(_WORD, _BYTE) ((((_WORD) >> (((_BYTE) & 0x03) * 8))) & 0xFF)
#define getBit(_BITFIELD, _BIT) (((_BITFIELD) >> ((_BIT) & 0x1F)) & 0x01)
#define STRINGS_USED 3
//Interfaces used
#define SENDVARLENPACKET 0
#define SENDJTPACKET 1
#define SENDBAREMSG 2
#define USBC_GPIOX_EN 88
#define USBC_GPION_DET 13
/**
* JT protocol numbers; NOTE: some of the constants
* are different between the client (mote) and host (pc) software (namely,
* the byte positions)
*/
#define IMOTE_HID_REPORT 1
#define IMOTE_HID_TYPE_COUNT 4
//Imote2 HID report, byte positions
#define IMOTE_HID_TYPE 0
#define IMOTE_HID_NI 1
//Imote2 HID report, type byte, bit positions
#define IMOTE_HID_TYPE_CL 0
#define IMOTE_HID_TYPE_L 2
#define IMOTE_HID_TYPE_H 4
#define IMOTE_HID_TYPE_MSC 5
//Imote2 HID report, type byte, L defintions
#define IMOTE_HID_TYPE_L_BYTE 0
#define IMOTE_HID_TYPE_L_SHORT 1
#define IMOTE_HID_TYPE_L_INT 2
//Imote2 HID report, Length sizes
//The JTProtocol determines the number of USB
//packets to be transmitted by the length of the
//buffer, every packet is then attached with a sequence
//number. If the length of the buffer is less than
//15871 (256 * IMOTE_HID_BYTE_MAXPACKETDATA) then
//basically we will be ok with a byte for the sequence.
#define IMOTE_HID_TYPE_L_BYTE_SIZE 15871
#define IMOTE_HID_TYPE_L_SHORT_SIZE 3997695
#define IMOTE_HID_TYPE_L_INT_SIZE 0xFFFFFFFF
//Imote2 HID report, type byte, CL defintions
#define IMOTE_HID_TYPE_CL_GENERAL 0
#define IMOTE_HID_TYPE_CL_BINARY 1
#define IMOTE_HID_TYPE_CL_RPACKET 2
#define IMOTE_HID_TYPE_CL_BLUSH 3
//Imote2 HID report, type byte, MSC definitions
#define IMOTE_HID_TYPE_MSC_DEFAULT 0
#define IMOTE_HID_TYPE_MSC_BLOADER 1
/**
* The types used by the boot loader extending
* JT Protocol messages.
* FIXME Currently the driver will not push the
* MSC types to the right bits, so its easier to
* set the right bits to start with.
* NOTE this value is not the same in PC App but the
* result is the same.
*/
#define IMOTE_HID_TYPE_MSC_REBOOT 64
#define IMOTE_HID_TYPE_MSC_COMMAND 96
#define IMOTE_HID_TYPE_MSC_BINARY 128
#define IMOTE_HID_TYPE_MSC_ERROR 160
//Imote2 HID report, max packet data sizes
#define IMOTE_HID_BYTE_MAXPACKETDATA 62
#define IMOTE_HID_SHORT_MAXPACKETDATA 61
#define IMOTE_HID_INT_MAXPACKETDATA 59
#endif
--- NEW FILE: PXA27XUSBdata.h ---
/* tab:4
* "Copyright (c) 2000-2003 The Regents of the University of California.
* All rights reserved.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose, without fee, and without written agreement is
* hereby granted, provided that the above copyright notice, the following
* two paragraphs and the author appear in all copies of this software.
*
* IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
* OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
* CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
* ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
*
* Copyright (c) 2002-2003 Intel Corporation
* All rights reserved.
*
* This file is distributed under the terms in the attached INTEL-LICENSE
* file. If you do not find these files, copies can be found by writing to
* Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
* 94704. Attention: Intel License Inquiry.
*/
/*
* @file: PXA27XUSBdata.h
* @author: Josh Herbach
* Revision: 1.0
* Date: 09/02/2005
*/
#ifndef __PXA27XUSBDATA_H
#define __PXA27XUSBDATA_H
#include <types.h>
typedef struct __USBdata
{
volatile unsigned long *endpointDR;
uint32_t fifosize;
uint8_t *src;
uint32_t len;
uint32_t tlen;
uint32_t index;
uint32_t pindex;
uint32_t n;
uint16_t status;
uint8_t type;
uint8_t source;
uint8_t *param;
} USBdata_t;
typedef USBdata_t * USBdata;
union string_or_langid
{
uint16_t wLANGID;
char *bString;
};
typedef struct __hid
{
uint16_t bcdHID;
uint16_t wDescriptorLength;
uint8_t bCountryCode;
uint8_t bNumDescriptors;
uint8_t bDescriptorType;
} USBhid;
typedef struct __hidreport
{
uint16_t wLength;
uint8_t *bString;
} USBhidReport;
typedef struct __string
{
uint8_t bLength;
union string_or_langid uMisc;
} __string_t;
typedef __string_t *USBstring;
typedef struct __endpoint
{
uint8_t bEndpointAddress;
uint8_t bmAttributes;
uint16_t wMaxPacketSize;
uint8_t bInterval;
} __endpoint_t;
typedef __endpoint_t *USBendpoint;
typedef struct __interface
{
uint8_t bInterfaceID;
uint8_t bAlternateSetting;
uint8_t bNumEndpoints;
uint8_t bInterfaceClass;
uint8_t bInterfaceSubclass;
uint8_t bInterfaceProtocol;
uint8_t iInterface;
USBendpoint *oEndpoints;
} __interface_t;
typedef __interface_t *USBinterface;
typedef struct __configuration
{
uint16_t wTotalLength;
uint8_t bNumInterfaces;
uint8_t bConfigurationID;
uint8_t iConfiguration;
uint8_t bmAttributes;
uint8_t MaxPower;
USBinterface *oInterfaces;
} __configuration_t;
typedef __configuration_t *USBconfiguration;
typedef struct __device
{
uint16_t bcdUSB;
uint8_t bDeviceClass;
uint8_t bDeviceSubclass;
uint8_t bDeviceProtocol;
uint8_t bMaxPacketSize0;
uint16_t idVendor;
uint16_t idProduct;
uint16_t bcdDevice;
uint8_t iManufacturer;
uint8_t iProduct;
uint8_t iSerialNumber;
uint8_t bNumConfigurations;
USBconfiguration *oConfigurations;
} USBdevice;
#endif
--- NEW FILE: PXA27Xdynqueue.h ---
/* tab:4
* "Copyright (c) 2000-2003 The Regents of the University of California.
* All rights reserved.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose, without fee, and without written agreement is
* hereby granted, provided that the above copyright notice, the following
* two paragraphs and the author appear in all copies of this software.
*
* IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
* OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
* CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
* ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
*
* Copyright (c) 2002-2003 Intel Corporation
* All rights reserved.
*
* This file is distributed under the terms in the attached INTEL-LICENSE
* file. If you do not find these files, copies can be found by writing to
* Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
* 94704. Attention: Intel License Inquiry.
*/
/**
* @file PXA27Xdynqueue.h
* @author Josh Herbach
* Revision 1.0
* Date 09/02/2005
*/
/*------------------------------------------------------------------*/
/* dynqueue.h */
/*------------------------------------------------------------------*/
#ifndef __PXA27Xdynqueue_H__
#define __PXA27Xdynqueue_H__
#include <stdlib.h>
#include <string.h>
typedef struct DynQueue_T *DynQueue;
/* A DynQueue is an fifo queue whose length can expand dynamically. */
DynQueue DynQueue_new();
/* Return a new DynQueue. */
void DynQueue_free(DynQueue oDynQueue);
/* Free oDynQueue. */
int DynQueue_getLength(DynQueue oDynQueue);
/* Return the length of oDynQueue.*/
void *DynQueue_dequeue(DynQueue oDynQueue);
/* Dequeues the first element of oDynQueue.*/
void DynQueue_enqueue(DynQueue oDynQueue, const void *pvItem);
/* Adds pvItem to oDynQueue.*/
void *DynQueue_peek(DynQueue oDynQueue);
/* Returns the first element of oDynQueue without removing it.*/
void DynQueue_push(DynQueue oDynQueue, const void *pvItem);
/* Puts an item at the head of oDynQueue the queue.*/
#endif
--- NEW FILE: TOSSched.h ---
/* tab:4
* "Copyright (c) 2000-2003 The Regents of the University of California.
* All rights reserved.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose, without fee, and without written agreement is
* hereby granted, provided that the above copyright notice, the following
* two paragraphs and the author appear in all copies of this software.
*
* IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
* OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
* CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
* ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
*
* Copyright (c) 2002-2003 Intel Corporation
* All rights reserved.
*
* This file is distributed under the terms in the attached INTEL-LICENSE
* file. If you do not find these files, copies can be found by writing to
* Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
* 94704. Attention: Intel License Inquiry.
*/
/**
* @file Sched.h
*
* Defines for posting a task.
*/
#ifndef SCHED_H
#define SCHED_H
typedef struct {
void (*tp) ();
} TOSH_sched_entry_T;
enum {
TOSH_MAX_TASKS = 8,
TOSH_TASK_BITMASK = (TOSH_MAX_TASKS - 1)
};
void TOSH_sched_init(void);
bool TOS_post(void (*tp) ());
void