Low Speed module
[NXT Firmware Modules]

Constants and functions related to the Low Speed module. More...

Modules

 LowSpeed module functions
 

Functions for accessing and modifying low speed module features.


 LowSpeed module constants
 

Constants that are part of the NXT firmware's LowSpeed module.



Detailed Description

Constants and functions related to the Low Speed module.

The NXT low speed module encompasses support for digital I2C sensor communication.

Use the lowspeed (aka I2C) communication methods to access devices that use the I2C protocol on the NXT brick's four input ports.

You must set the input port's TypeField property to IN_TYPE_LOWSPEED or IN_TYPE_LOWSPEED_9V on a given port before using an I2C device on that port. Use IN_TYPE_LOWSPEED_9V if your device requires 9V power from the NXT brick. Remember that you also need to set the input port's InvalidDataField property to true after setting a new TypeField, and then wait in a loop for the NXT firmware to set InvalidDataField back to false. This process ensures that the firmware has time to properly initialize the port, including the 9V power lines, if applicable. Some digital devices might need additional time to initialize after power up.

The SetSensorLowspeed API function sets the specified port to IN_TYPE_LOWSPEED_9V and calls ResetSensor to perform the InvalidDataField reset loop described above.

When communicating with I2C devices, the NXT firmware uses a master/slave setup in which the NXT brick is always the master device. This means that the firmware is responsible for controlling the write and read operations. The NXT firmware maintains write and read buffers for each port, and the three main Lowspeed (I2C) methods described below enable you to access these buffers.

A call to LowspeedWrite starts an asynchronous transaction between the NXT brick and a digital I2C device. The program continues to run while the firmware manages sending bytes from the write buffer and reading the response bytes from the device. Because the NXT is the master device, you must also specify the number of bytes to expect from the device in response to each write operation. You can exchange up to 16 bytes in each direction per transaction.

After you start a write transaction with LowspeedWrite, use LowspeedStatus in a loop to check the status of the port. If LowspeedStatus returns a status code of 0 and a count of bytes available in the read buffer, the system is ready for you to use LowspeedRead to copy the data from the read buffer into the buffer you provide.

Note that any of these calls might return various status codes at any time. A status code of 0 means the port is idle and the last transaction (if any) did not result in any errors. Negative status codes and the positive status code 32 indicate errors. There are a few possible errors per call.

Valid low speed return values include NO_ERR as well as the error codes listed in the Communications specific errors section.


Generated by  doxygen 1.6.2