BresserWeatherSensorLW
Bresser 868 MHz Weather Sensor Radio Receiver based on ESP32/RP2040 and SX1262/SX1276/LR1121 - sends data to a LoRaWAN Network
Loading...
Searching...
No Matches
pico_rtc_utils.h
1
2// pico_rtc_utils.h
3//
4// RTC utility functions for RP2040
5//
6// Sleep/wakeup scheme based on
7// https://github.com/lyusupov/SoftRF/tree/master/software/firmware/source/libraries/RP2040_Sleep
8// by Linar Yusupov
9//
10// Using code from pico-extras:
11// https://github.com/raspberrypi/pico-extras/blob/master/src/rp2_common/pico_sleep/include/pico/sleep.h
12// https://github.com/raspberrypi/pico-extras/blob/master/src/rp2_common/pico_sleep/sleep.c
13// https://github.com/raspberrypi/pico-extras/blob/master/src/rp2_common/hardware_rosc/include/hardware/rosc.h
14// https://github.com/raspberrypi/pico-extras/blob/master/src/rp2_common/hardware_rosc/rosc.c
15//
16// created: 10/2023
17//
18//
19// MIT License
20//
21// Copyright (c) 2023 Matthias Prinke
22//
23// Permission is hereby granted, free of charge, to any person obtaining a copy
24// of this software and associated documentation files (the "Software"), to deal
25// in the Software without restriction, including without limitation the rights
26// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
27// copies of the Software, and to permit persons to whom the Software is
28// furnished to do so, subject to the following conditions:
29//
30// The above copyright notice and this permission notice shall be included in all
31// copies or substantial portions of the Software.
32//
33// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
34// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
35// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
36// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
37// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
38// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
39// SOFTWARE.
40//
41//
42// History:
43//
44// 20231006 Created
45//
46// ToDo:
47// -
48//
50#if defined(ARDUINO_ARCH_RP2040)
51#include <Arduino.h>
52#include <time.h>
53#include <pico/stdlib.h>
54#include <hardware/rtc.h>
55#include <hardware/clocks.h>
56#include "pico_sleep.h"
57#include "pico_rosc.h"
58#include "../logging.h"
59
60#ifndef PICO_RTC_UTILS_H
61#define PICO_RTC_UTILS_H
62
63struct tm *datetime_to_tm(datetime_t *dt, struct tm *ti);
64datetime_t *tm_to_datetime(struct tm *ti, datetime_t *dt);
65time_t datetime_to_epoch(datetime_t *dt, time_t *epoch);
66datetime_t *epoch_to_datetime(time_t *epoch, datetime_t *dt);
67
68void print_dt(datetime_t dt);
69void print_tm(struct tm ti);
70
71void pico_sleep(unsigned duration);
72
73#endif // PICO_RTC_UTILS_H
74#endif // defined(ARDUINO_ARCH_RP2040)
Replacement for esp32-hal-log.h on RP20240.