SensorOnlyMode.h File Reference

#include "FeedbackSensor.h"

Include dependency graph for SensorOnlyMode.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  Packet
struct  Smartbuffer
struct  Statemachine

Defines

#define __SENSORONLYMODE_H__   1
#define BAUD   1000000
#define BROADCAST_ID   0xFE
#define cbi(REG, BITNUM)   REG &= ~(_BV(BITNUM))
#define CHECK_TXD_FINISH   bit_is_set(UCSRA,TXC)
#define E_ANGLE_LIMIT   2
#define E_CHECKSUM   16
#define E_INPUT_VOLTAGE   1
#define E_INSTRUCTION   64
#define E_OVERHEATING   4
#define E_OVERLOAD   32
#define E_RANGE   8
#define ENABLE_BIT_DEFINITIONS
#define highbyte_s(w)   (w&0x80000000?(byte)(w >> 8)|(0x8000):(byte)(w >> 8))
#define init(sb)   (sb.readPtr = sb.writePtr = 0)
#define INST_ACTION   0x05
#define INST_DIGITAL_RESET   0x07
#define INST_PING   0x01
#define INST_READ   0x02
#define INST_REG_WRITE   0x04
#define INST_RESET   0x06
#define INST_SYNC_REG_WRITE   0x84
#define INST_SYNC_WRITE   0x83
#define INST_SYSTEM_READ   0x0C
#define INST_SYSTEM_WRITE   0x0D
#define INST_WRITE   0x03
#define isEmpty(sb)   (sb.writePtr == sb.readPtr)
#define len(sb)   ( sb.readPtr > sb.writePtr ? (sb.writePtr - sb.readPtr + 256) : (sb.writePtr - sb.readPtr) )
#define MAX_PACKELEN   MAX_PARAM+4
#define MAX_PARAM   8
#define NO_ERROR   0
#define P_DIST   1
#define pop(sb)   (sb.buffer[ sb.readPtr++ ])
#define push(sb, value)   (sb.buffer[ sb.writePtr++ ] = value)
#define READDIST_X   TCNT0
#define READDIST_Y   TCNT1
#define RESET_MOUSE   TCNT0 = TCNT1 = 0
#define RESET_SENSOR   RESET_WHEEL
#define RESET_TXD_FINISH   cbi(UCSRA,TXC)
#define RESET_WHEEL   wheel1 = wheel2 = 0
#define RS485_RXD   sbi(PORTD, PD6), cbi(PORTD, PD5), sbi(UCSRB,RXCIE)
#define RS485_TXD   sbi(PORTD, PD5), cbi(PORTD, PD6), cbi(UCSRB,RXCIE)
#define RXD_DATA   UDR
#define sbi(REG, BITNUM)   REG |= _BV(BITNUM)
#define SELF_ID   200
#define SET_TXD_FINISH   sbi(UCSRA,TXC)
#define STATE_1ST_FF_RCVD   1
#define STATE_2ND_FF_RCVD   2
#define STATE_COMMAND_RCVD   5
#define STATE_ID_RCVD   3
#define STATE_IDLE   0
#define STATE_LENGTH_RCVD   4
#define STATE_PKT_COMPLETE   6
#define TXD_DATA   UDR
#define TXD_READY   bit_is_set(UCSRA,UDRE)
#define WORD_MAX_SIZE   32767
#define WORD_MIN_SIZE   -32767
#define XTAL   16000000

Typedefs

typedef unsigned char byte

Functions

int sensorMain (void)


Define Documentation

#define __SENSORONLYMODE_H__   1

Definition at line 2 of file SensorOnlyMode.h.

#define BAUD   1000000

Definition at line 131 of file SensorOnlyMode.h.

Referenced by initAtmega().

#define BROADCAST_ID   0xFE

Definition at line 8 of file SensorOnlyMode.h.

Referenced by stm_process().

#define cbi ( REG,
BITNUM   )     REG &= ~(_BV(BITNUM))

Definition at line 13 of file SensorOnlyMode.h.

