STMicroelectronics / STMems_Standard_C_drivers

Platform-independent drivers for STMicroelectronics MEMS motion and environmental sensors, based on standard C programming language.
BSD 3-Clause "New" or "Revised" License
729 stars 518 forks source link

added c++ usage example for this driver #154

Closed BeSeeTek closed 2 years ago

BeSeeTek commented 2 years ago

I'm using this drivers with C++ Code.

I needed some time to figure out how to use the hande to pass the instance pointer to my nonstatic member functions. An example would have helped me a lot. There for i sugest to add an c++ example to the readme like this one below and in the the pull request

2.c Using the handle to integrate this driver in c++ classes

class MemsSensor{
public:
  ...
private:
  int32_t platform_write(uint8_t reg, const uint8_t *bufp,uint16_t len);
  int32_t platform_read(uint8_t reg, uint8_t *bufp,uint16_t len);
  stmdev_ctx_t _dev_ctx={(stmdev_write_ptr)  &MemsSensor::platform_write,
                    (stmdev_read_ptr)    &MemsSensor::platform_read,
                        (stmdev_mdelay_ptr)  NULL, // no delay function set
                                             this};
}
ST-dot-com commented 2 years ago

This pull request has been refused, the Contribution License Agreement must be signed.