Code: Select all
https://hackaday.io/project/3878-digital-holga
However, in the meantime, there is an 'initial' point on which 'conceptually', I am a little bit stuck. So the 'gist' of the question/description below is that I 'get' hardware registers when they are 'on-chip', like on a PIC or an Uno or something... But when they are 'off chip', on a peripheral... ? Just how do you talk/address them ?
I'm not sure if the suggested 'procedure' I have laid out is at least 'somewhat' conceptually correct? Or if not, I think I would be just banging my head against a wall for a long time (as a mistaken register or 'code on a processor' will typically spit out an error, either at compile or run-time... But a 'distant peripheral', will 'just sit there' staring back at you on the desk, frustratingly mute and not doing what you want).
I am trying to work on an open-source project using the Teensy 3.1 and the Micron Mt9d111 imaging module. Completed, I hope this will be a resource to the Teensy community especially as I have not seen many camera adaptations for the Teensy, though it is definitely the right speed/size and thus much more appropriate than the Arduino..
However, there are a few points from the datasheet I am slightly uncertain as to how to address.
For one, general communication and control to the module is established via I2C.
From the datasheet, an example of a 16-bit hardware register read:
Example: 16-Bit Register Read
This is an example of a 16-bit register read from Chip Version register (R0x00:0),
expected value = 0x1519
1. Send Start
2. Send Device Address
a. 0xBA
3. Wait for ack
4. Send register address (8-bit)
a. 0x00
5. Wait for ack
6. Send Stop
7. Send Start
8. Send device address for read
a. 0xBB
9. Wait for ack
10. Slave device sends 8-bit data (MSB byte)
a. 0x15
11. Master send ack
12. Slave device sends another 8-bit data (LSB byte)
a. 0x19
13. Master send nack
14. Send Stop
Using the 'Wire' library to start (I understand there is an 'enhanced' I2C library, but I just want to get the basics down first), I believe this would be accomplished by the following:
Wire.beginTransmission(0xBA)
Wire.send(0x00)
Wire.beginTransmission(0xBB)
Wire.requestFrom(0x15, 1)
Wire.requestFrom(0x19, 1)
[or, would the last two lines instead be just the following:]
Wire.receive()
Wire.receive()
?
The one other question I had is that sometimes the hardware registers on the module are listed not just as '0xBA', say, but rather something like, just as a randomly selected example, "R198:1[7:0]". It is the ":1[7:0]" part I don't quite get. Or if I was looking at Verilog I would think it might be describing some sort of port or something, but obviously this is communication over two wire serial... So I am not quite sure I understand that part, or what it is referencing.
In any case, any help would be appreciated, and in the end I look forward to 'giving back'.
Best,
- Anthony