#define CHECK_TXD_FINISH   bit_is_set(UCSRA,TXC)

Definition at line 115 of file SensorOnlyMode.h.

Referenced by TxPacket().

#define E_ANGLE_LIMIT   2

Definition at line 25 of file SensorOnlyMode.h.

#define E_CHECKSUM   16

Definition at line 28 of file SensorOnlyMode.h.

Referenced by callback().

#define E_INPUT_VOLTAGE   1

Definition at line 24 of file SensorOnlyMode.h.

#define E_INSTRUCTION   64

Definition at line 30 of file SensorOnlyMode.h.

#define E_OVERHEATING   4

Definition at line 26 of file SensorOnlyMode.h.

#define E_OVERLOAD   32

Definition at line 29 of file SensorOnlyMode.h.

#define E_RANGE   8

Definition at line 27 of file SensorOnlyMode.h.

#define ENABLE_BIT_DEFINITIONS

Definition at line 12 of file SensorOnlyMode.h.

#define highbyte_s (  )     (w&0x80000000?(byte)(w >> 8)|(0x8000):(byte)(w >> 8))

Definition at line 20 of file SensorOnlyMode.h.

Referenced by callback().

#define init ( sb   )     (sb.readPtr = sb.writePtr = 0)

Definition at line 91 of file SensorOnlyMode.h.

Referenced by sensorMain().

#define INST_ACTION   0x05

Definition at line 37 of file SensorOnlyMode.h.

#define INST_DIGITAL_RESET   0x07

Definition at line 39 of file SensorOnlyMode.h.

#define INST_PING   0x01

Definition at line 33 of file SensorOnlyMode.h.

Referenced by callback().

#define INST_READ   0x02

Definition at line 34 of file SensorOnlyMode.h.

Referenced by callback().

#define INST_REG_WRITE   0x04

Definition at line 36 of file SensorOnlyMode.h.

#define INST_RESET   0x06

Definition at line 38 of file SensorOnlyMode.h.

Referenced by callback().

#define INST_SYNC_REG_WRITE   0x84

Definition at line 43 of file SensorOnlyMode.h.

#define INST_SYNC_WRITE   0x83

Definition at line 42 of file SensorOnlyMode.h.

#define INST_SYSTEM_READ   0x0C

Definition at line 40 of file SensorOnlyMode.h.

#define INST_SYSTEM_WRITE   0x0D

Definition at line 41 of file SensorOnlyMode.h.

#define INST_WRITE   0x03

Definition at line 35 of file SensorOnlyMode.h.

#define isEmpty ( sb   )     (sb.writePtr == sb.readPtr)

Definition at line 92 of file SensorOnlyMode.h.

Referenced by sensorMain().

#define len ( sb   )     ( sb.readPtr > sb.writePtr ? (sb.writePtr - sb.readPtr + 256) : (sb.writePtr - sb.readPtr) )

Definition at line 95 of file SensorOnlyMode.h.

#define MAX_PACKELEN   MAX_PARAM+4

Definition at line 7 of file SensorOnlyMode.h.

Referenced by stm_process(), and TxPacket().

#define MAX_PARAM   8

Definition at line 6 of file SensorOnlyMode.h.

#define NO_ERROR   0

Definition at line 23 of file SensorOnlyMode.h.

Referenced by callback().

#define P_DIST   1

Definition at line 46 of file SensorOnlyMode.h.

Referenced by callback().

#define pop ( sb   )     (sb.buffer[ sb.readPtr++ ])

Definition at line 94 of file SensorOnlyMode.h.

Referenced by sensorMain().

#define push ( sb,
value   )     (sb.buffer[ sb.writePtr++ ] = value)

Definition at line 93 of file SensorOnlyMode.h.

#define READDIST_X   TCNT0

Definition at line 121 of file SensorOnlyMode.h.

#define READDIST_Y   TCNT1

Definition at line 122 of file SensorOnlyMode.h.

#define RESET_MOUSE   TCNT0 = TCNT1 = 0

Definition at line 123 of file SensorOnlyMode.h.

