#include "FeedbackSensor.h"


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 __SENSORONLYMODE_H__ 1 |
Definition at line 2 of file SensorOnlyMode.h.
| #define BAUD 1000000 |
| #define BROADCAST_ID 0xFE |
| #define cbi | ( | REG, | |||
| BITNUM | ) | REG &= ~(_BV(BITNUM)) |
Definition at line 13 of file SensorOnlyMode.h.
| #define CHECK_TXD_FINISH bit_is_set(UCSRA,TXC) |
| #define E_ANGLE_LIMIT 2 |
Definition at line 25 of file SensorOnlyMode.h.
| #define E_CHECKSUM 16 |
| #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 | ) | (w&0x80000000?(byte)(w >> 8)|(0x8000):(byte)(w >> 8)) |
| #define init | ( | sb | ) | (sb.readPtr = sb.writePtr = 0) |
| #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 |
| #define INST_READ 0x02 |
| #define INST_REG_WRITE 0x04 |
Definition at line 36 of file SensorOnlyMode.h.
| #define INST_RESET 0x06 |
| #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) |
| #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 |
| #define MAX_PARAM 8 |
Definition at line 6 of file SensorOnlyMode.h.
| #define NO_ERROR 0 |
| #define P_DIST 1 |
| #define pop | ( | sb | ) | (sb.buffer[ sb.readPtr++ ]) |
| #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 |
| #define RESET_TXD_FINISH cbi(UCSRA,TXC) |
Definition at line 114 of file SensorOnlyMode.h.
| #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) |
| #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 |
| #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 |
| typedef unsigned char byte |
Definition at line 48 of file SensorOnlyMode.h.
| 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 }

1.5.5