/***************************************************************************** Module Name: MB.h Purpose: Header file for Mailbox RAM. Defines the Mailbox array, initialization and local uC access routines required for the Mailbox system. RAM can be accessed by local uC and external uC's and PCs depending on interface drivers included. The Mailbox array is defined as an array of unsigned char. The macros defined below allow the user to retrieve different variable types that are stored in the Mailbox character array. Multibyte variables are stored in Big Endian format (LSByte at losest address). Created by: Don Carveth don@botgoodies.com www.botgoodies.com Copyright(c) 2002 Don Carveth This software is provided as freeware for non-commercial use. Please contact the author for permission to use this software in a commercial application. This software may be freely distributed and modified as long as the copyright notice, this notice and all disclaimers remain in place. This software is provided by the copyright holder "As Is" and any express or implied warranties, including, but not limited to, the implied warranties or merchantability and fitness for a particular purpose are disclaimed. In no event shall the copyright owner 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. Rev. History: Rev. 1.0 Dec. 29, 2002 Initial release *****************************************************************************/ #define MB_HEADER 1 //--------------------- Function Prototypes extern void InitializeMailbox(void); //----------------------------- Defines // Set size of Mailbox Array - max 255 #define MAIL_ARRAY_ELEMENTS 255 // Direct to Mailbox RAM access macros for 1 byte variables #define MB1(addr) Mailbox[addr] #define MB1S(addr) *(CHARS*)(&Mailbox[addr]) // You must disable global interrupts before and re-enable after // any multibyte Mailbox access to prevent data corruption #define MB2(addr) *(INT16S*)(&Mailbox[addr]) #define MB2U(addr) *(INT16U*)(&Mailbox[addr]) #define MB4(addr) *(INT32S*)(&Mailbox[addr]) #define MB4U(addr) *(INT32U*)(&Mailbox[addr]) #define MBF(addr) *(FP32*)(&Mailbox[addr]) #define MBD(addr) *(FP64*)(&Mailbox[addr]) // Add your own definitions here - any fixed length data type can be specified //--------------------- Mailbox Array Setup volatile CHARU Mailbox[MAIL_ARRAY_ELEMENTS]; // Main Mailbox Array // Mailbox Assignments for this test program #define mbLC MB2(100) #define mbSC MB2(102) #define mbMaxRLatency MB1(104) #define mbMaxWLatency MB1(105) // Following included as sample only - delete and add your own #defines // Predefined Mailbox locations - set up as many as needed // Be sure to consider variable length when assigning addresses //Mailbox Config / Testing #define mbTCNT0_ENABLE MB1(3) #define mbTIMEOUT_SETTING MB2(4) #define mbRFLED_PERIOD MB2(6) #define mbSENDMBDAT_ENABLED MB1(8) #define mbSENDMB_PERIOD MB2(9) #define mbTEST_INT MB2(11) #define mbTIMEOUT MB1(13) //Robot Configuration #define mbSTALL_AMPS MB2(20) #define mbV13_MIN MB1(22) #define mbSENSORS_CONFIG MB1(23) #define mbSCAN_TIME MB2(24) #define mbDEFAULT_BEHAVE MB1(26) // From BotFront ****** #define mbFRONT_DISTANCE MB2(30) #define mbSONAR_DISTANCE MB2(32) #define mbIR_DISTANCE MB2(34) //mbOBJECTS = pack(d, d, d, d, d, d, stairs, ObjFront); #define mbOBJECTS MB1(36) #define mbSTAIRS_DET MB2(37) #define mbS_DISTANCE MB1(39) // ****** //From Sensors #define mbAMPSL MB2(56) #define mbAMPSR MB2(58) #define mbV13 MB2(60) #define mbCOMPASS1 MB2(62) #define mbCOMPASS2 MB2(64) #define mbNOT_MOVE_COUNT MB2(66) #define mbL_CLICKS MB2(68) #define mbR_CLICKS MB2(70) #define mbDISTANCE MB2(72) #define mbL_DIST MB2(74) #define mbR_DIST MB2(76) #define mbTHETA MB2(78) #define mbTHETAX MB2(80) #define mbHEADING MB2(82) #define mbCOMPASS_HEADING MB2(84) #define mbX_POS MB2(86) #define mbY_POS MB2(88) //From Actions #define mbL_VELTARGET MB1(120) #define mbR_VELTARGET MB1(121) #define mbL_POWER MB1(122) #define mbR_POWER MB1(123) #define mbL_ERR MB2(124) #define mbR_ERR MB2(126) #define mbREQ_ACTION MB1(128) //From Bot3 Main #define mbMILLISECS MB1(160) #define mbSECS MB1(161) #define mbMINUTES MB1(162) #define mbHOURS MB1(163) #define mbFREE_MILLISECS16 MB2(164) #define mbLOOP_TIME MB2(166) //From Behave #define mbGO_MODE MB1(180) #define mbGO_STEP MB1(181) #define mbL_OR_RIGHT MB1(182) // Status Discretes #define mbACTIONS_DISCRETES MB1(200) //mbACTIONS_DISCRETES = pack(ldir, rdir, LorR,d,d,d,d,d); #define mbSENSOR_DISCRETES MB1(202) //mbSENSOR_DISCRETES = pack(amps_stall, v13low, amps_screwedup, // Stuck,WheelsTurningNotMoving,stairs, // NotMoving ,d);