avsa242 / tmf8828-spin

P8X32A/Propeller, P2X8C4M64P/Propeller 2 driver object for the ams/OSRAM TMF8828 ToF imager
MIT License
1 stars 0 forks source link

Possible to use the C firmware image file from ams? #2

Open avsa242 opened 4 months ago

avsa242 commented 4 months ago

Since FlexSpin allows mixing of spin and C, check to see if the .c image file can be declared as an external object. If it doesn't have any dependencies or other reasons it won't work technically, it'd be a nice feature as it wouldn't be necessary to translate the tmf8828_image.c to the equivalent spin, and it'd be easier for someone to just go to ams' repository and download it.

avsa242 commented 3 months ago

This actually works, if the tmf8828_image.c file is modified slightly:

  1. Remove the PROGMEM keyword from the array definition.
  2. Remove the #include lines.

The image therein can then be used by declaring the .c file as an object and calling the driver's set_fw_image() with a pointer to the array and the size const provided (or specified manually). e.g.,:

obj

    sensor: "sensor.range.tmf8828.spin"
    fw_img: "tmf8828_image.c"

pub main()

    sensor.set_fw_image(@fw_img.tmf8828_image, fw_img.tmf8828_image_length)
avsa242 commented 3 months ago

It seems this doesn't work when building as bytecode. For some reason the address of the firmware image is returned as 0.