You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
VERSION: !Register
adr: 0x7F
reset_val: 0x41
doc: Holds the version number of the IC, currently 0x41.
layout: !Layout
VERSION_NUMBER:
bits: [0-7]
access: [R]
accepts: !Fixed 0x41
gets transpiled into the following C code:
// =============================================================================
// ==== VERSION Register =======================================================
// =============================================================================
// Holds the version number of the IC, currently 0x41.
// Fields:
// - [7:0] VERSION_NUMBER (fixed: 0x41)
#define FH101RF_VERSION_ADDRESS (0x7FU) //!< VERSION register address
#define FH101RF_VERSION_RESET_LE {0x41U} //!< VERSION register reset value
#define FH101RF_VERSION_RESET_BE {0x41U} //!< VERSION register reset value
// Register Layout Struct:
/**
* @brief Holds the version number of the IC, currently 0x41.
* @note use pack/unpack functions for conversion to/from packed binary value
*/
struct fh101rf_version {
int dummy; // Register contains no variable fields.
};
// Layout struct conversion functions:
/**
* @brief Convert @ref struct fh101rf_version struct to packed little-endian value.
* @note use pack/unpack functions for conversion to/from packed binary value
*/
static inline void fh101rf_version_pack_le(const struct fh101rf_version *r, uint8_t val[1]) {
// VERSION_NUMBER @ version[7:0]:
val[0] &= (uint8_t)~0xFFU;
val[0] |= (uint8_t)0x41; // Fixed value.
(void)r;
}
/**
* @brief Convert @ref struct fh101rf_version struct to packed big-endian value.
* @note use pack/unpack functions for conversion to/from packed binary value
*/
static inline void fh101rf_version_pack_be(const struct fh101rf_version *r, uint8_t val[1]) {
// VERSION_NUMBER @ version[7:0]:
val[0] &= (uint8_t)~0xFFU;
val[0] |= (uint8_t)0x41; // Fixed value.
(void)r;
}
/** @brief Convert packed {endian} binary value to struct. */
static inline struct fh101rf_version fh101rf_version_unpack_le(const uint8_t val[1]) {
struct fh101rf_version r = {0};
(void)val;
(void)r;
return r;
}
/** @brief Convert packed {endian} binary value to struct. */
static inline struct fh101rf_version fh101rf_version_unpack_be(const uint8_t val[1]) {
struct fh101rf_version r = {0};
(void)val;
(void)r;
return r;
}
/**
* @brief Validate struct
* @returns 0 if valid.
* @returns the position of the first invalid field if invalid.
* Confirms that all enums are valid, and all values fit into respective fields
*/
static inline int fh101rf_validate_version(const struct fh101rf_version *r) {
(void)r;
return 0;
}
/**
* @brief Attempt to convert packed {endian} binary value to struct.
* @returns 0 if valid.
* @returns the position of the first invalid field if invalid.
*/
static inline int fh101rf_version_try_unpack_le(const uint8_t val[1], struct fh101rf_version *r) {
*r = fh101rf_version_unpack_le(val);
return fh101rf_validate_version(r);
}
/**
* @brief Attempt to convert packed {endian} binary value to struct.
* @returns 0 if valid.
* @returns the position of the first invalid field if invalid.
*/
static inline int fh101rf_version_try_unpack_be(const uint8_t val[1], struct fh101rf_version *r) {
*r = fh101rf_version_unpack_be(val);
return fh101rf_validate_version(r);
}
Unfortunately, this does not allow to do (pseudo code):
uint8_t result;
read_reg(VERSION_ADDRESS, &result);
struct fh101rf_version ver = fh101rf_version_unpack_le(&result);
ver.version_number == dev->version.version_number, as this field does not even exist.
The text was updated successfully, but these errors were encountered:
The following YAML:
gets transpiled into the following C code:
Unfortunately, this does not allow to do (pseudo code):
The text was updated successfully, but these errors were encountered: