@web-font-path: "roboto-debian.css";
v2.2.0 (RP2040)
Loading...
Searching...
No Matches
types.h
/*
* Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef _PICO_TYPES_H
#define _PICO_TYPES_H
#ifndef __ASSEMBLER__
#include "pico/assert.h"
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
typedef unsigned int uint;
// PICO_CONFIG: PICO_OPAQUE_ABSOLUTE_TIME_T, Enable opaque type for absolute_time_t to help catch inadvertent confusing uint64_t delays with absolute times, default=0, advanced=true, group=pico_base
#ifndef PICO_OPAQUE_ABSOLUTE_TIME_T
#define PICO_OPAQUE_ABSOLUTE_TIME_T 0
#endif
#if PICO_OPAQUE_ABSOLUTE_TIME_T
typedef struct {
uint64_t _private_us_since_boot;
} absolute_time_t;
#else
typedef uint64_t absolute_time_t;
#endif
static inline uint64_t to_us_since_boot(absolute_time_t t) {
#ifdef PICO_DEBUG_ABSOLUTE_TIME_T
return t._private_us_since_boot;
#else
return t;
#endif
}
static inline void update_us_since_boot(absolute_time_t *t, uint64_t us_since_boot) {
#ifdef PICO_DEBUG_ABSOLUTE_TIME_T
assert(us_since_boot <= INT64_MAX);
t->_private_us_since_boot = us_since_boot;
#else
*t = us_since_boot;
#endif
}
static inline absolute_time_t from_us_since_boot(uint64_t us_since_boot) {
absolute_time_t t;
update_us_since_boot(&t, us_since_boot);
return t;
}
#ifdef NDEBUG
#define ABSOLUTE_TIME_INITIALIZED_VAR(name, value) name = value
#else
#define ABSOLUTE_TIME_INITIALIZED_VAR(name, value) name = {value}
#endif
// PICO_CONFIG: PICO_INCLUDE_RTC_DATETIME, Whether to include the datetime_t type used with the RP2040 RTC hardware, default=1 on RP2040, group=util_datetime
#ifndef PICO_INCLUDE_RTC_DATETIME
#define PICO_INCLUDE_RTC_DATETIME PICO_RP2040
#endif
#if PICO_INCLUDE_RTC_DATETIME
typedef struct {
int16_t year;
int8_t month;
int8_t day;
int8_t dotw;
int8_t hour;
int8_t min;
int8_t sec;
} datetime_t;
#endif
#define bool_to_bit(x) ((uint)!!(x))
#endif
#endif
to_us_since_boot
static uint64_t to_us_since_boot(absolute_time_t t)
convert an absolute_time_t into a number of microseconds since boot.
Definition types.h:52
from_us_since_boot
static absolute_time_t from_us_since_boot(uint64_t us_since_boot)
convert a number of microseconds since boot to an absolute_time_t
Definition types.h:82
update_us_since_boot
static void update_us_since_boot(absolute_time_t *t, uint64_t us_since_boot)
update an absolute_time_t value to represent a given number of microseconds since boot
Definition types.h:67
absolute_time_t
uint64_t absolute_time_t
An opaque 64 bit timestamp in microseconds.
Definition types.h:43
datetime_t
Structure containing date and time information.
Definition types.h:107
datetime_t::day
int8_t day
1..28,29,30,31 depending on month
Definition types.h:110
datetime_t::hour
int8_t hour
0..23
Definition types.h:112
datetime_t::month
int8_t month
1..12, 1 is January
Definition types.h:109
datetime_t::year
int16_t year
0..4095
Definition types.h:108
datetime_t::dotw
int8_t dotw
0..6, 0 is Sunday
Definition types.h:111
datetime_t::min
int8_t min
0..59
Definition types.h:113
datetime_t::sec
int8_t sec
0..59
Definition types.h:114