by JonHylands » Fri Mar 14, 2008 2:12 pm
by JonHylands
Fri Mar 14, 2008 2:12 pm
If you look at my IMU code, you'll get an example. I'll repost the interesting parts here...
MODEL_NUMBER_LOW 0
MODEL_NUMBER_HIGH 1
FIRMWARE_VERSION 2
ID 3
BAUD_RATE 4
RETURN_DELAY_TIME 5
STATUS_RETURN_LEVEL 16
LED 25
The EEPROM table ends at 23, and the RAM table starts at 24. The entries in the entire control table are stored in RAM while the device is running, but the EEPROM entries are also replicated in EEPROM, so they remain after a power-out.
Anything after the LED entry is fair game for your application, and entries 6-15 and 17-23 are available for stuff that should be stored in EEPROM.
From a command standpoint, you should implement at least:
PING
READ_DATA
WRITE_DATA
RESET
The important thing you have to realize, is that every device gets and has to parse every command. If the ID doesn't match your id, then ignore it. If the ID does match and its a command you don't recognize, ignore it.
To be really useful, you should be able to correctly respond to changes in the following 3 entries:
BAUD_RATE
RETURN_DELAY_TIME
STATUS_RETURN_LEVEL
Of course, you also should handle changing the device ID.
All of my devices work this way, and the framework of code my brother I and have written to support it allows me to build new types of devices without re-writing any of this baseline code.
- Jon
If you look at my IMU code, you'll get an example. I'll repost the interesting parts here...
MODEL_NUMBER_LOW 0
MODEL_NUMBER_HIGH 1
FIRMWARE_VERSION 2
ID 3
BAUD_RATE 4
RETURN_DELAY_TIME 5
STATUS_RETURN_LEVEL 16
LED 25
The EEPROM table ends at 23, and the RAM table starts at 24. The entries in the entire control table are stored in RAM while the device is running, but the EEPROM entries are also replicated in EEPROM, so they remain after a power-out.
Anything after the LED entry is fair game for your application, and entries 6-15 and 17-23 are available for stuff that should be stored in EEPROM.
From a command standpoint, you should implement at least:
PING
READ_DATA
WRITE_DATA
RESET
The important thing you have to realize, is that every device gets and has to parse every command. If the ID doesn't match your id, then ignore it. If the ID does match and its a command you don't recognize, ignore it.
To be really useful, you should be able to correctly respond to changes in the following 3 entries:
BAUD_RATE
RETURN_DELAY_TIME
STATUS_RETURN_LEVEL
Of course, you also should handle changing the device ID.
All of my devices work this way, and the framework of code my brother I and have written to support it allows me to build new types of devices without re-writing any of this baseline code.
- Jon