target.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #pragma once
  2. #define RADIOLIB_STATIC_ONLY 1
  3. #include <RadioLib.h>
  4. #include <helpers/radiolib/RadioLibWrappers.h>
  5. #include <helpers/stm32/STM32Board.h>
  6. #include <helpers/radiolib/CustomSTM32WLxWrapper.h>
  7. #include <helpers/ArduinoHelpers.h>
  8. #include <helpers/SensorManager.h>
  9. #define PIN_VBAT_READ A0
  10. #define ADC_MULTIPLIER (5 * 1.73 * 1000)
  11. class RAK3x72Board : public STM32Board {
  12. public:
  13. void begin() override {
  14. STM32Board::begin();
  15. pinMode(PA0, OUTPUT);
  16. pinMode(PA1, OUTPUT);
  17. }
  18. const char* getManufacturerName() const override {
  19. return "RAK 3x72";
  20. }
  21. uint16_t getBattMilliVolts() override {
  22. analogReadResolution(12);
  23. uint32_t raw = 0;
  24. for (int i=0; i<8;i++) {
  25. raw += analogRead(PIN_VBAT_READ);
  26. }
  27. return ((double)raw) * ADC_MULTIPLIER / 8 / 4096;
  28. }
  29. void setGpio(uint32_t values) override {
  30. // set led values
  31. digitalWrite(PA0, values & 1);
  32. digitalWrite(PA1, (values & 2) >> 1);
  33. }
  34. uint32_t getGpio() override {
  35. // get led value
  36. return (digitalRead(PA1) << 1) | digitalRead(PA0);
  37. }
  38. };
  39. extern RAK3x72Board board;
  40. extern WRAPPER_CLASS radio_driver;
  41. extern VolatileRTCClock rtc_clock;
  42. extern SensorManager sensors;
  43. bool radio_init();
  44. uint32_t radio_get_rng_seed();
  45. void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr);
  46. void radio_set_tx_power(int8_t dbm);
  47. mesh::LocalIdentity radio_new_identity();