Commonly used functions used by drivers.
More...
#include "firmwareVersion.h"
Go to the source code of this file.
Defines |
#define | __COMMON_H_SENSOR_CHECK__ 1 |
#define | MAX_ARR_SIZE 17 |
#define | min2(a, b) (a < b ? a : b) |
#define | min3(a, b, c) (a < b) ? ((a < c) ? a : c) : ((b < c) ? b : c) |
#define | max2(a, b) (a > b ? a : b) |
#define | max3(a, b, c) (a > b) ? ((a > c) ? a : c) : ((b > c) ? b : c) |
#define | clip(a, b, c) min2(c, max2(b, a)) |
#define | STRTOK_MAX_TOKEN_SIZE 20 |
#define | STRTOK_MAX_BUFFER_SIZE 50 |
Typedefs |
typedef ubyte | tByteArray [MAX_ARR_SIZE] |
typedef sbyte | tsByteArray [MAX_ARR_SIZE] |
typedef ubyte | tMassiveArray [128] |
typedef ubyte | tHugeByteArray [64] |
typedef ubyte | tBigByteArray [32] |
typedef ubyte | tIPaddr [4] |
typedef int | tIntArray [MAX_ARR_SIZE] |
Functions |
void | clearI2CError (tSensors link, ubyte address) |
void | clearI2Cbus (tSensors link) |
bool | waitForI2CBus (tSensors link) |
bool | writeI2C (tSensors link, tByteArray &request, tByteArray &reply, int replylen) |
bool | writeI2C (tSensors link, tByteArray &request) |
long | getUID () |
bool | strtok (char *buffer, char *token, char *seperator) |
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:
- 0.1: Initial release
- 0.2: Added version check to issue error when compiling with RobotC < 1.46
- 0.2: Added __COMMON_H_DEBUG__ to enable/disable sounds when an I2C error occurs
- 0.2: Removed bool waitForI2CBus(tSensors link, bool silent)
- 0.3: clearI2CError() added to make writeI2C more robust, I2C bus errors are now handled better.
- 0.4: Added HiTechnic SMUX functions
- 0.5: Added clip function (Tom Roach)
- 0.6: clearI2CBus is now conditionally compiled into the FW. Only RobotC < 1.57 needs it.
- 0.7: ubyteToInt(byte byteVal) modified, works better with 1.57+
- 0.8: ubyte used for arrays for firmware version 770 and higher
added support for new colour sensor
added better handling for when sensor is not configured properly
- 0.9: added bool HTSMUXsetMode(tSensors link, byte channel, byte mode) prototype
added int HTSMUXreadAnalogue(tMUXSensor muxsensor)
added HTSMUXSensorType HTSMUXreadSensorType(tMUXSensor muxsensor)
added bool HTSMUXreadPort(tMUXSensor muxsensor, tByteArray &result, int numbytes, int offset)
added bool HTSMUXreadPort(tMUXSensor muxsensor, tByteArray &result, int numbytes)
added bool HTSMUXsetMode(tMUXSensor muxsensor, byte mode)
added bool HTSMUXsetAnalogueActive(tMUXSensor muxsensor)
added bool HTSMUXsetAnalogueInactive(tMUXSensor muxsensor)
corrected function description for HTSMUXSensorType()
- 0.10: Removed unnecessary read from HTSMUXsendCommand()
- 0.11: Added long uByteToLong(byte a1, byte a2, byte a3, byte a4);
- 0.12: Added HTSMUXreadPowerStatus(tSensors link)
Added int round(float fl)
- 0.13: Added motor mux types and data structs
- 0.14: Added check for digital sensors to prevent conflict with built-in drivers
Changed clearI2CError to take ubyte for address, thanks Aswin
- 0.15: Removed motor mux and sensor mux functions and types out
- 0.16: Added max() and min() functions by Mike Henning, Max Bareiss
- Author:
- Xander Soldaat (xander_at_botbench.com)
- Date:
- 27 April 2011
- Version:
- 0.16
Definition in file common.h.