esp-rs / esp-pacs

Peripheral Access Crates for Espressif SoCs and modules
Apache License 2.0
103 stars 29 forks source link

Registers in the reserved area (temperature sensor in this case) #272

Open cs2dsb opened 3 weeks ago

cs2dsb commented 3 weeks ago

I am interested in trying to get the internal temperature sensor working and was hoping for some insight/guidance on the best way to do this.

It seems like there are extra peripherals/registers in areas of memory documented as RESERVED in the technical reference manuals that are necessary for certain features - the temperature sensor in this case but possibly there are others.

I thought it was best to ask here since the esp-rs book says that this org includes employees from Espressif and I thought they might be able to provide an SVD for the reserved peripherals or suggest a better way than reverse engineering the definitions from the IDF header files.

Failing that, would you accept a patch to add undocumented registers to the SVDs here or would it be better if they were in a separate crate due to them being undocumented? My current plan to get it working as a PoC is just to hand write the peripheral/registerblock/etc. with hard coded addresses from the IDF. Eventually it would be nice to get the peripheral returned as part of the peripherals list from the various PACs.

The trail I followed to work out what was needed to use the temperature sensor was:

  1. temperature_sensor_install
  2. temperature_sensor_power_acquire
  3. regi2c_saradc_enable
  4. regi2c_ctrl_ll_i2c_saradc_enable
  5. ANA_CONFIG_REG 0x6000E044
  6. ANA_CONFIG2_REG 0x6000E048

These registers are in the RESERVED region according to the C3 technical reference manual and aren't in the C3 memory map but one of them IS in the S3 memory map (page 2, top right, ANA_CONFIG_REG).

The general documentation about the temperature sensor is here.

Any input on this would be gratefully received. In the meantime I'll continue hacking away at a messy, unsafe PoC to at least get some readings out to make sure it's working.

jessebraham commented 3 weeks ago

Thanks for opening this issue.

I'm not sure why these registers are not included, I am not familiar with this peripheral. I would be more than happy to accept a PR adding them however, otherwise I can look into it at some point in the future.