#define RESET_SENSOR   RESET_WHEEL

Definition at line 125 of file SensorOnlyMode.h.

Referenced by sensorMain().

#define RESET_TXD_FINISH   cbi(UCSRA,TXC)

Definition at line 114 of file SensorOnlyMode.h.

#define RESET_WHEEL   wheel1 = wheel2 = 0

Definition at line 124 of file SensorOnlyMode.h.

Referenced by callback().

#define RS485_RXD   sbi(PORTD, PD6), cbi(PORTD, PD5), sbi(UCSRB,RXCIE)

Definition at line 111 of file SensorOnlyMode.h.

Referenced by initAtmega(), sensorMain(), and TxPacket().

#define RS485_TXD   sbi(PORTD, PD5), cbi(PORTD, PD6), cbi(UCSRB,RXCIE)

Definition at line 110 of file SensorOnlyMode.h.

Referenced by TxPacket().

#define RXD_DATA   UDR

Definition at line 119 of file SensorOnlyMode.h.

#define sbi ( REG,
BITNUM   )     REG |= _BV(BITNUM)

Definition at line 14 of file SensorOnlyMode.h.

#define SELF_ID   200

Definition at line 9 of file SensorOnlyMode.h.

Referenced by sensorMain(), and TxPacket().

#define SET_TXD_FINISH   sbi(UCSRA,TXC)

Definition at line 113 of file SensorOnlyMode.h.

Referenced by TxPacket().

#define STATE_1ST_FF_RCVD   1

Definition at line 69 of file SensorOnlyMode.h.

Referenced by stm_process().

#define STATE_2ND_FF_RCVD   2

Definition at line 70 of file SensorOnlyMode.h.

Referenced by stm_process().

#define STATE_COMMAND_RCVD   5

Definition at line 73 of file SensorOnlyMode.h.

Referenced by stm_process().

#define STATE_ID_RCVD   3

Definition at line 71 of file SensorOnlyMode.h.

Referenced by stm_process().

#define STATE_IDLE   0

Definition at line 68 of file SensorOnlyMode.h.

Referenced by stm_init(), and stm_process().

#define STATE_LENGTH_RCVD   4

Definition at line 72 of file SensorOnlyMode.h.

Referenced by stm_process().

#define STATE_PKT_COMPLETE   6

Definition at line 74 of file SensorOnlyMode.h.

Referenced by stm_process().

#define TXD_DATA   UDR

Definition at line 118 of file SensorOnlyMode.h.

Referenced by TxD().

#define TXD_READY   bit_is_set(UCSRA,UDRE)

Definition at line 117 of file SensorOnlyMode.h.

Referenced by TxD().

#define WORD_MAX_SIZE   32767

Definition at line 16 of file SensorOnlyMode.h.

Referenced by callback().

#define WORD_MIN_SIZE   -32767

Definition at line 17 of file SensorOnlyMode.h.

Referenced by callback().

#define XTAL   16000000

Definition at line 130 of file SensorOnlyMode.h.

Referenced by initAtmega().


Typedef Documentation

typedef unsigned char byte

Definition at line 48 of file SensorOnlyMode.h.


Function Documentation

int sensorMain ( void   ) 

Definition at line 115 of file SensorOnlyMode.c.

References callback(), init, initAtmega(), isEmpty, pop, RESET_SENSOR, RS485_RXD, SELF_ID, stm_init(), and stm_process().

Referenced by main().

00116 {
00117 
00118   Statemachine stm;
00119   stm_init(&stm, SELF_ID, &callback);
00120   RESET_SENSOR;
00121   init(interruptbuff);
00122   initAtmega();
00123   
00124   RS485_RXD;
00125   for(;;){
00126      if( !isEmpty(interruptbuff) ){
00127      stm_process(&stm, pop(interruptbuff) );
00128     }  
00129   }
00130 }

Here is the call graph for this function:


Generated on Wed Nov 25 11:27:43 2009 for Crawling Robot Microcontroller Software by  doxygen 1.5.5