Mindstorms 3rd Party ROBOTC Drivers RobotC
[Home] [Download] [Submit a bug/suggestion] [ROBOTC Forums] [Blog] [Support this project]
Defines | Typedefs | Enumerations | Functions | Variables

hitechnic-sensormux.h File Reference

Commonly used functions used by drivers. More...

#include "common.h"

Go to the source code of this file.

Defines

#define __HTSMUX_SUPPORT__
#define SPORT(X)   (X / 4)
#define MPORT(X)   (X % 4)
#define HTSMUX_I2C_ADDR   0x10
#define HTSMUX_COMMAND   0x20
#define HTSMUX_STATUS   0x21
#define HTSMUX_MODE   0x00
#define HTSMUX_TYPE   0x01
#define HTSMUX_I2C_COUNT   0x02
#define HTSMUX_I2C_DADDR   0x03
#define HTSMUX_I2C_MADDR   0x04
#define HTSMUX_CH_OFFSET   0x22
#define HTSMUX_CH_ENTRY_SIZE   0x05
#define HTSMUX_ANALOG   0x36
#define HTSMUX_AN_ENTRY_SIZE   0x02
#define HTSMUX_I2C_BUF   0x40
#define HTSMUX_BF_ENTRY_SIZE   0x10
#define HTSMUX_CMD_HALT   0x00
#define HTSMUX_CMD_AUTODETECT   0x01
#define HTSMUX_CMD_RUN   0x02
#define HTSMUX_STAT_NORMAL   0x00
#define HTSMUX_STAT_BATT   0x01
#define HTSMUX_STAT_BUSY   0x02
#define HTSMUX_STAT_HALT   0x04
#define HTSMUX_STAT_ERROR   0x08
#define HTSMUX_STAT_NOTHING   0xFF
#define HTSMUX_CHAN_NONE   0x00
#define HTSMUX_CHAN_I2C   0x01
#define HTSMUX_CHAN_9V   0x02
#define HTSMUX_CHAN_DIG0_HIGH   0x04
#define HTSMUX_CHAN_DIG1_HIGH   0x08
#define HTSMUX_CHAN_I2C_SLOW   0x10

Typedefs

typedef ubyte tConfigParams [4]

Enumerations

enum  HTSMUXSensorType {
  HTSMUXAnalogue = 0x00, HTSMUXLegoUS = 0x01, HTSMUXCompass = 0x02, HTSMUXColor = 0x03,
  HTSMUXAccel = 0x04, HTSMUXIRSeeker = 0x05, HTSMUXProto = 0x06, HTSMUXColorNew = 0x07,
  HTSMUXAngle = 0x08, HTSMUXIRSeekerNew = 0x09, HTSMUXSensorCustom = 0x0E, HTSMUXSensorNone = 0x0F
}
enum  tMUXSensor {
  msensor_S1_1 = 0, msensor_S1_2 = 1, msensor_S1_3 = 2, msensor_S1_4 = 3,
  msensor_S2_1 = 4, msensor_S2_2 = 5, msensor_S2_3 = 6, msensor_S2_4 = 7,
  msensor_S3_1 = 8, msensor_S3_2 = 9, msensor_S3_3 = 10, msensor_S3_4 = 11,
  msensor_S4_1 = 12, msensor_S4_2 = 13, msensor_S4_3 = 14, msensor_S4_4 = 15
}

Functions

byte HTSMUXreadStatus (tSensors link)
HTSMUXSensorType HTSMUXreadSensorType (tMUXSensor muxsensor)
bool HTSMUXsendCommand (tSensors link, byte command)
bool HTSMUXreadPort (tMUXSensor muxsensor, tByteArray &result, int numbytes, int offset=0)
bool HTSMUXsetMode (tMUXSensor muxsensor, byte mode)
bool HTSMUXsetAnalogueActive (tMUXSensor muxsensor)
bool HTSMUXsetAnalogueInactive (tMUXSensor muxsensor)
int HTSMUXreadAnalogue (tMUXSensor muxsensor)
bool HTSMUXreadPowerStatus (tSensors link)
bool HTSMUXconfigChannel (tMUXSensor muxsensor, tConfigParams &configparams)
void HTSMUXsensorTypeToString (HTSMUXSensorType muxsensor, string &sensorName)

Variables

ubyte HTSMUXstatus [4] = {HTSMUX_STAT_NOTHING, HTSMUX_STAT_NOTHING, HTSMUX_STAT_NOTHING, HTSMUX_STAT_NOTHING}
HTSMUXSensorType HTSMUXSensorTypes [16]
tByteArray HTSMUX_I2CRequest
tByteArray HTSMUX_I2CReply
tConfigParams Analogue_config = {HTSMUX_CHAN_NONE, 0, 0, 0}

Detailed Description

Commonly used functions used by drivers.

common.h provides a number of frequently used functions that are useful for writing drivers. License: You may use this code as you wish, provided you give credit where its due.

THIS CODE WILL ONLY WORK WITH ROBOTC VERSION 3.59 AND HIGHER.

Changelog:

Author:
Xander Soldaat (xander_at_botbench.com)
Date:
18 January 2011
Version:
0.1

Definition in file hitechnic-sensormux.h.