Loading...
Searching...
No Matches
max313xx.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2026 Technische Universität Hamburg
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
40
41#include <stdint.h>
42#include <time.h>
43#include <stdbool.h>
44
45#include "periph/i2c.h"
46#include "kernel_defines.h"
47
48#ifdef __cplusplus
49extern "C" {
50#endif
51
59typedef struct {
62
71typedef enum {
72 MAX313xx_SQW_1HZ = 0,
73 MAX313xx_SQW_2HZ = 1,
74 MAX313xx_SQW_4HZ = 2,
75 MAX313xx_SQW_8HZ = 3,
76 MAX313xx_SQW_16HZ = 4,
77 MAX313xx_SQW_32HZ = 5,
79
100
113
117typedef struct {
120
142
152int max313xx_get_time(const max313xx_t *dev, struct tm *time);
153
167int max313xx_set_time(const max313xx_t *dev, const struct tm *time);
168
180
192
211int max313xx_set_alarm(const max313xx_t *dev, const struct tm *time);
212
226int max313xx_get_alarm(const max313xx_t *dev, struct tm *time);
227
243int max313xx_set_alarm_int(const max313xx_t *dev, bool enable);
244
262
277int max313xx_get_temp(const max313xx_t *dev, int16_t *temp_centi);
278
296
306
321int max313xx_temp_set_automode(const max313xx_t *dev, bool enable, max313xx_ttsint_t ttsint);
322
324
325#ifdef __cplusplus
326}
327#endif
int max313xx_trickle_charge_enable(const max313xx_t *dev, bool diode, max313xx_trickle_res_t res)
Enable the trickle charger.
int max313xx_set_time(const max313xx_t *dev, const struct tm *time)
Set current time on device.
int max313xx_trickle_charge_disable(const max313xx_t *dev)
Disable the trickle charger.
int max313xx_temp_set_automode(const max313xx_t *dev, bool enable, max313xx_ttsint_t ttsint)
Configure automatic temperature conversion mode and interval.
int max313xx_set_sqw(const max313xx_t *dev, max313xx_sqw_freq_t freq)
Configure the square-wave (SQW) output frequency.
int max313xx_poweroff(const max313xx_t *dev)
Disable RTC oscillator (stop timekeeping).
int max313xx_set_alarm(const max313xx_t *dev, const struct tm *time)
Set alarm time registers.
int max313xx_poweron(const max313xx_t *dev)
Enable RTC oscillator (power on timekeeping).
int max313xx_get_temp(const max313xx_t *dev, int16_t *temp_centi)
Read temperature in centi-degrees Celsius (°C * 100)
int max313xx_get_alarm(const max313xx_t *dev, struct tm *time)
Get the currently configured alarm time.
int max313xx_get_time(const max313xx_t *dev, struct tm *time)
Read current time from device.
max313xx_sqw_freq_t
Square-wave output frequency selection.
Definition max313xx.h:71
max313xx_ttsint_t
Automatic temperature conversion interval.
Definition max313xx.h:90
max313xx_trickle_res_t
Trickle charger resistor selection.
Definition max313xx.h:108
int max313xx_set_alarm_int(const max313xx_t *dev, bool enable)
Enable or disable the alarm interrupt.
int max313xx_init(max313xx_t *dev, const max313xx_params_t *params)
Initialize MAX313xx device.
@ MAX313xx_TTSINT_16S
update temperature every 16s
Definition max313xx.h:95
@ MAX313xx_TTSINT_1S
update temperature every 1s
Definition max313xx.h:91
@ MAX313xx_TTSINT_32S
update temperature every 32s
Definition max313xx.h:96
@ MAX313xx_TTSINT_128S
update temperature every 128s
Definition max313xx.h:98
@ MAX313xx_TTSINT_8S
update temperature every 8s
Definition max313xx.h:94
@ MAX313xx_TTSINT_4S
update temperature every 4s
Definition max313xx.h:93
@ MAX313xx_TTSINT_64S
update temperature every 64s
Definition max313xx.h:97
@ MAX313xx_TTSINT_2S
update temperature every 2s
Definition max313xx.h:92
@ MAX313xx_TRICKLE_RES_6K
6 kOhm
Definition max313xx.h:110
@ MAX313xx_TRICKLE_RES_11K
11 kOhm
Definition max313xx.h:111
@ MAX313xx_TRICKLE_RES_3K
3 kOhm
Definition max313xx.h:109
uint_fast8_t i2c_t
Default i2c_t type definition.
Definition i2c.h:155
Low-level I2C peripheral driver interface definition.
Common macros and compiler attributes/pragmas configuration.
Configuration parameters for MAX313xx initialization.
Definition max313xx.h:117
i2c_t i2c
I2C bus the device is connected to.
Definition max313xx.h:118
Device descriptor for the MAX313xx RTC.
Definition max313xx.h:59
i2c_t i2c
I2C bus.
Definition max313xx.h:60