diff --git a/Drivers/BSP/Components/lps22hh/LICENSE.md b/Drivers/BSP/Components/lps22hh/LICENSE.md new file mode 100644 index 0000000..e349e23 --- /dev/null +++ b/Drivers/BSP/Components/lps22hh/LICENSE.md @@ -0,0 +1,27 @@ +Copyright 2019 STMicroelectronics. +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation and/or +other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors +may be used to endorse or promote products derived from this software without +specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/Drivers/BSP/Components/lps22hh/Release_Notes.html b/Drivers/BSP/Components/lps22hh/Release_Notes.html new file mode 100644 index 0000000..1cd908b --- /dev/null +++ b/Drivers/BSP/Components/lps22hh/Release_Notes.html @@ -0,0 +1,174 @@ + + + + + + + Release Notes for LPS22HH Component + + + + + + +
+
+
+

Release Notes for LPS22HH Component Driver

+

Copyright © 2022 STMicroelectronics
+

+ +
+

Purpose

+

This directory contains the LPS22HH component drivers.

+
+
+

Update history

+
+ +
+

Main changes

+

Patch release

+
    +
  • Removed useless APIs
  • +
  • Fixed typos in some comments
  • +
+

+
+
+
+ +
+

Main changes

+

Maintenance release

+
    +
  • Synchronized PID with currently latest version on ST GitHub
  • +
  • Added Delay function
  • +
+

+
+
+
+ +
+

Main changes

+

Maintenance release

+
    +
  • Synchronized PID with currently latest version on ST GitHub
  • +
+

+
+
+
+ +
+

Main changes

+

Patch release

+
    +
  • Update License to new format
  • +
+

+
+
+
+ +
+

Main changes

+

Patch release

+
    +
  • Update Release Notes to new format
  • +
+

+
+
+
+ +
+

Main changes

+

Maintenance release

+
    +
  • Synchronize PID with latest version on ST GitHub
  • +
+

+
+
+
+ +
+

Main changes

+

Patch release

+
    +
  • Synchronize PID with latest version on ST GitHub and adapt HLD to it
  • +
+

+
+
+
+ +
+

Main changes

+

Patch release

+
    +
  • Rename context type to universal stmdev_ctx_t
  • +
  • Move unions from PID to HLD
  • +
+

+
+
+
+ +
+

Main changes

+

Maintenance release

+
    +
  • PID update from ST GitHub
  • +
  • HLD update to reflect new PID
  • +
+

+
+
+
+ +
+

Main changes

+

Patch release

+
    +
  • Fix doxygen comments
  • +
+

+
+
+
+ +
+

Main changes

+

First release

+
    +
  • First official release
  • +
+

+
+
+
+
+ + + diff --git a/Drivers/BSP/Components/lps22hh/_htmresc/favicon.png b/Drivers/BSP/Components/lps22hh/_htmresc/favicon.png new file mode 100644 index 0000000..06713ee Binary files /dev/null and b/Drivers/BSP/Components/lps22hh/_htmresc/favicon.png differ diff --git a/Drivers/BSP/Components/lps22hh/_htmresc/mini-st_2020.css b/Drivers/BSP/Components/lps22hh/_htmresc/mini-st_2020.css new file mode 100644 index 0000000..986f4d4 --- /dev/null +++ b/Drivers/BSP/Components/lps22hh/_htmresc/mini-st_2020.css @@ -0,0 +1,1711 @@ +@charset "UTF-8"; +/* + Flavor name: Custom (mini-custom) + Generated online - https://minicss.org/flavors + mini.css version: v3.0.1 +*/ +/* + Browsers resets and base typography. +*/ +/* Core module CSS variable definitions */ +:root { + --fore-color: #03234b; + --secondary-fore-color: #03234b; + --back-color: #ffffff; + --secondary-back-color: #ffffff; + --blockquote-color: #e6007e; + --pre-color: #e6007e; + --border-color: #3cb4e6; + --secondary-border-color: #3cb4e6; + --heading-ratio: 1.2; + --universal-margin: 0.5rem; + --universal-padding: 0.25rem; + --universal-border-radius: 0.075rem; + --background-margin: 1.5%; + --a-link-color: #3cb4e6; + --a-visited-color: #8c0078; } + +html { + font-size: 13.5px; } + +a, b, del, em, i, ins, q, span, strong, u { + font-size: 1em; } + +html, * { + font-family: -apple-system, BlinkMacSystemFont, Helvetica, arial, sans-serif; + line-height: 1.25; + -webkit-text-size-adjust: 100%; } + +* { + font-size: 1rem; } + +body { + margin: 0; + color: var(--fore-color); + @background: var(--back-color); + background: var(--back-color) linear-gradient(#ffd200, #ffd200) repeat-y left top; + background-size: var(--background-margin); + } + +details { + display: block; } + +summary { + display: list-item; } + +abbr[title] { + border-bottom: none; + text-decoration: underline dotted; } + +input { + overflow: visible; } + +img { + max-width: 100%; + height: auto; } + +h1, h2, h3, h4, h5, h6 { + line-height: 1.25; + margin: calc(1.5 * var(--universal-margin)) var(--universal-margin); + font-weight: 400; } + h1 small, h2 small, h3 small, h4 small, h5 small, h6 small { + color: var(--secondary-fore-color); + display: block; + margin-top: -0.25rem; } + +h1 { + font-size: calc(1rem * var(--heading-ratio) * var(--heading-ratio) * var(--heading-ratio)); } + +h2 { + font-size: calc(1rem * var(--heading-ratio) * var(--heading-ratio) ); + border-style: none none solid none ; + border-width: thin; + border-color: var(--border-color); } +h3 { + font-size: calc(1rem * var(--heading-ratio) ); } + +h4 { + font-size: calc(1rem * var(--heading-ratio)); } + +h5 { + font-size: 1rem; } + +h6 { + font-size: calc(1rem / var(--heading-ratio)); } + +p { + margin: var(--universal-margin); } + +ol, ul { + margin: var(--universal-margin); + padding-left: calc(3 * var(--universal-margin)); } + +b, strong { + font-weight: 700; } + +hr { + box-sizing: content-box; + border: 0; + line-height: 1.25em; + margin: var(--universal-margin); + height: 0.0714285714rem; + background: linear-gradient(to right, transparent, var(--border-color) 20%, var(--border-color) 80%, transparent); } + +blockquote { + display: block; + position: relative; + font-style: italic; + color: var(--secondary-fore-color); + margin: var(--universal-margin); + padding: calc(3 * var(--universal-padding)); + border: 0.0714285714rem solid var(--secondary-border-color); + border-left: 0.3rem solid var(--blockquote-color); + border-radius: 0 var(--universal-border-radius) var(--universal-border-radius) 0; } + blockquote:before { + position: absolute; + top: calc(0rem - var(--universal-padding)); + left: 0; + font-family: sans-serif; + font-size: 2rem; + font-weight: 800; + content: "\201c"; + color: var(--blockquote-color); } + blockquote[cite]:after { + font-style: normal; + font-size: 0.75em; + font-weight: 700; + content: "\a— " attr(cite); + white-space: pre; } + +code, kbd, pre, samp { + font-family: Menlo, Consolas, monospace; + font-size: 0.85em; } + +code { + background: var(--secondary-back-color); + border-radius: var(--universal-border-radius); + padding: calc(var(--universal-padding) / 4) calc(var(--universal-padding) / 2); } + +kbd { + background: var(--fore-color); + color: var(--back-color); + border-radius: var(--universal-border-radius); + padding: calc(var(--universal-padding) / 4) calc(var(--universal-padding) / 2); } + +pre { + overflow: auto; + background: var(--secondary-back-color); + padding: calc(1.5 * var(--universal-padding)); + margin: var(--universal-margin); + border: 0.0714285714rem solid var(--secondary-border-color); + border-left: 0.2857142857rem solid var(--pre-color); + border-radius: 0 var(--universal-border-radius) var(--universal-border-radius) 0; } + +sup, sub, code, kbd { + line-height: 0; + position: relative; + vertical-align: baseline; } + +small, sup, sub, figcaption { + font-size: 0.75em; } + +sup { + top: -0.5em; } + +sub { + bottom: -0.25em; } + +figure { + margin: var(--universal-margin); } + +figcaption { + color: var(--secondary-fore-color); } + +a { + text-decoration: none; } + a:link { + color: var(--a-link-color); } + a:visited { + color: var(--a-visited-color); } + a:hover, a:focus { + text-decoration: underline; } + +/* + Definitions for the grid system, cards and containers. +*/ +.container { + margin: 0 auto; + padding: 0 calc(1.5 * var(--universal-padding)); } + +.row { + box-sizing: border-box; + display: flex; + flex: 0 1 auto; + flex-flow: row wrap; + margin: 0 0 0 var(--background-margin); } + +.col-sm, +[class^='col-sm-'], +[class^='col-sm-offset-'], +.row[class*='cols-sm-'] > * { + box-sizing: border-box; + flex: 0 0 auto; + padding: 0 calc(var(--universal-padding) / 2); } + +.col-sm, +.row.cols-sm > * { + max-width: 100%; + flex-grow: 1; + flex-basis: 0; } + +.col-sm-1, +.row.cols-sm-1 > * { + max-width: 8.3333333333%; + flex-basis: 8.3333333333%; } + +.col-sm-offset-0 { + margin-left: 0; } + +.col-sm-2, +.row.cols-sm-2 > * { + max-width: 16.6666666667%; + flex-basis: 16.6666666667%; } + +.col-sm-offset-1 { + margin-left: 8.3333333333%; } + +.col-sm-3, +.row.cols-sm-3 > * { + max-width: 25%; + flex-basis: 25%; } + +.col-sm-offset-2 { + margin-left: 16.6666666667%; } + +.col-sm-4, +.row.cols-sm-4 > * { + max-width: 33.3333333333%; + flex-basis: 33.3333333333%; } + +.col-sm-offset-3 { + margin-left: 25%; } + +.col-sm-5, +.row.cols-sm-5 > * { + max-width: 41.6666666667%; + flex-basis: 41.6666666667%; } + +.col-sm-offset-4 { + margin-left: 33.3333333333%; } + +.col-sm-6, +.row.cols-sm-6 > * { + max-width: 50%; + flex-basis: 50%; } + +.col-sm-offset-5 { + margin-left: 41.6666666667%; } + +.col-sm-7, +.row.cols-sm-7 > * { + max-width: 58.3333333333%; + flex-basis: 58.3333333333%; } + +.col-sm-offset-6 { + margin-left: 50%; } + +.col-sm-8, +.row.cols-sm-8 > * { + max-width: 66.6666666667%; + flex-basis: 66.6666666667%; } + +.col-sm-offset-7 { + margin-left: 58.3333333333%; } + +.col-sm-9, +.row.cols-sm-9 > * { + max-width: 75%; + flex-basis: 75%; } + +.col-sm-offset-8 { + margin-left: 66.6666666667%; } + +.col-sm-10, +.row.cols-sm-10 > * { + max-width: 83.3333333333%; + flex-basis: 83.3333333333%; } + +.col-sm-offset-9 { + margin-left: 75%; } + +.col-sm-11, +.row.cols-sm-11 > * { + max-width: 91.6666666667%; + flex-basis: 91.6666666667%; } + +.col-sm-offset-10 { + margin-left: 83.3333333333%; } + +.col-sm-12, +.row.cols-sm-12 > * { + max-width: 100%; + flex-basis: 100%; } + +.col-sm-offset-11 { + margin-left: 91.6666666667%; } + +.col-sm-normal { + order: initial; } + +.col-sm-first { + order: -999; } + +.col-sm-last { + order: 999; } + +@media screen and (min-width: 500px) { + .col-md, + [class^='col-md-'], + [class^='col-md-offset-'], + .row[class*='cols-md-'] > * { + box-sizing: border-box; + flex: 0 0 auto; + padding: 0 calc(var(--universal-padding) / 2); } + + .col-md, + .row.cols-md > * { + max-width: 100%; + flex-grow: 1; + flex-basis: 0; } + + .col-md-1, + .row.cols-md-1 > * { + max-width: 8.3333333333%; + flex-basis: 8.3333333333%; } + + .col-md-offset-0 { + margin-left: 0; } + + .col-md-2, + .row.cols-md-2 > * { + max-width: 16.6666666667%; + flex-basis: 16.6666666667%; } + + .col-md-offset-1 { + margin-left: 8.3333333333%; } + + .col-md-3, + .row.cols-md-3 > * { + max-width: 25%; + flex-basis: 25%; } + + .col-md-offset-2 { + margin-left: 16.6666666667%; } + + .col-md-4, + .row.cols-md-4 > * { + max-width: 33.3333333333%; + flex-basis: 33.3333333333%; } + + .col-md-offset-3 { + margin-left: 25%; } + + .col-md-5, + .row.cols-md-5 > * { + max-width: 41.6666666667%; + flex-basis: 41.6666666667%; } + + .col-md-offset-4 { + margin-left: 33.3333333333%; } + + .col-md-6, + .row.cols-md-6 > * { + max-width: 50%; + flex-basis: 50%; } + + .col-md-offset-5 { + margin-left: 41.6666666667%; } + + .col-md-7, + .row.cols-md-7 > * { + max-width: 58.3333333333%; + flex-basis: 58.3333333333%; } + + .col-md-offset-6 { + margin-left: 50%; } + + .col-md-8, + .row.cols-md-8 > * { + max-width: 66.6666666667%; + flex-basis: 66.6666666667%; } + + .col-md-offset-7 { + margin-left: 58.3333333333%; } + + .col-md-9, + .row.cols-md-9 > * { + max-width: 75%; + flex-basis: 75%; } + + .col-md-offset-8 { + margin-left: 66.6666666667%; } + + .col-md-10, + .row.cols-md-10 > * { + max-width: 83.3333333333%; + flex-basis: 83.3333333333%; } + + .col-md-offset-9 { + margin-left: 75%; } + + .col-md-11, + .row.cols-md-11 > * { + max-width: 91.6666666667%; + flex-basis: 91.6666666667%; } + + .col-md-offset-10 { + margin-left: 83.3333333333%; } + + .col-md-12, + .row.cols-md-12 > * { + max-width: 100%; + flex-basis: 100%; } + + .col-md-offset-11 { + margin-left: 91.6666666667%; } + + .col-md-normal { + order: initial; } + + .col-md-first { + order: -999; } + + .col-md-last { + order: 999; } } +@media screen and (min-width: 1280px) { + .col-lg, + [class^='col-lg-'], + [class^='col-lg-offset-'], + .row[class*='cols-lg-'] > * { + box-sizing: border-box; + flex: 0 0 auto; + padding: 0 calc(var(--universal-padding) / 2); } + + .col-lg, + .row.cols-lg > * { + max-width: 100%; + flex-grow: 1; + flex-basis: 0; } + + .col-lg-1, + .row.cols-lg-1 > * { + max-width: 8.3333333333%; + flex-basis: 8.3333333333%; } + + .col-lg-offset-0 { + margin-left: 0; } + + .col-lg-2, + .row.cols-lg-2 > * { + max-width: 16.6666666667%; + flex-basis: 16.6666666667%; } + + .col-lg-offset-1 { + margin-left: 8.3333333333%; } + + .col-lg-3, + .row.cols-lg-3 > * { + max-width: 25%; + flex-basis: 25%; } + + .col-lg-offset-2 { + margin-left: 16.6666666667%; } + + .col-lg-4, + .row.cols-lg-4 > * { + max-width: 33.3333333333%; + flex-basis: 33.3333333333%; } + + .col-lg-offset-3 { + margin-left: 25%; } + + .col-lg-5, + .row.cols-lg-5 > * { + max-width: 41.6666666667%; + flex-basis: 41.6666666667%; } + + .col-lg-offset-4 { + margin-left: 33.3333333333%; } + + .col-lg-6, + .row.cols-lg-6 > * { + max-width: 50%; + flex-basis: 50%; } + + .col-lg-offset-5 { + margin-left: 41.6666666667%; } + + .col-lg-7, + .row.cols-lg-7 > * { + max-width: 58.3333333333%; + flex-basis: 58.3333333333%; } + + .col-lg-offset-6 { + margin-left: 50%; } + + .col-lg-8, + .row.cols-lg-8 > * { + max-width: 66.6666666667%; + flex-basis: 66.6666666667%; } + + .col-lg-offset-7 { + margin-left: 58.3333333333%; } + + .col-lg-9, + .row.cols-lg-9 > * { + max-width: 75%; + flex-basis: 75%; } + + .col-lg-offset-8 { + margin-left: 66.6666666667%; } + + .col-lg-10, + .row.cols-lg-10 > * { + max-width: 83.3333333333%; + flex-basis: 83.3333333333%; } + + .col-lg-offset-9 { + margin-left: 75%; } + + .col-lg-11, + .row.cols-lg-11 > * { + max-width: 91.6666666667%; + flex-basis: 91.6666666667%; } + + .col-lg-offset-10 { + margin-left: 83.3333333333%; } + + .col-lg-12, + .row.cols-lg-12 > * { + max-width: 100%; + flex-basis: 100%; } + + .col-lg-offset-11 { + margin-left: 91.6666666667%; } + + .col-lg-normal { + order: initial; } + + .col-lg-first { + order: -999; } + + .col-lg-last { + order: 999; } } +/* Card component CSS variable definitions */ +:root { + --card-back-color: #3cb4e6; + --card-fore-color: #03234b; + --card-border-color: #03234b; } + +.card { + display: flex; + flex-direction: column; + justify-content: space-between; + align-self: center; + position: relative; + width: 100%; + background: var(--card-back-color); + color: var(--card-fore-color); + border: 0.0714285714rem solid var(--card-border-color); + border-radius: var(--universal-border-radius); + margin: var(--universal-margin); + overflow: hidden; } + @media screen and (min-width: 320px) { + .card { + max-width: 320px; } } + .card > .sectione { + background: var(--card-back-color); + color: var(--card-fore-color); + box-sizing: border-box; + margin: 0; + border: 0; + border-radius: 0; + border-bottom: 0.0714285714rem solid var(--card-border-color); + padding: var(--universal-padding); + width: 100%; } + .card > .sectione.media { + height: 200px; + padding: 0; + -o-object-fit: cover; + object-fit: cover; } + .card > .sectione:last-child { + border-bottom: 0; } + +/* + Custom elements for card elements. +*/ +@media screen and (min-width: 240px) { + .card.small { + max-width: 240px; } } +@media screen and (min-width: 480px) { + .card.large { + max-width: 480px; } } +.card.fluid { + max-width: 100%; + width: auto; } + +.card.warning { + --card-back-color: #e5b8b7; + --card-fore-color: #3b234b; + --card-border-color: #8c0078; } + +.card.error { + --card-back-color: #464650; + --card-fore-color: #ffffff; + --card-border-color: #8c0078; } + +.card > .sectione.dark { + --card-back-color: #3b234b; + --card-fore-color: #ffffff; } + +.card > .sectione.double-padded { + padding: calc(1.5 * var(--universal-padding)); } + +/* + Definitions for forms and input elements. +*/ +/* Input_control module CSS variable definitions */ +:root { + --form-back-color: #ffe97f; + --form-fore-color: #03234b; + --form-border-color: #3cb4e6; + --input-back-color: #ffffff; + --input-fore-color: #03234b; + --input-border-color: #3cb4e6; + --input-focus-color: #0288d1; + --input-invalid-color: #d32f2f; + --button-back-color: #e2e2e2; + --button-hover-back-color: #dcdcdc; + --button-fore-color: #212121; + --button-border-color: transparent; + --button-hover-border-color: transparent; + --button-group-border-color: rgba(124, 124, 124, 0.54); } + +form { + background: var(--form-back-color); + color: var(--form-fore-color); + border: 0.0714285714rem solid var(--form-border-color); + border-radius: var(--universal-border-radius); + margin: var(--universal-margin); + padding: calc(2 * var(--universal-padding)) var(--universal-padding); } + +fieldset { + border: 0.0714285714rem solid var(--form-border-color); + border-radius: var(--universal-border-radius); + margin: calc(var(--universal-margin) / 4); + padding: var(--universal-padding); } + +legend { + box-sizing: border-box; + display: table; + max-width: 100%; + white-space: normal; + font-weight: 500; + padding: calc(var(--universal-padding) / 2); } + +label { + padding: calc(var(--universal-padding) / 2) var(--universal-padding); } + +.input-group { + display: inline-block; } + .input-group.fluid { + display: flex; + align-items: center; + justify-content: center; } + .input-group.fluid > input { + max-width: 100%; + flex-grow: 1; + flex-basis: 0px; } + @media screen and (max-width: 499px) { + .input-group.fluid { + align-items: stretch; + flex-direction: column; } } + .input-group.vertical { + display: flex; + align-items: stretch; + flex-direction: column; } + .input-group.vertical > input { + max-width: 100%; + flex-grow: 1; + flex-basis: 0px; } + +[type="number"]::-webkit-inner-spin-button, [type="number"]::-webkit-outer-spin-button { + height: auto; } + +[type="search"] { + -webkit-appearance: textfield; + outline-offset: -2px; } + +[type="search"]::-webkit-search-cancel-button, +[type="search"]::-webkit-search-decoration { + -webkit-appearance: none; } + +input:not([type]), [type="text"], [type="email"], [type="number"], [type="search"], +[type="password"], [type="url"], [type="tel"], [type="checkbox"], [type="radio"], textarea, select { + box-sizing: border-box; + background: var(--input-back-color); + color: var(--input-fore-color); + border: 0.0714285714rem solid var(--input-border-color); + border-radius: var(--universal-border-radius); + margin: calc(var(--universal-margin) / 2); + padding: var(--universal-padding) calc(1.5 * var(--universal-padding)); } + +input:not([type="button"]):not([type="submit"]):not([type="reset"]):hover, input:not([type="button"]):not([type="submit"]):not([type="reset"]):focus, textarea:hover, textarea:focus, select:hover, select:focus { + border-color: var(--input-focus-color); + box-shadow: none; } +input:not([type="button"]):not([type="submit"]):not([type="reset"]):invalid, input:not([type="button"]):not([type="submit"]):not([type="reset"]):focus:invalid, textarea:invalid, textarea:focus:invalid, select:invalid, select:focus:invalid { + border-color: var(--input-invalid-color); + box-shadow: none; } +input:not([type="button"]):not([type="submit"]):not([type="reset"])[readonly], textarea[readonly], select[readonly] { + background: var(--secondary-back-color); } + +select { + max-width: 100%; } + +option { + overflow: hidden; + text-overflow: ellipsis; } + +[type="checkbox"], [type="radio"] { + -webkit-appearance: none; + -moz-appearance: none; + appearance: none; + position: relative; + height: calc(1rem + var(--universal-padding) / 2); + width: calc(1rem + var(--universal-padding) / 2); + vertical-align: text-bottom; + padding: 0; + flex-basis: calc(1rem + var(--universal-padding) / 2) !important; + flex-grow: 0 !important; } + [type="checkbox"]:checked:before, [type="radio"]:checked:before { + position: absolute; } + +[type="checkbox"]:checked:before { + content: '\2713'; + font-family: sans-serif; + font-size: calc(1rem + var(--universal-padding) / 2); + top: calc(0rem - var(--universal-padding)); + left: calc(var(--universal-padding) / 4); } + +[type="radio"] { + border-radius: 100%; } + [type="radio"]:checked:before { + border-radius: 100%; + content: ''; + top: calc(0.0714285714rem + var(--universal-padding) / 2); + left: calc(0.0714285714rem + var(--universal-padding) / 2); + background: var(--input-fore-color); + width: 0.5rem; + height: 0.5rem; } + +:placeholder-shown { + color: var(--input-fore-color); } + +::-ms-placeholder { + color: var(--input-fore-color); + opacity: 0.54; } + +button::-moz-focus-inner, [type="button"]::-moz-focus-inner, [type="reset"]::-moz-focus-inner, [type="submit"]::-moz-focus-inner { + border-style: none; + padding: 0; } + +button, html [type="button"], [type="reset"], [type="submit"] { + -webkit-appearance: button; } + +button { + overflow: visible; + text-transform: none; } + +button, [type="button"], [type="submit"], [type="reset"], +a.button, label.button, .button, +a[role="button"], label[role="button"], [role="button"] { + display: inline-block; + background: var(--button-back-color); + color: var(--button-fore-color); + border: 0.0714285714rem solid var(--button-border-color); + border-radius: var(--universal-border-radius); + padding: var(--universal-padding) calc(1.5 * var(--universal-padding)); + margin: var(--universal-margin); + text-decoration: none; + cursor: pointer; + transition: background 0.3s; } + button:hover, button:focus, [type="button"]:hover, [type="button"]:focus, [type="submit"]:hover, [type="submit"]:focus, [type="reset"]:hover, [type="reset"]:focus, + a.button:hover, + a.button:focus, label.button:hover, label.button:focus, .button:hover, .button:focus, + a[role="button"]:hover, + a[role="button"]:focus, label[role="button"]:hover, label[role="button"]:focus, [role="button"]:hover, [role="button"]:focus { + background: var(--button-hover-back-color); + border-color: var(--button-hover-border-color); } + +input:disabled, input[disabled], textarea:disabled, textarea[disabled], select:disabled, select[disabled], button:disabled, button[disabled], .button:disabled, .button[disabled], [role="button"]:disabled, [role="button"][disabled] { + cursor: not-allowed; + opacity: 0.75; } + +.button-group { + display: flex; + border: 0.0714285714rem solid var(--button-group-border-color); + border-radius: var(--universal-border-radius); + margin: var(--universal-margin); } + .button-group > button, .button-group [type="button"], .button-group > [type="submit"], .button-group > [type="reset"], .button-group > .button, .button-group > [role="button"] { + margin: 0; + max-width: 100%; + flex: 1 1 auto; + text-align: center; + border: 0; + border-radius: 0; + box-shadow: none; } + .button-group > :not(:first-child) { + border-left: 0.0714285714rem solid var(--button-group-border-color); } + @media screen and (max-width: 499px) { + .button-group { + flex-direction: column; } + .button-group > :not(:first-child) { + border: 0; + border-top: 0.0714285714rem solid var(--button-group-border-color); } } + +/* + Custom elements for forms and input elements. +*/ +button.primary, [type="button"].primary, [type="submit"].primary, [type="reset"].primary, .button.primary, [role="button"].primary { + --button-back-color: #1976d2; + --button-fore-color: #f8f8f8; } + button.primary:hover, button.primary:focus, [type="button"].primary:hover, [type="button"].primary:focus, [type="submit"].primary:hover, [type="submit"].primary:focus, [type="reset"].primary:hover, [type="reset"].primary:focus, .button.primary:hover, .button.primary:focus, [role="button"].primary:hover, [role="button"].primary:focus { + --button-hover-back-color: #1565c0; } + +button.secondary, [type="button"].secondary, [type="submit"].secondary, [type="reset"].secondary, .button.secondary, [role="button"].secondary { + --button-back-color: #d32f2f; + --button-fore-color: #f8f8f8; } + button.secondary:hover, button.secondary:focus, [type="button"].secondary:hover, [type="button"].secondary:focus, [type="submit"].secondary:hover, [type="submit"].secondary:focus, [type="reset"].secondary:hover, [type="reset"].secondary:focus, .button.secondary:hover, .button.secondary:focus, [role="button"].secondary:hover, [role="button"].secondary:focus { + --button-hover-back-color: #c62828; } + +button.tertiary, [type="button"].tertiary, [type="submit"].tertiary, [type="reset"].tertiary, .button.tertiary, [role="button"].tertiary { + --button-back-color: #308732; + --button-fore-color: #f8f8f8; } + button.tertiary:hover, button.tertiary:focus, [type="button"].tertiary:hover, [type="button"].tertiary:focus, [type="submit"].tertiary:hover, [type="submit"].tertiary:focus, [type="reset"].tertiary:hover, [type="reset"].tertiary:focus, .button.tertiary:hover, .button.tertiary:focus, [role="button"].tertiary:hover, [role="button"].tertiary:focus { + --button-hover-back-color: #277529; } + +button.inverse, [type="button"].inverse, [type="submit"].inverse, [type="reset"].inverse, .button.inverse, [role="button"].inverse { + --button-back-color: #212121; + --button-fore-color: #f8f8f8; } + button.inverse:hover, button.inverse:focus, [type="button"].inverse:hover, [type="button"].inverse:focus, [type="submit"].inverse:hover, [type="submit"].inverse:focus, [type="reset"].inverse:hover, [type="reset"].inverse:focus, .button.inverse:hover, .button.inverse:focus, [role="button"].inverse:hover, [role="button"].inverse:focus { + --button-hover-back-color: #111; } + +button.small, [type="button"].small, [type="submit"].small, [type="reset"].small, .button.small, [role="button"].small { + padding: calc(0.5 * var(--universal-padding)) calc(0.75 * var(--universal-padding)); + margin: var(--universal-margin); } + +button.large, [type="button"].large, [type="submit"].large, [type="reset"].large, .button.large, [role="button"].large { + padding: calc(1.5 * var(--universal-padding)) calc(2 * var(--universal-padding)); + margin: var(--universal-margin); } + +/* + Definitions for navigation elements. +*/ +/* Navigation module CSS variable definitions */ +:root { + --header-back-color: #03234b; + --header-hover-back-color: #ffd200; + --header-fore-color: #ffffff; + --header-border-color: #3cb4e6; + --nav-back-color: #ffffff; + --nav-hover-back-color: #ffe97f; + --nav-fore-color: #e6007e; + --nav-border-color: #3cb4e6; + --nav-link-color: #3cb4e6; + --footer-fore-color: #ffffff; + --footer-back-color: #03234b; + --footer-border-color: #3cb4e6; + --footer-link-color: #3cb4e6; + --drawer-back-color: #ffffff; + --drawer-hover-back-color: #ffe97f; + --drawer-border-color: #3cb4e6; + --drawer-close-color: #e6007e; } + +header { + height: 2.75rem; + background: var(--header-back-color); + color: var(--header-fore-color); + border-bottom: 0.0714285714rem solid var(--header-border-color); + padding: calc(var(--universal-padding) / 4) 0; + white-space: nowrap; + overflow-x: auto; + overflow-y: hidden; } + header.row { + box-sizing: content-box; } + header .logo { + color: var(--header-fore-color); + font-size: 1.75rem; + padding: var(--universal-padding) calc(2 * var(--universal-padding)); + text-decoration: none; } + header button, header [type="button"], header .button, header [role="button"] { + box-sizing: border-box; + position: relative; + top: calc(0rem - var(--universal-padding) / 4); + height: calc(3.1875rem + var(--universal-padding) / 2); + background: var(--header-back-color); + line-height: calc(3.1875rem - var(--universal-padding) * 1.5); + text-align: center; + color: var(--header-fore-color); + border: 0; + border-radius: 0; + margin: 0; + text-transform: uppercase; } + header button:hover, header button:focus, header [type="button"]:hover, header [type="button"]:focus, header .button:hover, header .button:focus, header [role="button"]:hover, header [role="button"]:focus { + background: var(--header-hover-back-color); } + +nav { + background: var(--nav-back-color); + color: var(--nav-fore-color); + border: 0.0714285714rem solid var(--nav-border-color); + border-radius: var(--universal-border-radius); + margin: var(--universal-margin); } + nav * { + padding: var(--universal-padding) calc(1.5 * var(--universal-padding)); } + nav a, nav a:visited { + display: block; + color: var(--nav-link-color); + border-radius: var(--universal-border-radius); + transition: background 0.3s; } + nav a:hover, nav a:focus, nav a:visited:hover, nav a:visited:focus { + text-decoration: none; + background: var(--nav-hover-back-color); } + nav .sublink-1 { + position: relative; + margin-left: calc(2 * var(--universal-padding)); } + nav .sublink-1:before { + position: absolute; + left: calc(var(--universal-padding) - 1 * var(--universal-padding)); + top: -0.0714285714rem; + content: ''; + height: 100%; + border: 0.0714285714rem solid var(--nav-border-color); + border-left: 0; } + nav .sublink-2 { + position: relative; + margin-left: calc(4 * var(--universal-padding)); } + nav .sublink-2:before { + position: absolute; + left: calc(var(--universal-padding) - 3 * var(--universal-padding)); + top: -0.0714285714rem; + content: ''; + height: 100%; + border: 0.0714285714rem solid var(--nav-border-color); + border-left: 0; } + +footer { + background: var(--footer-back-color); + color: var(--footer-fore-color); + border-top: 0.0714285714rem solid var(--footer-border-color); + padding: calc(2 * var(--universal-padding)) var(--universal-padding); + font-size: 0.875rem; } + footer a, footer a:visited { + color: var(--footer-link-color); } + +header.sticky { + position: -webkit-sticky; + position: sticky; + z-index: 1101; + top: 0; } + +footer.sticky { + position: -webkit-sticky; + position: sticky; + z-index: 1101; + bottom: 0; } + +.drawer-toggle:before { + display: inline-block; + position: relative; + vertical-align: bottom; + content: '\00a0\2261\00a0'; + font-family: sans-serif; + font-size: 1.5em; } +@media screen and (min-width: 500px) { + .drawer-toggle:not(.persistent) { + display: none; } } + +[type="checkbox"].drawer { + height: 1px; + width: 1px; + margin: -1px; + overflow: hidden; + position: absolute; + clip: rect(0 0 0 0); + -webkit-clip-path: inset(100%); + clip-path: inset(100%); } + [type="checkbox"].drawer + * { + display: block; + box-sizing: border-box; + position: fixed; + top: 0; + width: 320px; + height: 100vh; + overflow-y: auto; + background: var(--drawer-back-color); + border: 0.0714285714rem solid var(--drawer-border-color); + border-radius: 0; + margin: 0; + z-index: 1110; + right: -320px; + transition: right 0.3s; } + [type="checkbox"].drawer + * .drawer-close { + position: absolute; + top: var(--universal-margin); + right: var(--universal-margin); + z-index: 1111; + width: 2rem; + height: 2rem; + border-radius: var(--universal-border-radius); + padding: var(--universal-padding); + margin: 0; + cursor: pointer; + transition: background 0.3s; } + [type="checkbox"].drawer + * .drawer-close:before { + display: block; + content: '\00D7'; + color: var(--drawer-close-color); + position: relative; + font-family: sans-serif; + font-size: 2rem; + line-height: 1; + text-align: center; } + [type="checkbox"].drawer + * .drawer-close:hover, [type="checkbox"].drawer + * .drawer-close:focus { + background: var(--drawer-hover-back-color); } + @media screen and (max-width: 320px) { + [type="checkbox"].drawer + * { + width: 100%; } } + [type="checkbox"].drawer:checked + * { + right: 0; } + @media screen and (min-width: 500px) { + [type="checkbox"].drawer:not(.persistent) + * { + position: static; + height: 100%; + z-index: 1100; } + [type="checkbox"].drawer:not(.persistent) + * .drawer-close { + display: none; } } + +/* + Definitions for the responsive table component. +*/ +/* Table module CSS variable definitions. */ +:root { + --table-border-color: #03234b; + --table-border-separator-color: #03234b; + --table-head-back-color: #03234b; + --table-head-fore-color: #ffffff; + --table-body-back-color: #ffffff; + --table-body-fore-color: #03234b; + --table-body-alt-back-color: #f4f4f4; } + +table { + border-collapse: separate; + border-spacing: 0; + margin: 0; + display: flex; + flex: 0 1 auto; + flex-flow: row wrap; + padding: var(--universal-padding); + padding-top: 0; } + table caption { + font-size: 1rem; + margin: calc(2 * var(--universal-margin)) 0; + max-width: 100%; + flex: 0 0 100%; } + table thead, table tbody { + display: flex; + flex-flow: row wrap; + border: 0.0714285714rem solid var(--table-border-color); } + table thead { + z-index: 999; + border-radius: var(--universal-border-radius) var(--universal-border-radius) 0 0; + border-bottom: 0.0714285714rem solid var(--table-border-separator-color); } + table tbody { + border-top: 0; + margin-top: calc(0 - var(--universal-margin)); + border-radius: 0 0 var(--universal-border-radius) var(--universal-border-radius); } + table tr { + display: flex; + padding: 0; } + table th, table td { + padding: calc(0.5 * var(--universal-padding)); + font-size: 0.9rem; } + table th { + text-align: left; + background: var(--table-head-back-color); + color: var(--table-head-fore-color); } + table td { + background: var(--table-body-back-color); + color: var(--table-body-fore-color); + border-top: 0.0714285714rem solid var(--table-border-color); } + +table:not(.horizontal) { + overflow: auto; + max-height: 100%; } + table:not(.horizontal) thead, table:not(.horizontal) tbody { + max-width: 100%; + flex: 0 0 100%; } + table:not(.horizontal) tr { + flex-flow: row wrap; + flex: 0 0 100%; } + table:not(.horizontal) th, table:not(.horizontal) td { + flex: 1 0 0%; + overflow: hidden; + text-overflow: ellipsis; } + table:not(.horizontal) thead { + position: sticky; + top: 0; } + table:not(.horizontal) tbody tr:first-child td { + border-top: 0; } + +table.horizontal { + border: 0; } + table.horizontal thead, table.horizontal tbody { + border: 0; + flex: .2 0 0; + flex-flow: row nowrap; } + table.horizontal tbody { + overflow: auto; + justify-content: space-between; + flex: .8 0 0; + margin-left: 0; + padding-bottom: calc(var(--universal-padding) / 4); } + table.horizontal tr { + flex-direction: column; + flex: 1 0 auto; } + table.horizontal th, table.horizontal td { + width: auto; + border: 0; + border-bottom: 0.0714285714rem solid var(--table-border-color); } + table.horizontal th:not(:first-child), table.horizontal td:not(:first-child) { + border-top: 0; } + table.horizontal th { + text-align: right; + border-left: 0.0714285714rem solid var(--table-border-color); + border-right: 0.0714285714rem solid var(--table-border-separator-color); } + table.horizontal thead tr:first-child { + padding-left: 0; } + table.horizontal th:first-child, table.horizontal td:first-child { + border-top: 0.0714285714rem solid var(--table-border-color); } + table.horizontal tbody tr:last-child td { + border-right: 0.0714285714rem solid var(--table-border-color); } + table.horizontal tbody tr:last-child td:first-child { + border-top-right-radius: 0.25rem; } + table.horizontal tbody tr:last-child td:last-child { + border-bottom-right-radius: 0.25rem; } + table.horizontal thead tr:first-child th:first-child { + border-top-left-radius: 0.25rem; } + table.horizontal thead tr:first-child th:last-child { + border-bottom-left-radius: 0.25rem; } + +@media screen and (max-width: 499px) { + table, table.horizontal { + border-collapse: collapse; + border: 0; + width: 100%; + display: table; } + table thead, table th, table.horizontal thead, table.horizontal th { + border: 0; + height: 1px; + width: 1px; + margin: -1px; + overflow: hidden; + padding: 0; + position: absolute; + clip: rect(0 0 0 0); + -webkit-clip-path: inset(100%); + clip-path: inset(100%); } + table tbody, table.horizontal tbody { + border: 0; + display: table-row-group; } + table tr, table.horizontal tr { + display: block; + border: 0.0714285714rem solid var(--table-border-color); + border-radius: var(--universal-border-radius); + background: #ffffff; + padding: var(--universal-padding); + margin: var(--universal-margin); + margin-bottom: calc(1 * var(--universal-margin)); } + table th, table td, table.horizontal th, table.horizontal td { + width: auto; } + table td, table.horizontal td { + display: block; + border: 0; + text-align: right; } + table td:before, table.horizontal td:before { + content: attr(data-label); + float: left; + font-weight: 600; } + table th:first-child, table td:first-child, table.horizontal th:first-child, table.horizontal td:first-child { + border-top: 0; } + table tbody tr:last-child td, table.horizontal tbody tr:last-child td { + border-right: 0; } } +table tr:nth-of-type(2n) > td { + background: var(--table-body-alt-back-color); } + +@media screen and (max-width: 500px) { + table tr:nth-of-type(2n) { + background: var(--table-body-alt-back-color); } } +:root { + --table-body-hover-back-color: #90caf9; } + +table.hoverable tr:hover, table.hoverable tr:hover > td, table.hoverable tr:focus, table.hoverable tr:focus > td { + background: var(--table-body-hover-back-color); } + +@media screen and (max-width: 500px) { + table.hoverable tr:hover, table.hoverable tr:hover > td, table.hoverable tr:focus, table.hoverable tr:focus > td { + background: var(--table-body-hover-back-color); } } +/* + Definitions for contextual background elements, toasts and tooltips. +*/ +/* Contextual module CSS variable definitions */ +:root { + --mark-back-color: #3cb4e6; + --mark-fore-color: #ffffff; } + +mark { + background: var(--mark-back-color); + color: var(--mark-fore-color); + font-size: 0.95em; + line-height: 1em; + border-radius: var(--universal-border-radius); + padding: calc(var(--universal-padding) / 4) var(--universal-padding); } + mark.inline-block { + display: inline-block; + font-size: 1em; + line-height: 1.4; + padding: calc(var(--universal-padding) / 2) var(--universal-padding); } + +:root { + --toast-back-color: #424242; + --toast-fore-color: #fafafa; } + +.toast { + position: fixed; + bottom: calc(var(--universal-margin) * 3); + left: 50%; + transform: translate(-50%, -50%); + z-index: 1111; + color: var(--toast-fore-color); + background: var(--toast-back-color); + border-radius: calc(var(--universal-border-radius) * 16); + padding: var(--universal-padding) calc(var(--universal-padding) * 3); } + +:root { + --tooltip-back-color: #212121; + --tooltip-fore-color: #fafafa; } + +.tooltip { + position: relative; + display: inline-block; } + .tooltip:before, .tooltip:after { + position: absolute; + opacity: 0; + clip: rect(0 0 0 0); + -webkit-clip-path: inset(100%); + clip-path: inset(100%); + transition: all 0.3s; + z-index: 1010; + left: 50%; } + .tooltip:not(.bottom):before, .tooltip:not(.bottom):after { + bottom: 75%; } + .tooltip.bottom:before, .tooltip.bottom:after { + top: 75%; } + .tooltip:hover:before, .tooltip:hover:after, .tooltip:focus:before, .tooltip:focus:after { + opacity: 1; + clip: auto; + -webkit-clip-path: inset(0%); + clip-path: inset(0%); } + .tooltip:before { + content: ''; + background: transparent; + border: var(--universal-margin) solid transparent; + left: calc(50% - var(--universal-margin)); } + .tooltip:not(.bottom):before { + border-top-color: #212121; } + .tooltip.bottom:before { + border-bottom-color: #212121; } + .tooltip:after { + content: attr(aria-label); + color: var(--tooltip-fore-color); + background: var(--tooltip-back-color); + border-radius: var(--universal-border-radius); + padding: var(--universal-padding); + white-space: nowrap; + transform: translateX(-50%); } + .tooltip:not(.bottom):after { + margin-bottom: calc(2 * var(--universal-margin)); } + .tooltip.bottom:after { + margin-top: calc(2 * var(--universal-margin)); } + +:root { + --modal-overlay-color: rgba(0, 0, 0, 0.45); + --modal-close-color: #e6007e; + --modal-close-hover-color: #ffe97f; } + +[type="checkbox"].modal { + height: 1px; + width: 1px; + margin: -1px; + overflow: hidden; + position: absolute; + clip: rect(0 0 0 0); + -webkit-clip-path: inset(100%); + clip-path: inset(100%); } + [type="checkbox"].modal + div { + position: fixed; + top: 0; + left: 0; + display: none; + width: 100vw; + height: 100vh; + background: var(--modal-overlay-color); } + [type="checkbox"].modal + div .card { + margin: 0 auto; + max-height: 50vh; + overflow: auto; } + [type="checkbox"].modal + div .card .modal-close { + position: absolute; + top: 0; + right: 0; + width: 1.75rem; + height: 1.75rem; + border-radius: var(--universal-border-radius); + padding: var(--universal-padding); + margin: 0; + cursor: pointer; + transition: background 0.3s; } + [type="checkbox"].modal + div .card .modal-close:before { + display: block; + content: '\00D7'; + color: var(--modal-close-color); + position: relative; + font-family: sans-serif; + font-size: 1.75rem; + line-height: 1; + text-align: center; } + [type="checkbox"].modal + div .card .modal-close:hover, [type="checkbox"].modal + div .card .modal-close:focus { + background: var(--modal-close-hover-color); } + [type="checkbox"].modal:checked + div { + display: flex; + flex: 0 1 auto; + z-index: 1200; } + [type="checkbox"].modal:checked + div .card .modal-close { + z-index: 1211; } + +:root { + --collapse-label-back-color: #03234b; + --collapse-label-fore-color: #ffffff; + --collapse-label-hover-back-color: #3cb4e6; + --collapse-selected-label-back-color: #3cb4e6; + --collapse-border-color: var(--collapse-label-back-color); + --collapse-selected-border-color: #ceecf8; + --collapse-content-back-color: #ffffff; + --collapse-selected-label-border-color: #3cb4e6; } + +.collapse { + width: calc(100% - 2 * var(--universal-margin)); + opacity: 1; + display: flex; + flex-direction: column; + margin: var(--universal-margin); + border-radius: var(--universal-border-radius); } + .collapse > [type="radio"], .collapse > [type="checkbox"] { + height: 1px; + width: 1px; + margin: -1px; + overflow: hidden; + position: absolute; + clip: rect(0 0 0 0); + -webkit-clip-path: inset(100%); + clip-path: inset(100%); } + .collapse > label { + flex-grow: 1; + display: inline-block; + height: 1.25rem; + cursor: pointer; + transition: background 0.2s; + color: var(--collapse-label-fore-color); + background: var(--collapse-label-back-color); + border: 0.0714285714rem solid var(--collapse-selected-border-color); + padding: calc(1.25 * var(--universal-padding)); } + .collapse > label:hover, .collapse > label:focus { + background: var(--collapse-label-hover-back-color); } + .collapse > label + div { + flex-basis: auto; + height: 1px; + width: 1px; + margin: -1px; + overflow: hidden; + position: absolute; + clip: rect(0 0 0 0); + -webkit-clip-path: inset(100%); + clip-path: inset(100%); + transition: max-height 0.3s; + max-height: 1px; } + .collapse > :checked + label { + background: var(--collapse-selected-label-back-color); + border-color: var(--collapse-selected-label-border-color); } + .collapse > :checked + label + div { + box-sizing: border-box; + position: relative; + width: 100%; + height: auto; + overflow: auto; + margin: 0; + background: var(--collapse-content-back-color); + border: 0.0714285714rem solid var(--collapse-selected-border-color); + border-top: 0; + padding: var(--universal-padding); + clip: auto; + -webkit-clip-path: inset(0%); + clip-path: inset(0%); + max-height: 100%; } + .collapse > label:not(:first-of-type) { + border-top: 0; } + .collapse > label:first-of-type { + border-radius: var(--universal-border-radius) var(--universal-border-radius) 0 0; } + .collapse > label:last-of-type:not(:first-of-type) { + border-radius: 0 0 var(--universal-border-radius) var(--universal-border-radius); } + .collapse > label:last-of-type:first-of-type { + border-radius: var(--universal-border-radius); } + .collapse > :checked:last-of-type:not(:first-of-type) + label { + border-radius: 0; } + .collapse > :checked:last-of-type + label + div { + border-radius: 0 0 var(--universal-border-radius) var(--universal-border-radius); } + +/* + Custom elements for contextual background elements, toasts and tooltips. +*/ +mark.tertiary { + --mark-back-color: #3cb4e6; } + +mark.tag { + padding: calc(var(--universal-padding)/2) var(--universal-padding); + border-radius: 1em; } + +/* + Definitions for progress elements and spinners. +*/ +/* Progress module CSS variable definitions */ +:root { + --progress-back-color: #3cb4e6; + --progress-fore-color: #555; } + +progress { + display: block; + vertical-align: baseline; + -webkit-appearance: none; + -moz-appearance: none; + appearance: none; + height: 0.75rem; + width: calc(100% - 2 * var(--universal-margin)); + margin: var(--universal-margin); + border: 0; + border-radius: calc(2 * var(--universal-border-radius)); + background: var(--progress-back-color); + color: var(--progress-fore-color); } + progress::-webkit-progress-value { + background: var(--progress-fore-color); + border-top-left-radius: calc(2 * var(--universal-border-radius)); + border-bottom-left-radius: calc(2 * var(--universal-border-radius)); } + progress::-webkit-progress-bar { + background: var(--progress-back-color); } + progress::-moz-progress-bar { + background: var(--progress-fore-color); + border-top-left-radius: calc(2 * var(--universal-border-radius)); + border-bottom-left-radius: calc(2 * var(--universal-border-radius)); } + progress[value="1000"]::-webkit-progress-value { + border-radius: calc(2 * var(--universal-border-radius)); } + progress[value="1000"]::-moz-progress-bar { + border-radius: calc(2 * var(--universal-border-radius)); } + progress.inline { + display: inline-block; + vertical-align: middle; + width: 60%; } + +:root { + --spinner-back-color: #ddd; + --spinner-fore-color: #555; } + +@keyframes spinner-donut-anim { + 0% { + transform: rotate(0deg); } + 100% { + transform: rotate(360deg); } } +.spinner { + display: inline-block; + margin: var(--universal-margin); + border: 0.25rem solid var(--spinner-back-color); + border-left: 0.25rem solid var(--spinner-fore-color); + border-radius: 50%; + width: 1.25rem; + height: 1.25rem; + animation: spinner-donut-anim 1.2s linear infinite; } + +/* + Custom elements for progress bars and spinners. +*/ +progress.primary { + --progress-fore-color: #1976d2; } + +progress.secondary { + --progress-fore-color: #d32f2f; } + +progress.tertiary { + --progress-fore-color: #308732; } + +.spinner.primary { + --spinner-fore-color: #1976d2; } + +.spinner.secondary { + --spinner-fore-color: #d32f2f; } + +.spinner.tertiary { + --spinner-fore-color: #308732; } + +/* + Definitions for icons - powered by Feather (https://feathericons.com/). +*/ +span[class^='icon-'] { + display: inline-block; + height: 1em; + width: 1em; + vertical-align: -0.125em; + background-size: contain; + margin: 0 calc(var(--universal-margin) / 4); } + span[class^='icon-'].secondary { + -webkit-filter: invert(25%); + filter: invert(25%); } + span[class^='icon-'].inverse { + -webkit-filter: invert(100%); + filter: invert(100%); } + +span.icon-alert { + background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2303234b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'%3E%3C/circle%3E%3Cline x1='12' y1='8' x2='12' y2='12'%3E%3C/line%3E%3Cline x1='12' y1='16' x2='12' y2='16'%3E%3C/line%3E%3C/svg%3E"); } +span.icon-bookmark { + background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2303234b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M19 21l-7-5-7 5V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z'%3E%3C/path%3E%3C/svg%3E"); } +span.icon-calendar { + background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2303234b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2' ry='2'%3E%3C/rect%3E%3Cline x1='16' y1='2' x2='16' y2='6'%3E%3C/line%3E%3Cline x1='8' y1='2' x2='8' y2='6'%3E%3C/line%3E%3Cline x1='3' y1='10' x2='21' y2='10'%3E%3C/line%3E%3C/svg%3E"); } +span.icon-credit { + background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2303234b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='1' y='4' width='22' height='16' rx='2' ry='2'%3E%3C/rect%3E%3Cline x1='1' y1='10' x2='23' y2='10'%3E%3C/line%3E%3C/svg%3E"); } +span.icon-edit { + background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2303234b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 14.66V20a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h5.34'%3E%3C/path%3E%3Cpolygon points='18 2 22 6 12 16 8 16 8 12 18 2'%3E%3C/polygon%3E%3C/svg%3E"); } +span.icon-link { + background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2303234b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6'%3E%3C/path%3E%3Cpolyline points='15 3 21 3 21 9'%3E%3C/polyline%3E%3Cline x1='10' y1='14' x2='21' y2='3'%3E%3C/line%3E%3C/svg%3E"); } +span.icon-help { + background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2303234b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3'%3E%3C/path%3E%3Ccircle cx='12' cy='12' r='10'%3E%3C/circle%3E%3Cline x1='12' y1='17' x2='12' y2='17'%3E%3C/line%3E%3C/svg%3E"); } +span.icon-home { + background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2303234b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z'%3E%3C/path%3E%3Cpolyline points='9 22 9 12 15 12 15 22'%3E%3C/polyline%3E%3C/svg%3E"); } +span.icon-info { + background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2303234b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'%3E%3C/circle%3E%3Cline x1='12' y1='16' x2='12' y2='12'%3E%3C/line%3E%3Cline x1='12' y1='8' x2='12' y2='8'%3E%3C/line%3E%3C/svg%3E"); } +span.icon-lock { + background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2303234b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='11' width='18' height='11' rx='2' ry='2'%3E%3C/rect%3E%3Cpath d='M7 11V7a5 5 0 0 1 10 0v4'%3E%3C/path%3E%3C/svg%3E"); } +span.icon-mail { + background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2303234b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z'%3E%3C/path%3E%3Cpolyline points='22,6 12,13 2,6'%3E%3C/polyline%3E%3C/svg%3E"); } +span.icon-location { + background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2303234b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 10c0 7-9 13-9 13s-9-6-9-13a9 9 0 0 1 18 0z'%3E%3C/path%3E%3Ccircle cx='12' cy='10' r='3'%3E%3C/circle%3E%3C/svg%3E"); } +span.icon-phone { + background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2303234b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z'%3E%3C/path%3E%3C/svg%3E"); } +span.icon-rss { + background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2303234b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 11a9 9 0 0 1 9 9'%3E%3C/path%3E%3Cpath d='M4 4a16 16 0 0 1 16 16'%3E%3C/path%3E%3Ccircle cx='5' cy='19' r='1'%3E%3C/circle%3E%3C/svg%3E"); } +span.icon-search { + background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2303234b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E"); } +span.icon-settings { + background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2303234b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='3'%3E%3C/circle%3E%3Cpath d='M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z'%3E%3C/path%3E%3C/svg%3E"); } +span.icon-share { + background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2303234b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='18' cy='5' r='3'%3E%3C/circle%3E%3Ccircle cx='6' cy='12' r='3'%3E%3C/circle%3E%3Ccircle cx='18' cy='19' r='3'%3E%3C/circle%3E%3Cline x1='8.59' y1='13.51' x2='15.42' y2='17.49'%3E%3C/line%3E%3Cline x1='15.41' y1='6.51' x2='8.59' y2='10.49'%3E%3C/line%3E%3C/svg%3E"); } +span.icon-cart { + background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2303234b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='9' cy='21' r='1'%3E%3C/circle%3E%3Ccircle cx='20' cy='21' r='1'%3E%3C/circle%3E%3Cpath d='M1 1h4l2.68 13.39a2 2 0 0 0 2 1.61h9.72a2 2 0 0 0 2-1.61L23 6H6'%3E%3C/path%3E%3C/svg%3E"); } +span.icon-upload { + background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2303234b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4'%3E%3C/path%3E%3Cpolyline points='17 8 12 3 7 8'%3E%3C/polyline%3E%3Cline x1='12' y1='3' x2='12' y2='15'%3E%3C/line%3E%3C/svg%3E"); } +span.icon-user { + background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2303234b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2'%3E%3C/path%3E%3Ccircle cx='12' cy='7' r='4'%3E%3C/circle%3E%3C/svg%3E"); } + +/* + Definitions for STMicroelectronics icons (https://brandportal.st.com/document/26). +*/ +span.icon-st-update { + background-image: url("Update.svg"); } +span.icon-st-add { + background-image: url("Add button.svg"); } + +/* + Definitions for utilities and helper classes. +*/ +/* Utility module CSS variable definitions */ +:root { + --generic-border-color: rgba(0, 0, 0, 0.3); + --generic-box-shadow: 0 0.2857142857rem 0.2857142857rem 0 rgba(0, 0, 0, 0.125), 0 0.1428571429rem 0.1428571429rem -0.1428571429rem rgba(0, 0, 0, 0.125); } + +.hidden { + display: none !important; } + +.visually-hidden { + position: absolute !important; + width: 1px !important; + height: 1px !important; + margin: -1px !important; + border: 0 !important; + padding: 0 !important; + clip: rect(0 0 0 0) !important; + -webkit-clip-path: inset(100%) !important; + clip-path: inset(100%) !important; + overflow: hidden !important; } + +.bordered { + border: 0.0714285714rem solid var(--generic-border-color) !important; } + +.rounded { + border-radius: var(--universal-border-radius) !important; } + +.circular { + border-radius: 50% !important; } + +.shadowed { + box-shadow: var(--generic-box-shadow) !important; } + +.responsive-margin { + margin: calc(var(--universal-margin) / 4) !important; } + @media screen and (min-width: 500px) { + .responsive-margin { + margin: calc(var(--universal-margin) / 2) !important; } } + @media screen and (min-width: 1280px) { + .responsive-margin { + margin: var(--universal-margin) !important; } } + +.responsive-padding { + padding: calc(var(--universal-padding) / 4) !important; } + @media screen and (min-width: 500px) { + .responsive-padding { + padding: calc(var(--universal-padding) / 2) !important; } } + @media screen and (min-width: 1280px) { + .responsive-padding { + padding: var(--universal-padding) !important; } } + +@media screen and (max-width: 499px) { + .hidden-sm { + display: none !important; } } +@media screen and (min-width: 500px) and (max-width: 1279px) { + .hidden-md { + display: none !important; } } +@media screen and (min-width: 1280px) { + .hidden-lg { + display: none !important; } } +@media screen and (max-width: 499px) { + .visually-hidden-sm { + position: absolute !important; + width: 1px !important; + height: 1px !important; + margin: -1px !important; + border: 0 !important; + padding: 0 !important; + clip: rect(0 0 0 0) !important; + -webkit-clip-path: inset(100%) !important; + clip-path: inset(100%) !important; + overflow: hidden !important; } } +@media screen and (min-width: 500px) and (max-width: 1279px) { + .visually-hidden-md { + position: absolute !important; + width: 1px !important; + height: 1px !important; + margin: -1px !important; + border: 0 !important; + padding: 0 !important; + clip: rect(0 0 0 0) !important; + -webkit-clip-path: inset(100%) !important; + clip-path: inset(100%) !important; + overflow: hidden !important; } } +@media screen and (min-width: 1280px) { + .visually-hidden-lg { + position: absolute !important; + width: 1px !important; + height: 1px !important; + margin: -1px !important; + border: 0 !important; + padding: 0 !important; + clip: rect(0 0 0 0) !important; + -webkit-clip-path: inset(100%) !important; + clip-path: inset(100%) !important; + overflow: hidden !important; } } + +/*# sourceMappingURL=mini-custom.css.map */ + +img[alt="ST logo"] { display: block; margin: auto; width: 75%; max-width: 250px; min-width: 71px; } +img[alt="Cube logo"] { float: right; width: 30%; max-width: 10rem; min-width: 8rem; padding-right: 1rem;} + +.figure { + display: block; + margin-left: auto; + margin-right: auto; + text-align: center; +} \ No newline at end of file diff --git a/Drivers/BSP/Components/lps22hh/_htmresc/st_logo_2020.png b/Drivers/BSP/Components/lps22hh/_htmresc/st_logo_2020.png new file mode 100644 index 0000000..d6cebb5 Binary files /dev/null and b/Drivers/BSP/Components/lps22hh/_htmresc/st_logo_2020.png differ diff --git a/Drivers/BSP/Components/lps22hh/lps22hh.c b/Drivers/BSP/Components/lps22hh/lps22hh.c new file mode 100644 index 0000000..3dd12a4 --- /dev/null +++ b/Drivers/BSP/Components/lps22hh/lps22hh.c @@ -0,0 +1,1081 @@ +/** + ****************************************************************************** + * @file lps22hh.c + * @author MEMS Software Solutions Team + * @brief LPS22HH driver file + ****************************************************************************** + * @attention + * + * Copyright (c) 2019 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "lps22hh.h" + +/** @addtogroup BSP BSP + * @{ + */ + +/** @addtogroup Component Component + * @{ + */ + +/** @defgroup LPS22HH LPS22HH + * @{ + */ + +/** @defgroup LPS22HH_Exported_Variables LPS22HH Exported Variables + * @{ + */ + +LPS22HH_CommonDrv_t LPS22HH_COMMON_Driver = +{ + LPS22HH_Init, + LPS22HH_DeInit, + LPS22HH_ReadID, + LPS22HH_GetCapabilities, +}; + +LPS22HH_PRESS_Drv_t LPS22HH_PRESS_Driver = +{ + LPS22HH_PRESS_Enable, + LPS22HH_PRESS_Disable, + LPS22HH_PRESS_GetOutputDataRate, + LPS22HH_PRESS_SetOutputDataRate, + LPS22HH_PRESS_GetPressure, +}; + +LPS22HH_TEMP_Drv_t LPS22HH_TEMP_Driver = +{ + LPS22HH_TEMP_Enable, + LPS22HH_TEMP_Disable, + LPS22HH_TEMP_GetOutputDataRate, + LPS22HH_TEMP_SetOutputDataRate, + LPS22HH_TEMP_GetTemperature, +}; + +/** + * @} + */ + +/** @defgroup LPS22HH_Private_Function_Prototypes LPS22HH Private Function Prototypes + * @{ + */ + +static int32_t ReadRegWrap(void *Handle, uint8_t Reg, uint8_t *pData, uint16_t Length); +static int32_t WriteRegWrap(void *Handle, uint8_t Reg, uint8_t *pData, uint16_t Length); +static int32_t LPS22HH_GetOutputDataRate(LPS22HH_Object_t *pObj, float *Odr); +static int32_t LPS22HH_SetOutputDataRate_When_Enabled(LPS22HH_Object_t *pObj, float Odr); +static int32_t LPS22HH_SetOutputDataRate_When_Disabled(LPS22HH_Object_t *pObj, float Odr); +static int32_t LPS22HH_Initialize(LPS22HH_Object_t *pObj); + +/** + * @} + */ + +/** @defgroup LPS22HH_Exported_Functions LPS22HH Exported Functions + * @{ + */ + +/** + * @brief Register Component Bus IO operations + * @param pObj the device pObj + * @retval 0 in case of success, an error code otherwise + */ +int32_t LPS22HH_RegisterBusIO(LPS22HH_Object_t *pObj, LPS22HH_IO_t *pIO) +{ + int32_t ret = LPS22HH_OK; + + if (pObj == NULL) + { + ret = LPS22HH_ERROR; + } + else + { + pObj->IO.Init = pIO->Init; + pObj->IO.DeInit = pIO->DeInit; + pObj->IO.BusType = pIO->BusType; + pObj->IO.Address = pIO->Address; + pObj->IO.WriteReg = pIO->WriteReg; + pObj->IO.ReadReg = pIO->ReadReg; + pObj->IO.GetTick = pIO->GetTick; + + pObj->Ctx.read_reg = ReadRegWrap; + pObj->Ctx.write_reg = WriteRegWrap; + pObj->Ctx.mdelay = pIO->Delay; + pObj->Ctx.handle = pObj; + + if (pObj->IO.Init == NULL) + { + ret = LPS22HH_ERROR; + } + else if (pObj->IO.Init() != LPS22HH_OK) + { + ret = LPS22HH_ERROR; + } + else + { + if (pObj->IO.BusType == LPS22HH_SPI_3WIRES_BUS) /* SPI 3-Wires */ + { + /* Enable the SPI 3-Wires support only the first time */ + if (pObj->is_initialized == 0U) + { + /* Enable SPI 3-Wires on the component */ + uint8_t data = 0x01; + + if (LPS22HH_Write_Reg(pObj, LPS22HH_CTRL_REG1, data) != LPS22HH_OK) + { + ret = LPS22HH_ERROR; + } + } + } + } + } + + return ret; +} + +/** + * @brief Initialize the LPS22HH sensor + * @param pObj the device pObj + * @retval 0 in case of success, an error code otherwise + */ +int32_t LPS22HH_Init(LPS22HH_Object_t *pObj) +{ + if (pObj->is_initialized == 0U) + { + if (LPS22HH_Initialize(pObj) != LPS22HH_OK) + { + return LPS22HH_ERROR; + } + } + + pObj->is_initialized = 1U; + + return LPS22HH_OK; +} + +/** + * @brief Deinitialize the LPS22HH sensor + * @param pObj the device pObj + * @retval 0 in case of success, an error code otherwise + */ +int32_t LPS22HH_DeInit(LPS22HH_Object_t *pObj) +{ + if (pObj->is_initialized == 1U) + { + if (LPS22HH_PRESS_Disable(pObj) != LPS22HH_OK) + { + return LPS22HH_ERROR; + } + + if (LPS22HH_TEMP_Disable(pObj) != LPS22HH_OK) + { + return LPS22HH_ERROR; + } + } + + pObj->is_initialized = 0; + + return LPS22HH_OK; +} + +/** + * @brief Get WHO_AM_I value + * @param pObj the device pObj + * @param Id the WHO_AM_I value + * @retval 0 in case of success, an error code otherwise + */ +int32_t LPS22HH_ReadID(LPS22HH_Object_t *pObj, uint8_t *Id) +{ + if (lps22hh_device_id_get(&(pObj->Ctx), Id) != LPS22HH_OK) + { + return LPS22HH_ERROR; + } + + return LPS22HH_OK; +} + +/** + * @brief Get LPS22HH sensor capabilities + * @param pObj Component object pointer + * @param Capabilities pointer to LPS22HH sensor capabilities + * @retval 0 in case of success, an error code otherwise + */ +int32_t LPS22HH_GetCapabilities(LPS22HH_Object_t *pObj, LPS22HH_Capabilities_t *Capabilities) +{ + /* Prevent unused argument(s) compilation warning */ + (void)(pObj); + + Capabilities->Humidity = 0; + Capabilities->Pressure = 1; + Capabilities->Temperature = 1; + Capabilities->LowPower = 0; + Capabilities->HumMaxOdr = 0.0f; + Capabilities->TempMaxOdr = 200.0f; + Capabilities->PressMaxOdr = 200.0f; + return LPS22HH_OK; +} + +/** + * @brief Get the LPS22HH initialization status + * @param pObj the device pObj + * @param Status 1 if initialized, 0 otherwise + * @retval 0 in case of success, an error code otherwise + */ +int32_t LPS22HH_Get_Init_Status(LPS22HH_Object_t *pObj, uint8_t *Status) +{ + if (pObj == NULL) + { + return LPS22HH_ERROR; + } + + *Status = pObj->is_initialized; + + return LPS22HH_OK; +} + +/** + * @brief Enable the LPS22HH pressure sensor + * @param pObj the device pObj + * @retval 0 in case of success, an error code otherwise + */ +int32_t LPS22HH_PRESS_Enable(LPS22HH_Object_t *pObj) +{ + /* Check if the component is already enabled */ + if (pObj->press_is_enabled == 1U) + { + return LPS22HH_OK; + } + + /* Output data rate selection. */ + if (lps22hh_data_rate_set(&(pObj->Ctx), pObj->last_odr) != LPS22HH_OK) + { + return LPS22HH_ERROR; + } + + pObj->press_is_enabled = 1; + + return LPS22HH_OK; +} + +/** + * @brief Disable the LPS22HH pressure sensor + * @param pObj the device pObj + * @retval 0 in case of success, an error code otherwise + */ +int32_t LPS22HH_PRESS_Disable(LPS22HH_Object_t *pObj) +{ + /* Check if the component is already disabled */ + if (pObj->press_is_enabled == 0U) + { + return LPS22HH_OK; + } + + /* Check if the LPS22HH temperature sensor is still enable. */ + /* If yes, skip the disable function, if not call disable function */ + if (pObj->temp_is_enabled == 0U) + { + /* Get current output data rate. */ + if (lps22hh_data_rate_get(&(pObj->Ctx), &pObj->last_odr) != LPS22HH_OK) + { + return LPS22HH_ERROR; + } + + /* Output data rate selection - power down. */ + if (lps22hh_data_rate_set(&(pObj->Ctx), LPS22HH_POWER_DOWN) != LPS22HH_OK) + { + return LPS22HH_ERROR; + } + } + + pObj->press_is_enabled = 0; + + return LPS22HH_OK; +} + +/** + * @brief Get the LPS22HH pressure sensor output data rate + * @param pObj the device pObj + * @param Odr pointer where the output data rate is written + * @retval 0 in case of success, an error code otherwise + */ +int32_t LPS22HH_PRESS_GetOutputDataRate(LPS22HH_Object_t *pObj, float *Odr) +{ + return LPS22HH_GetOutputDataRate(pObj, Odr); +} + +/** + * @brief Set the LPS22HH pressure sensor output data rate + * @param pObj the device pObj + * @param Odr the output data rate value to be set + * @retval 0 in case of success, an error code otherwise + */ +int32_t LPS22HH_PRESS_SetOutputDataRate(LPS22HH_Object_t *pObj, float Odr) +{ + /* Check if the component is enabled */ + if (pObj->press_is_enabled == 1U) + { + return LPS22HH_SetOutputDataRate_When_Enabled(pObj, Odr); + } + else + { + return LPS22HH_SetOutputDataRate_When_Disabled(pObj, Odr); + } +} + +/** + * @brief Get the LPS22HH pressure value + * @param pObj the device pObj + * @param Value pointer where the pressure value is written + * @retval 0 in case of success, an error code otherwise + */ +int32_t LPS22HH_PRESS_GetPressure(LPS22HH_Object_t *pObj, float *Value) +{ + lps22hh_axis1bit32_t data_raw_pressure; + + (void)memset(data_raw_pressure.u8bit, 0x00, sizeof(int32_t)); + if (lps22hh_pressure_raw_get(&(pObj->Ctx), (uint32_t *)&data_raw_pressure.i32bit) != LPS22HH_OK) + { + return LPS22HH_ERROR; + } + + *Value = lps22hh_from_lsb_to_hpa((uint32_t)data_raw_pressure.i32bit); + + return LPS22HH_OK; +} + +/** + * @brief Get the LPS22HH pressure data ready bit value + * @param pObj the device pObj + * @param Status the status of data ready bit + * @retval 0 in case of success, an error code otherwise + */ +int32_t LPS22HH_PRESS_Get_DRDY_Status(LPS22HH_Object_t *pObj, uint8_t *Status) +{ + if (lps22hh_press_flag_data_ready_get(&(pObj->Ctx), Status) != LPS22HH_OK) + { + return LPS22HH_ERROR; + } + + return LPS22HH_OK; +} + +/** + * @brief Enable the LPS22HH temperature sensor + * @param pObj the device pObj + * @retval 0 in case of success, an error code otherwise + */ +int32_t LPS22HH_TEMP_Enable(LPS22HH_Object_t *pObj) +{ + /* Check if the component is already enabled */ + if (pObj->temp_is_enabled == 1U) + { + return LPS22HH_OK; + } + + /* Output data rate selection. */ + if (lps22hh_data_rate_set(&(pObj->Ctx), pObj->last_odr) != LPS22HH_OK) + { + return LPS22HH_ERROR; + } + + pObj->temp_is_enabled = 1; + + return LPS22HH_OK; +} + +/** + * @brief Disable the LPS22HH temperature sensor + * @param pObj the device pObj + * @retval 0 in case of success, an error code otherwise + */ +int32_t LPS22HH_TEMP_Disable(LPS22HH_Object_t *pObj) +{ + /* Check if the component is already disabled */ + if (pObj->temp_is_enabled == 0U) + { + return LPS22HH_OK; + } + + /* Check if the LPS22HH pressure sensor is still enable. */ + /* If yes, skip the disable function, if not call disable function */ + if (pObj->press_is_enabled == 0U) + { + /* Get current output data rate. */ + if (lps22hh_data_rate_get(&(pObj->Ctx), &pObj->last_odr) != LPS22HH_OK) + { + return LPS22HH_ERROR; + } + + /* Output data rate selection - power down. */ + if (lps22hh_data_rate_set(&(pObj->Ctx), LPS22HH_POWER_DOWN) != LPS22HH_OK) + { + return LPS22HH_ERROR; + } + } + + pObj->temp_is_enabled = 0; + + return LPS22HH_OK; +} + +/** + * @brief Get the LPS22HH temperature sensor output data rate + * @param pObj the device pObj + * @param Odr pointer where the output data rate is written + * @retval 0 in case of success, an error code otherwise + */ +int32_t LPS22HH_TEMP_GetOutputDataRate(LPS22HH_Object_t *pObj, float *Odr) +{ + return LPS22HH_GetOutputDataRate(pObj, Odr); +} + +/** + * @brief Set the LPS22HH temperature sensor output data rate + * @param pObj the device pObj + * @param Odr the output data rate value to be set + * @retval 0 in case of success, an error code otherwise + */ +int32_t LPS22HH_TEMP_SetOutputDataRate(LPS22HH_Object_t *pObj, float Odr) +{ + /* Check if the component is enabled */ + if (pObj->temp_is_enabled == 1U) + { + return LPS22HH_SetOutputDataRate_When_Enabled(pObj, Odr); + } + else + { + return LPS22HH_SetOutputDataRate_When_Disabled(pObj, Odr); + } +} + +/** + * @brief Get the LPS22HH temperature value + * @param pObj the device pObj + * @param Value pointer where the temperature value is written + * @retval 0 in case of success, an error code otherwise + */ +int32_t LPS22HH_TEMP_GetTemperature(LPS22HH_Object_t *pObj, float *Value) +{ + lps22hh_axis1bit16_t data_raw_temperature; + + (void)memset(data_raw_temperature.u8bit, 0x00, sizeof(int16_t)); + if (lps22hh_temperature_raw_get(&(pObj->Ctx), &data_raw_temperature.i16bit) != LPS22HH_OK) + { + return LPS22HH_ERROR; + } + + *Value = lps22hh_from_lsb_to_celsius(data_raw_temperature.i16bit); + + return LPS22HH_OK; +} + +/** + * @brief Get the LPS22HH temperature data ready bit value + * @param pObj the device pObj + * @param Status the status of data ready bit + * @retval 0 in case of success, an error code otherwise + */ +int32_t LPS22HH_TEMP_Get_DRDY_Status(LPS22HH_Object_t *pObj, uint8_t *Status) +{ + if (lps22hh_temp_flag_data_ready_get(&(pObj->Ctx), Status) != LPS22HH_OK) + { + return LPS22HH_ERROR; + } + + return LPS22HH_OK; +} + +/** + * @brief Get the LPS22HH register value + * @param pObj the device pObj + * @param Reg address to be read + * @param Data value to be read + * @retval 0 in case of success, an error code otherwise + */ +int32_t LPS22HH_Read_Reg(LPS22HH_Object_t *pObj, uint8_t Reg, uint8_t *Data) +{ + if (lps22hh_read_reg(&(pObj->Ctx), Reg, Data, 1) != LPS22HH_OK) + { + return LPS22HH_ERROR; + } + + return LPS22HH_OK; +} + +/** + * @brief Set the LPS22HH register value + * @param pObj the device pObj + * @param Reg address to be written + * @param Data value to be written + * @retval 0 in case of success, an error code otherwise + */ +int32_t LPS22HH_Write_Reg(LPS22HH_Object_t *pObj, uint8_t Reg, uint8_t Data) +{ + if (lps22hh_write_reg(&(pObj->Ctx), Reg, &Data, 1) != LPS22HH_OK) + { + return LPS22HH_ERROR; + } + + return LPS22HH_OK; +} + +/** + * @} + */ + +/** @defgroup LPS22HH_Private_Functions LPS22HH Private Functions + * @{ + */ + +/** + * @brief Get output data rate + * @param pObj the device pObj + * @param Odr the output data rate value + * @retval 0 in case of success, an error code otherwise + */ +static int32_t LPS22HH_GetOutputDataRate(LPS22HH_Object_t *pObj, float *Odr) +{ + int32_t ret = LPS22HH_OK; + lps22hh_odr_t odr_low_level; + + if (lps22hh_data_rate_get(&(pObj->Ctx), &odr_low_level) != LPS22HH_OK) + { + return LPS22HH_ERROR; + } + + switch (odr_low_level) + { + case LPS22HH_POWER_DOWN: + *Odr = 0.0f; + break; + + case LPS22HH_1_Hz: + *Odr = 1.0f; + break; + + case LPS22HH_10_Hz: + *Odr = 10.0f; + break; + + case LPS22HH_25_Hz: + *Odr = 25.0f; + break; + + case LPS22HH_50_Hz: + *Odr = 50.0f; + break; + + case LPS22HH_75_Hz: + *Odr = 75.0f; + break; + + case LPS22HH_100_Hz: + *Odr = 100.0f; + break; + + case LPS22HH_200_Hz: + *Odr = 200.0f; + break; + + default: + ret = LPS22HH_ERROR; + break; + } + + return ret; +} + +/** + * @brief Set output data rate + * @param pObj the device pObj + * @param Odr the output data rate value to be set + * @retval 0 in case of success, an error code otherwise + */ +static int32_t LPS22HH_SetOutputDataRate_When_Enabled(LPS22HH_Object_t *pObj, float Odr) +{ + lps22hh_odr_t new_odr; + + new_odr = (Odr <= 1.0f) ? LPS22HH_1_Hz + : (Odr <= 10.0f) ? LPS22HH_10_Hz + : (Odr <= 25.0f) ? LPS22HH_25_Hz + : (Odr <= 50.0f) ? LPS22HH_50_Hz + : (Odr <= 75.0f) ? LPS22HH_75_Hz + : (Odr <= 100.0f) ? LPS22HH_100_Hz + : LPS22HH_200_Hz; + + if (lps22hh_data_rate_set(&(pObj->Ctx), new_odr) != LPS22HH_OK) + { + return LPS22HH_ERROR; + } + + if (lps22hh_data_rate_get(&(pObj->Ctx), &pObj->last_odr) != LPS22HH_OK) + { + return LPS22HH_ERROR; + } + + return LPS22HH_OK; +} + +/** + * @brief Set output data rate when disabled + * @param pObj the device pObj + * @param Odr the output data rate value to be set + * @retval 0 in case of success, an error code otherwise + */ +static int32_t LPS22HH_SetOutputDataRate_When_Disabled(LPS22HH_Object_t *pObj, float Odr) +{ + pObj->last_odr = (Odr <= 1.0f) ? LPS22HH_1_Hz + : (Odr <= 10.0f) ? LPS22HH_10_Hz + : (Odr <= 25.0f) ? LPS22HH_25_Hz + : (Odr <= 50.0f) ? LPS22HH_50_Hz + : (Odr <= 75.0f) ? LPS22HH_75_Hz + : (Odr <= 100.0f) ? LPS22HH_100_Hz + : LPS22HH_200_Hz; + + return LPS22HH_OK; +} + +/** + * @brief Initialize the LPS22HH sensor + * @param pObj the device pObj + * @retval 0 in case of success, an error code otherwise + */ +static int32_t LPS22HH_Initialize(LPS22HH_Object_t *pObj) +{ + /* Disable MIPI I3C(SM) interface */ + if (lps22hh_i3c_interface_set(&(pObj->Ctx), LPS22HH_I3C_DISABLE) != LPS22HH_OK) + { + return LPS22HH_ERROR; + } + + /* Power down the device, set Low Noise Enable (bit 5), clear One Shot (bit 4) */ + if (lps22hh_data_rate_set(&(pObj->Ctx), (lps22hh_odr_t)(LPS22HH_POWER_DOWN | 0x10)) != LPS22HH_OK) + { + return LPS22HH_ERROR; + } + + /* Disable low-pass filter on LPS22HH pressure data */ + if (lps22hh_lp_bandwidth_set(&(pObj->Ctx), LPS22HH_LPF_ODR_DIV_2) != LPS22HH_OK) + { + return LPS22HH_ERROR; + } + + /* Set block data update mode */ + if (lps22hh_block_data_update_set(&(pObj->Ctx), PROPERTY_ENABLE) != LPS22HH_OK) + { + return LPS22HH_ERROR; + } + + /* Set autoincrement for multi-byte read/write */ + if (lps22hh_auto_increment_set(&(pObj->Ctx), PROPERTY_ENABLE) != LPS22HH_OK) + { + return LPS22HH_ERROR; + } + + pObj->last_odr = LPS22HH_25_Hz; + + return LPS22HH_OK; +} + +/** + * @brief Get the LPS22HH FIFO data level + * @param pObj the device pObj + * @param Press the pressure data + * @param Temp the temperature data + * @retval 0 in case of success, an error code otherwise + */ +int32_t LPS22HH_FIFO_Get_Data(LPS22HH_Object_t *pObj, float *Press, float *Temp) +{ + lps22hh_axis1bit32_t data_raw_pressure; + lps22hh_axis1bit16_t data_raw_temperature; + + (void)memset(data_raw_pressure.u8bit, 0x00, sizeof(int32_t)); + if (lps22hh_fifo_pressure_raw_get(&(pObj->Ctx), (uint32_t *)&data_raw_pressure.i32bit) != LPS22HH_OK) + { + return LPS22HH_ERROR; + } + + *Press = lps22hh_from_lsb_to_hpa((uint32_t)data_raw_pressure.i32bit); + + (void)memset(data_raw_temperature.u8bit, 0x00, sizeof(int16_t)); + if (lps22hh_fifo_temperature_raw_get(&(pObj->Ctx), &data_raw_temperature.i16bit) != LPS22HH_OK) + { + return LPS22HH_ERROR; + } + + *Temp = lps22hh_from_lsb_to_celsius(data_raw_temperature.i16bit); + + return LPS22HH_OK; +} + +/** + * @brief Get the LPS22HH FIFO threshold + * @param pObj the device pObj + * @param Status the status of data ready bit + * @retval 0 in case of success, an error code otherwise + */ +int32_t LPS22HH_FIFO_Get_FTh_Status(LPS22HH_Object_t *pObj, uint8_t *Status) +{ + if (lps22hh_fifo_wtm_flag_get(&(pObj->Ctx), Status) != LPS22HH_OK) + { + return LPS22HH_ERROR; + } + + return LPS22HH_OK; +} + +/** + * @brief Get the LPS22HH FIFO full status + * @param pObj the device pObj + * @param Status the status of data ready bit + * @retval 0 in case of success, an error code otherwise + */ +int32_t LPS22HH_FIFO_Get_Full_Status(LPS22HH_Object_t *pObj, uint8_t *Status) +{ + if (lps22hh_fifo_full_flag_get(&(pObj->Ctx), Status) != LPS22HH_OK) + { + return LPS22HH_ERROR; + } + + return LPS22HH_OK; +} + +/** + * @brief Get the LPS22HH FIFO OVR status + * @param pObj the device pObj + * @param Status the status of data ready bit + * @retval 0 in case of success, an error code otherwise + */ +int32_t LPS22HH_FIFO_Get_Ovr_Status(LPS22HH_Object_t *pObj, uint8_t *Status) +{ + if (lps22hh_fifo_ovr_flag_get(&(pObj->Ctx), Status) != LPS22HH_OK) + { + return LPS22HH_ERROR; + } + + return LPS22HH_OK; +} + +/** + * @brief Get the LPS22HH FIFO data level + * @param pObj the device pObj + * @param Status the status of data ready bit + * @retval 0 in case of success, an error code otherwise + */ +int32_t LPS22HH_FIFO_Get_Level(LPS22HH_Object_t *pObj, uint8_t *Status) +{ + if (lps22hh_fifo_data_level_get(&(pObj->Ctx), Status) != LPS22HH_OK) + { + return LPS22HH_ERROR; + } + + return LPS22HH_OK; +} + +/** + * @brief Reset the FIFO interrupt + * @param pObj the device pObj + * @param interrupt The FIFO interrupt to be reset; values: 0 = FTH; 1 = FULL; 2 = OVR + * @retval 0 in case of success, an error code otherwise + */ +int32_t LPS22HH_FIFO_Reset_Interrupt(LPS22HH_Object_t *pObj, uint8_t interrupt) +{ + switch (interrupt) + { + case 0: + if (lps22hh_fifo_threshold_on_int_set(&(pObj->Ctx), PROPERTY_DISABLE) != LPS22HH_OK) + { + return LPS22HH_ERROR; + } + break; + case 1: + if (lps22hh_fifo_full_on_int_set(&(pObj->Ctx), PROPERTY_DISABLE) != LPS22HH_OK) + { + return LPS22HH_ERROR; + } + break; + case 2: + if (lps22hh_fifo_ovr_on_int_set(&(pObj->Ctx), PROPERTY_DISABLE) != LPS22HH_OK) + { + return LPS22HH_ERROR; + } + break; + default: + return LPS22HH_ERROR; + } + + return LPS22HH_OK; +} + +/** + * @brief Set the FIFO interrupt + * @param pObj the device pObj + * @param interrupt The FIFO interrupt to be reset; values: 0 = FTH; 1 = FULL; 2 = OVR + * @retval 0 in case of success, an error code otherwise + */ +int32_t LPS22HH_FIFO_Set_Interrupt(LPS22HH_Object_t *pObj, uint8_t interrupt) +{ + switch (interrupt) + { + case 0: + if (lps22hh_fifo_threshold_on_int_set(&(pObj->Ctx), PROPERTY_ENABLE) != LPS22HH_OK) + { + return LPS22HH_ERROR; + } + break; + case 1: + if (lps22hh_fifo_full_on_int_set(&(pObj->Ctx), PROPERTY_ENABLE) != LPS22HH_OK) + { + return LPS22HH_ERROR; + } + break; + case 2: + if (lps22hh_fifo_ovr_on_int_set(&(pObj->Ctx), PROPERTY_ENABLE) != LPS22HH_OK) + { + return LPS22HH_ERROR; + } + break; + default: + return LPS22HH_ERROR; + } + + return LPS22HH_OK; +} + +/** + * @brief Set the FIFO mode + * @param pObj the device pObj + * @param Mode the FIFO mode to be set + * @retval 0 in case of success, an error code otherwise + */ +int32_t LPS22HH_FIFO_Set_Mode(LPS22HH_Object_t *pObj, uint8_t Mode) +{ + /* Verify that the passed parameter contains one of the valid values */ + switch ((lps22hh_f_mode_t)Mode) + { + case LPS22HH_BYPASS_MODE: + case LPS22HH_FIFO_MODE: + case LPS22HH_STREAM_MODE: + case LPS22HH_STREAM_TO_FIFO_MODE: + case LPS22HH_BYPASS_TO_STREAM_MODE: + case LPS22HH_BYPASS_TO_FIFO_MODE: + break; + default: + return LPS22HH_ERROR; + } + + if (lps22hh_fifo_mode_set(&(pObj->Ctx), (lps22hh_f_mode_t)Mode) != LPS22HH_OK) + { + return LPS22HH_ERROR; + } + + return LPS22HH_OK; +} + +/** + * @brief Set the LPS22HH FIFO data level + * @param pObj the device pObj + * @param Watermark the watermark level + * @retval 0 in case of success, an error code otherwise + */ +int32_t LPS22HH_FIFO_Set_Watermark_Level(LPS22HH_Object_t *pObj, uint8_t Watermark) +{ + if (lps22hh_fifo_watermark_set(&(pObj->Ctx), Watermark) != LPS22HH_OK) + { + return LPS22HH_ERROR; + } + + return LPS22HH_OK; +} + +/** + * @brief Set the LPS22HH stop on watermark function + * @param pObj the device pObj + * @param Stop the state of stop on watermark function + * @retval 0 in case of success, an error code otherwise + */ +int32_t LPS22HH_FIFO_Stop_On_Watermark(LPS22HH_Object_t *pObj, uint8_t Stop) +{ + if (lps22hh_fifo_stop_on_wtm_set(&(pObj->Ctx), Stop) != LPS22HH_OK) + { + return LPS22HH_ERROR; + } + + return LPS22HH_OK; +} + +/** + * @brief Set the LPS22HH One Shot Mode + * @param pObj the device pObj + * @retval 0 in case of success, an error code otherwise + */ +int32_t LPS22HH_Set_One_Shot(LPS22HH_Object_t *pObj) +{ + /* Start One Shot Measurement */ + if (lps22hh_data_rate_set(&(pObj->Ctx), LPS22HH_ONE_SHOOT) != LPS22HH_OK) + { + return LPS22HH_ERROR; + } + + return LPS22HH_OK; +} + +/** + * @brief Get the LPS22HH One Shot Status + * @param pObj the device pObj + * @param Status pointer to the one shot status (1 means measurements available, 0 means measurements not available yet) + * @retval 0 in case of success, an error code otherwise + */ +int32_t LPS22HH_Get_One_Shot_Status(LPS22HH_Object_t *pObj, uint8_t *Status) +{ + uint8_t p_da; + uint8_t t_da; + + /* Get DataReady for pressure */ + if (lps22hh_press_flag_data_ready_get(&(pObj->Ctx), &p_da) != LPS22HH_OK) + { + return LPS22HH_ERROR; + } + + /* Get DataReady for temperature */ + if (lps22hh_temp_flag_data_ready_get(&(pObj->Ctx), &t_da) != LPS22HH_OK) + { + return LPS22HH_ERROR; + } + + if (p_da && t_da) + { + *Status = 1; + } + else + { + *Status = 0; + } + + return LPS22HH_OK; +} + +/** + * @brief Enable LPS22HH DRDY interrupt mode + * @param pObj the device pObj + * @retval 0 in case of success, an error code otherwise + */ +int32_t LPS22HH_Enable_DRDY_Interrupt(LPS22HH_Object_t *pObj) +{ + lps22hh_ctrl_reg3_t ctrl1_reg3; + + /* Enable Interrupt DRDY on INT1 */ + if (lps22hh_pin_int_route_get(&(pObj->Ctx), &ctrl1_reg3) != LPS22HH_OK) + { + return LPS22HH_ERROR; + } + ctrl1_reg3.drdy = 1; + if (lps22hh_pin_int_route_set(&(pObj->Ctx), &ctrl1_reg3) != LPS22HH_OK) + { + return LPS22HH_ERROR; + } + + return LPS22HH_OK; +} + +/** + * @brief Set the LPS22HH power mode + * @param pObj the device pObj + * @param powerMode mode to be set + * @retval 0 in case of success, an error code otherwise + */ +int32_t LPS22HH_Set_Power_Mode(LPS22HH_Object_t *pObj, uint8_t powerMode) +{ + lps22hh_ctrl_reg2_t ctrl_reg2; + + if (lps22hh_read_reg(&(pObj->Ctx), LPS22HH_CTRL_REG2, (uint8_t *)&ctrl_reg2, 1) != LPS22HH_OK) + { + return LPS22HH_ERROR; + } + + if (powerMode == 1) + { + ctrl_reg2.low_noise_en = LPS22HH_LOW_NOISE_EN; + } + else + { + ctrl_reg2.low_noise_en = LPS22HH_LOW_NOISE_DIS; + } + + if (lps22hh_write_reg(&(pObj->Ctx), LPS22HH_CTRL_REG2, (uint8_t *)&ctrl_reg2, 1) != LPS22HH_OK) + { + return LPS22HH_ERROR; + } + + return LPS22HH_OK; +} + +/** + * @brief Set the LPS22HH filter mode + * @param pObj the device pObj + * @param filterMode to be set + * @retval 0 in case of success, an error code otherwise + */ +int32_t LPS22HH_Set_Filter_Mode(LPS22HH_Object_t *pObj, uint8_t filterMode) +{ + if (lps22hh_lp_bandwidth_set(&(pObj->Ctx), (lps22hh_lpfp_cfg_t)filterMode) != LPS22HH_OK) + { + return LPS22HH_ERROR; + } + return LPS22HH_OK; +} + +/** + * @brief Wrap Read register component function to Bus IO function + * @param Handle the device handler + * @param Reg the register address + * @param pData the stored data pointer + * @param Length the length + * @retval 0 in case of success, an error code otherwise + */ +static int32_t ReadRegWrap(void *Handle, uint8_t Reg, uint8_t *pData, uint16_t Length) +{ + LPS22HH_Object_t *pObj = (LPS22HH_Object_t *)Handle; + + return pObj->IO.ReadReg(pObj->IO.Address, Reg, pData, Length); +} + +/** + * @brief Wrap Write register component function to Bus IO function + * @param Handle the device handler + * @param Reg the register address + * @param pData the stored data pointer + * @param Length the length + * @retval 0 in case of success, an error code otherwise + */ +static int32_t WriteRegWrap(void *Handle, uint8_t Reg, uint8_t *pData, uint16_t Length) +{ + LPS22HH_Object_t *pObj = (LPS22HH_Object_t *)Handle; + + return pObj->IO.WriteReg(pObj->IO.Address, Reg, pData, Length); +} + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ diff --git a/Drivers/BSP/Components/lps22hh/lps22hh.h b/Drivers/BSP/Components/lps22hh/lps22hh.h new file mode 100644 index 0000000..9603dc6 --- /dev/null +++ b/Drivers/BSP/Components/lps22hh/lps22hh.h @@ -0,0 +1,250 @@ +/** + ****************************************************************************** + * @file lps22hh.h + * @author MEMS Software Solutions Team + * @brief LPS22HH header driver file + ****************************************************************************** + * @attention + * + * Copyright (c) 2019 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef LPS22HH_H +#define LPS22HH_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "lps22hh_reg.h" +#include + +/** @addtogroup BSP BSP + * @{ + */ + +/** @addtogroup Component Component + * @{ + */ + +/** @addtogroup LPS22HH LPS22HH + * @{ + */ + +/** @defgroup LPS22HH_Exported_Types LPS22HH Exported Types + * @{ + */ + +typedef int32_t (*LPS22HH_Init_Func)(void); +typedef int32_t (*LPS22HH_DeInit_Func)(void); +typedef int32_t (*LPS22HH_GetTick_Func)(void); +typedef void (*LPS22HH_Delay_Func)(uint32_t); +typedef int32_t (*LPS22HH_WriteReg_Func)(uint16_t, uint16_t, uint8_t *, uint16_t); +typedef int32_t (*LPS22HH_ReadReg_Func)(uint16_t, uint16_t, uint8_t *, uint16_t); + +typedef struct +{ + LPS22HH_Init_Func Init; + LPS22HH_DeInit_Func DeInit; + uint32_t BusType; /*0 means I2C, 1 means SPI 4-Wires, 2 means SPI-3-Wires */ + uint8_t Address; + LPS22HH_WriteReg_Func WriteReg; + LPS22HH_ReadReg_Func ReadReg; + LPS22HH_GetTick_Func GetTick; + LPS22HH_Delay_Func Delay; +} LPS22HH_IO_t; + +typedef struct +{ + LPS22HH_IO_t IO; + stmdev_ctx_t Ctx; + uint8_t is_initialized; + uint8_t press_is_enabled; + uint8_t temp_is_enabled; + lps22hh_odr_t last_odr; +} LPS22HH_Object_t; + +typedef struct +{ + uint8_t Temperature; + uint8_t Pressure; + uint8_t Humidity; + uint8_t LowPower; + float HumMaxOdr; + float TempMaxOdr; + float PressMaxOdr; +} LPS22HH_Capabilities_t; + +typedef struct +{ + int32_t (*Init)(LPS22HH_Object_t *); + int32_t (*DeInit)(LPS22HH_Object_t *); + int32_t (*ReadID)(LPS22HH_Object_t *, uint8_t *); + int32_t (*GetCapabilities)(LPS22HH_Object_t *, LPS22HH_Capabilities_t *); +} LPS22HH_CommonDrv_t; + +typedef struct +{ + int32_t (*Enable)(LPS22HH_Object_t *); + int32_t (*Disable)(LPS22HH_Object_t *); + int32_t (*GetOutputDataRate)(LPS22HH_Object_t *, float *); + int32_t (*SetOutputDataRate)(LPS22HH_Object_t *, float); + int32_t (*GetTemperature)(LPS22HH_Object_t *, float *); +} LPS22HH_TEMP_Drv_t; + +typedef struct +{ + int32_t (*Enable)(LPS22HH_Object_t *); + int32_t (*Disable)(LPS22HH_Object_t *); + int32_t (*GetOutputDataRate)(LPS22HH_Object_t *, float *); + int32_t (*SetOutputDataRate)(LPS22HH_Object_t *, float); + int32_t (*GetPressure)(LPS22HH_Object_t *, float *); +} LPS22HH_PRESS_Drv_t; + +typedef enum +{ + LPS22HH_FIFO_BYPASS_MODE = (uint8_t)0x00, /*!< The FIFO is disabled and empty. The pressure is read directly*/ + LPS22HH_FIFO_FIFO_MODE = (uint8_t)0x20, /*!< Stops collecting data when full */ + LPS22HH_FIFO_STREAM_MODE = (uint8_t)0x40, /*!< Keep the newest measurements in the FIFO*/ + LPS22HH_FIFO_TRIGGER_STREAMTOFIFO_MODE = (uint8_t)0x60, /*!< STREAM MODE until trigger deasserted, then change to FIFO MODE*/ + LPS22HH_FIFO_TRIGGER_BYPASSTOSTREAM_MODE = (uint8_t)0x80, /*!< BYPASS MODE until trigger deasserted, then STREAM MODE*/ + LPS22HH_FIFO_TRIGGER_BYPASSTOFIFO_MODE = (uint8_t)0xE0 /*!< BYPASS mode until trigger deasserted, then FIFO MODE*/ +} LPS22HH_FifoMode; + +typedef union +{ + int16_t i16bit[3]; + uint8_t u8bit[6]; +} lps22hh_axis3bit16_t; + +typedef union +{ + int16_t i16bit; + uint8_t u8bit[2]; +} lps22hh_axis1bit16_t; + +typedef union +{ + int32_t i32bit[3]; + uint8_t u8bit[12]; +} lps22hh_axis3bit32_t; + +typedef union +{ + int32_t i32bit; + uint8_t u8bit[4]; +} lps22hh_axis1bit32_t; + +/** + * @} + */ + +/** @defgroup LPS22HH_Exported_Constants LPS22HH Exported Constants + * @{ + */ + +#define LPS22HH_OK 0 +#define LPS22HH_ERROR -1 + +#define LPS22HH_I2C_BUS 0U +#define LPS22HH_SPI_4WIRES_BUS 1U +#define LPS22HH_SPI_3WIRES_BUS 2U + +#define LPS22HH_FIFO_FULL (uint8_t)0x20 + +/** LPS22HH low noise mode **/ +#define LPS22HH_LOW_NOISE_DIS 0 +#define LPS22HH_LOW_NOISE_EN 1 + +/** + * @} + */ + +/** @addtogroup LPS22HH_Exported_Functions LPS22HH Exported Functions + * @{ + */ + +int32_t LPS22HH_RegisterBusIO(LPS22HH_Object_t *pObj, LPS22HH_IO_t *pIO); +int32_t LPS22HH_Init(LPS22HH_Object_t *pObj); +int32_t LPS22HH_DeInit(LPS22HH_Object_t *pObj); +int32_t LPS22HH_ReadID(LPS22HH_Object_t *pObj, uint8_t *Id); +int32_t LPS22HH_GetCapabilities(LPS22HH_Object_t *pObj, LPS22HH_Capabilities_t *Capabilities); +int32_t LPS22HH_Get_Init_Status(LPS22HH_Object_t *pObj, uint8_t *Status); + +int32_t LPS22HH_PRESS_Enable(LPS22HH_Object_t *pObj); +int32_t LPS22HH_PRESS_Disable(LPS22HH_Object_t *pObj); +int32_t LPS22HH_PRESS_GetOutputDataRate(LPS22HH_Object_t *pObj, float *Odr); +int32_t LPS22HH_PRESS_SetOutputDataRate(LPS22HH_Object_t *pObj, float Odr); +int32_t LPS22HH_PRESS_GetPressure(LPS22HH_Object_t *pObj, float *Value); +int32_t LPS22HH_PRESS_Get_DRDY_Status(LPS22HH_Object_t *pObj, uint8_t *Status); + +int32_t LPS22HH_TEMP_Enable(LPS22HH_Object_t *pObj); +int32_t LPS22HH_TEMP_Disable(LPS22HH_Object_t *pObj); +int32_t LPS22HH_TEMP_GetOutputDataRate(LPS22HH_Object_t *pObj, float *Odr); +int32_t LPS22HH_TEMP_SetOutputDataRate(LPS22HH_Object_t *pObj, float Odr); +int32_t LPS22HH_TEMP_GetTemperature(LPS22HH_Object_t *pObj, float *Value); +int32_t LPS22HH_TEMP_Get_DRDY_Status(LPS22HH_Object_t *pObj, uint8_t *Status); + +int32_t LPS22HH_Read_Reg(LPS22HH_Object_t *pObj, uint8_t reg, uint8_t *Data); +int32_t LPS22HH_Write_Reg(LPS22HH_Object_t *pObj, uint8_t reg, uint8_t Data); + +int32_t LPS22HH_FIFO_Get_Data(LPS22HH_Object_t *pObj, float *Press, float *Temp); +int32_t LPS22HH_FIFO_Get_FTh_Status(LPS22HH_Object_t *pObj, uint8_t *Status); +int32_t LPS22HH_FIFO_Get_Full_Status(LPS22HH_Object_t *pObj, uint8_t *Status); +int32_t LPS22HH_FIFO_Get_Ovr_Status(LPS22HH_Object_t *pObj, uint8_t *Status); +int32_t LPS22HH_FIFO_Get_Level(LPS22HH_Object_t *pObj, uint8_t *Status); +int32_t LPS22HH_FIFO_Reset_Interrupt(LPS22HH_Object_t *pObj, uint8_t interrupt); +int32_t LPS22HH_FIFO_Set_Interrupt(LPS22HH_Object_t *pObj, uint8_t interrupt); +int32_t LPS22HH_FIFO_Set_Mode(LPS22HH_Object_t *pObj, uint8_t Mode); +int32_t LPS22HH_FIFO_Set_Watermark_Level(LPS22HH_Object_t *pObj, uint8_t Watermark); +int32_t LPS22HH_FIFO_Stop_On_Watermark(LPS22HH_Object_t *pObj, uint8_t Stop); + +int32_t LPS22HH_Set_One_Shot(LPS22HH_Object_t *pObj); +int32_t LPS22HH_Get_One_Shot_Status(LPS22HH_Object_t *pObj, uint8_t *Status); + +int32_t LPS22HH_Enable_DRDY_Interrupt(LPS22HH_Object_t *pObj); +int32_t LPS22HH_Set_Power_Mode(LPS22HH_Object_t *pObj, uint8_t powerMode); +int32_t LPS22HH_Set_Filter_Mode(LPS22HH_Object_t *pObj, uint8_t filterMode); + +/** + * @} + */ + +/** @addtogroup LPS22HH_Exported_Variables LPS22HH Exported Variables + * @{ + */ +extern LPS22HH_CommonDrv_t LPS22HH_COMMON_Driver; +extern LPS22HH_PRESS_Drv_t LPS22HH_PRESS_Driver; +extern LPS22HH_TEMP_Drv_t LPS22HH_TEMP_Driver; + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ diff --git a/Drivers/BSP/Components/lps22hh/lps22hh_reg.c b/Drivers/BSP/Components/lps22hh/lps22hh_reg.c new file mode 100644 index 0000000..1a1258d --- /dev/null +++ b/Drivers/BSP/Components/lps22hh/lps22hh_reg.c @@ -0,0 +1,2067 @@ +/** + ****************************************************************************** + * @file lps22hh_reg.c + * @author Sensors Software Solution Team + * @brief LPS22HH driver file + ****************************************************************************** + * @attention + * + * Copyright (c) 2019 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ + +#include "lps22hh_reg.h" + +/** + * @defgroup LPS22HH + * @brief This file provides a set of functions needed to drive the + * lps22hh enhanced inertial module. + * @{ + * + */ + +/** + * @defgroup LPS22HH_Interfaces_Functions + * @brief This section provide a set of functions used to read and + * write a generic register of the device. + * MANDATORY: return 0 -> no Error. + * @{ + * + */ + +/** + * @brief Read generic device register + * + * @param ctx read / write interface definitions(ptr) + * @param reg register to read + * @param data pointer to buffer that store the data read(ptr) + * @param len number of consecutive register to read + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t __weak lps22hh_read_reg(stmdev_ctx_t *ctx, uint8_t reg, + uint8_t *data, + uint16_t len) +{ + int32_t ret; + + ret = ctx->read_reg(ctx->handle, reg, data, len); + + return ret; +} + +/** + * @brief Write generic device register + * + * @param ctx read / write interface definitions(ptr) + * @param reg register to write + * @param data pointer to data to write in register reg(ptr) + * @param len number of consecutive register to write + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t __weak lps22hh_write_reg(stmdev_ctx_t *ctx, uint8_t reg, + uint8_t *data, + uint16_t len) +{ + int32_t ret; + + ret = ctx->write_reg(ctx->handle, reg, data, len); + + return ret; +} + +/** + * @} + * + */ + +/** + * @defgroup LPS22HH_Sensitivity + * @brief These functions convert raw-data into engineering units. + * @{ + * + */ +float_t lps22hh_from_lsb_to_hpa(uint32_t lsb) +{ + return ((float_t) lsb / 1048576.0f); +} + +float_t lps22hh_from_lsb_to_celsius(int16_t lsb) +{ + return ((float_t) lsb / 100.0f); +} + +/** + * @} + * + */ + +/** + * @defgroup LPS22HH_Data_Generation + * @brief This section groups all the functions concerning + * data generation. + * @{ + * + */ + +/** + * @brief Reset Autozero function.[set] + * + * @param ctx read / write interface definitions + * @param val change the values of reset_az in reg INTERRUPT_CFG + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_autozero_rst_set(stmdev_ctx_t *ctx, uint8_t val) +{ + lps22hh_interrupt_cfg_t reg; + int32_t ret; + + ret = lps22hh_read_reg(ctx, LPS22HH_INTERRUPT_CFG, (uint8_t *) ®, 1); + + if (ret == 0) + { + reg.reset_az = val; + ret = lps22hh_write_reg(ctx, LPS22HH_INTERRUPT_CFG, (uint8_t *) ®, 1); + } + + return ret; +} + +/** + * @brief Reset Autozero function.[get] + * + * @param ctx read / write interface definitions + * @param val change the values of reset_az in reg INTERRUPT_CFG + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_autozero_rst_get(stmdev_ctx_t *ctx, uint8_t *val) +{ + lps22hh_interrupt_cfg_t reg; + int32_t ret; + + ret = lps22hh_read_reg(ctx, LPS22HH_INTERRUPT_CFG, (uint8_t *) ®, 1); + *val = reg.reset_az; + + return ret; +} + +/** + * @brief Enable Autozero function.[set] + * + * @param ctx read / write interface definitions + * @param val change the values of autozero in reg INTERRUPT_CFG + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_autozero_set(stmdev_ctx_t *ctx, uint8_t val) +{ + lps22hh_interrupt_cfg_t reg; + int32_t ret; + + ret = lps22hh_read_reg(ctx, LPS22HH_INTERRUPT_CFG, (uint8_t *) ®, 1); + + if (ret == 0) + { + reg.autozero = val; + ret = lps22hh_write_reg(ctx, LPS22HH_INTERRUPT_CFG, (uint8_t *) ®, 1); + } + + return ret; +} + +/** + * @brief Enable Autozero function.[get] + * + * @param ctx read / write interface definitions + * @param val change the values of autozero in reg INTERRUPT_CFG + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_autozero_get(stmdev_ctx_t *ctx, uint8_t *val) +{ + lps22hh_interrupt_cfg_t reg; + int32_t ret; + + ret = lps22hh_read_reg(ctx, LPS22HH_INTERRUPT_CFG, (uint8_t *) ®, 1); + *val = reg.autozero; + + return ret; +} + +/** + * @brief Reset AutoRifP function.[set] + * + * @param ctx read / write interface definitions + * @param val change the values of reset_arp in reg INTERRUPT_CFG + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_pressure_snap_rst_set(stmdev_ctx_t *ctx, uint8_t val) +{ + lps22hh_interrupt_cfg_t reg; + int32_t ret; + + ret = lps22hh_read_reg(ctx, LPS22HH_INTERRUPT_CFG, (uint8_t *) ®, 1); + + if (ret == 0) + { + reg.reset_arp = val; + ret = lps22hh_write_reg(ctx, LPS22HH_INTERRUPT_CFG, (uint8_t *) ®, 1); + } + + return ret; +} + +/** + * @brief Reset AutoRifP function.[get] + * + * @param ctx read / write interface definitions + * @param val change the values of reset_arp in reg INTERRUPT_CFG + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_pressure_snap_rst_get(stmdev_ctx_t *ctx, uint8_t *val) +{ + lps22hh_interrupt_cfg_t reg; + int32_t ret; + + ret = lps22hh_read_reg(ctx, LPS22HH_INTERRUPT_CFG, (uint8_t *) ®, 1); + *val = reg.reset_arp; + + return ret; +} + +/** + * @brief Enable AutoRefP function.[set] + * + * @param ctx read / write interface definitions + * @param val change the values of autorefp in reg INTERRUPT_CFG + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_pressure_snap_set(stmdev_ctx_t *ctx, uint8_t val) +{ + lps22hh_interrupt_cfg_t reg; + int32_t ret; + + ret = lps22hh_read_reg(ctx, LPS22HH_INTERRUPT_CFG, (uint8_t *) ®, 1); + + if (ret == 0) + { + reg.autorefp = val; + ret = lps22hh_write_reg(ctx, LPS22HH_INTERRUPT_CFG, (uint8_t *) ®, 1); + } + + return ret; +} + +/** + * @brief Enable AutoRefP function.[get] + * + * @param ctx read / write interface definitions + * @param val change the values of autorefp in reg INTERRUPT_CFG + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_pressure_snap_get(stmdev_ctx_t *ctx, uint8_t *val) +{ + lps22hh_interrupt_cfg_t reg; + int32_t ret; + + ret = lps22hh_read_reg(ctx, LPS22HH_INTERRUPT_CFG, (uint8_t *) ®, 1); + *val = reg.autorefp; + + return ret; +} + +/** + * @brief Block Data Update.[set] + * + * @param ctx read / write interface definitions + * @param val change the values of bdu in reg CTRL_REG1 + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_block_data_update_set(stmdev_ctx_t *ctx, uint8_t val) +{ + lps22hh_ctrl_reg1_t reg; + int32_t ret; + + ret = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG1, (uint8_t *) ®, 1); + + if (ret == 0) + { + reg.bdu = val; + ret = lps22hh_write_reg(ctx, LPS22HH_CTRL_REG1, (uint8_t *) ®, 1); + } + + return ret; +} + +/** + * @brief Block Data Update.[get] + * + * @param ctx read / write interface definitions + * @param val change the values of bdu in reg CTRL_REG1 + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_block_data_update_get(stmdev_ctx_t *ctx, uint8_t *val) +{ + lps22hh_ctrl_reg1_t reg; + int32_t ret; + + ret = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG1, (uint8_t *) ®, 1); + *val = reg.bdu; + + return ret; +} + +/** + * @brief Output data rate selection.[set] + * + * @param ctx read / write interface definitions + * @param val change the values of odr in reg CTRL_REG1 + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_data_rate_set(stmdev_ctx_t *ctx, lps22hh_odr_t val) +{ + lps22hh_ctrl_reg1_t ctrl_reg1; + lps22hh_ctrl_reg2_t ctrl_reg2; + int32_t ret; + + ret = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG1, (uint8_t *)&ctrl_reg1, 1); + + if (ret == 0) + { + ret = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG2, (uint8_t *)&ctrl_reg2, 1); + } + + if (ret == 0) + { + ctrl_reg1.odr = (uint8_t)val & 0x07U; + ret = lps22hh_write_reg(ctx, LPS22HH_CTRL_REG1, (uint8_t *)&ctrl_reg1, 1); + } + + if (ret == 0) + { + ctrl_reg2.low_noise_en = ((uint8_t)val & 0x10U) >> 4; + ctrl_reg2.one_shot = ((uint8_t)val & 0x08U) >> 3; + ret = lps22hh_write_reg(ctx, LPS22HH_CTRL_REG2, (uint8_t *)&ctrl_reg2, 1); + } + + return ret; +} + +/** + * @brief Output data rate selection.[get] + * + * @param ctx read / write interface definitions + * @param val Get the values of odr in reg CTRL_REG1 + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_data_rate_get(stmdev_ctx_t *ctx, lps22hh_odr_t *val) +{ + lps22hh_ctrl_reg1_t ctrl_reg1; + lps22hh_ctrl_reg2_t ctrl_reg2; + int32_t ret; + + ret = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG1, (uint8_t *)&ctrl_reg1, 1); + + if (ret == 0) + { + ret = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG2, (uint8_t *)&ctrl_reg2, 1); + } + + if (ret == 0) + { + ret = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG2, (uint8_t *)&ctrl_reg2, 1); + + switch (((ctrl_reg2.low_noise_en << 4) + (ctrl_reg2.one_shot << 3) + + ctrl_reg1.odr)) + { + case LPS22HH_POWER_DOWN: + *val = LPS22HH_POWER_DOWN; + break; + + case LPS22HH_ONE_SHOOT: + *val = LPS22HH_ONE_SHOOT; + break; + + case LPS22HH_1_Hz: + *val = LPS22HH_1_Hz; + break; + + case LPS22HH_10_Hz: + *val = LPS22HH_10_Hz; + break; + + case LPS22HH_25_Hz: + *val = LPS22HH_25_Hz; + break; + + case LPS22HH_50_Hz: + *val = LPS22HH_50_Hz; + break; + + case LPS22HH_75_Hz: + *val = LPS22HH_75_Hz; + break; + + case LPS22HH_1_Hz_LOW_NOISE: + *val = LPS22HH_1_Hz_LOW_NOISE; + break; + + case LPS22HH_10_Hz_LOW_NOISE: + *val = LPS22HH_10_Hz_LOW_NOISE; + break; + + case LPS22HH_25_Hz_LOW_NOISE: + *val = LPS22HH_25_Hz_LOW_NOISE; + break; + + case LPS22HH_50_Hz_LOW_NOISE: + *val = LPS22HH_50_Hz_LOW_NOISE; + break; + + case LPS22HH_75_Hz_LOW_NOISE: + *val = LPS22HH_75_Hz_LOW_NOISE; + break; + + case LPS22HH_100_Hz: + *val = LPS22HH_100_Hz; + break; + + case LPS22HH_200_Hz: + *val = LPS22HH_200_Hz; + break; + + default: + *val = LPS22HH_POWER_DOWN; + break; + } + } + + return ret; +} + +/** + * @brief The Reference pressure value is a 16-bit data + * expressed as 2's complement. The value is used + * when AUTOZERO or AUTORIFP function is enabled.[set] + * + * @param ctx read / write interface definitions + * @param buff buffer that contains data to write + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_pressure_ref_set(stmdev_ctx_t *ctx, int16_t val) +{ + uint8_t buff[2]; + int32_t ret; + + buff[1] = (uint8_t)((uint16_t)val / 256U); + buff[0] = (uint8_t)((uint16_t)val - (buff[1] * 256U)); + ret = lps22hh_write_reg(ctx, LPS22HH_REF_P_L, buff, 2); + + return ret; +} + +/** + * @brief The Reference pressure value is a 16-bit + * data expressed as 2's complement. + * The value is used when AUTOZERO or AUTORIFP + * function is enabled.[get] + * + * @param ctx read / write interface definitions + * @param buff buffer that stores data read + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_pressure_ref_get(stmdev_ctx_t *ctx, int16_t *val) +{ + uint8_t buff[2]; + int32_t ret; + + ret = lps22hh_read_reg(ctx, LPS22HH_REF_P_L, buff, 2); + *val = (int16_t)buff[1]; + *val = (*val * 256) + (int16_t)buff[0]; + + return ret; +} + +/** + * @brief The pressure offset value is 16-bit data + * that can be used to implement one-point + * calibration (OPC) after soldering.[set] + * + * @param ctx read / write interface definitions + * @param buff buffer that contains data to write + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_pressure_offset_set(stmdev_ctx_t *ctx, int16_t val) +{ + uint8_t buff[2]; + int32_t ret; + + buff[1] = (uint8_t)((uint16_t)val / 256U); + buff[0] = (uint8_t)((uint16_t)val - (buff[1] * 256U)); + ret = lps22hh_write_reg(ctx, LPS22HH_RPDS_L, buff, 2); + + return ret; +} + +/** + * @brief The pressure offset value is 16-bit + * data that can be used to implement + * one-point calibration (OPC) after + * soldering.[get] + * + * @param ctx read / write interface definitions + * @param buff buffer that stores data read + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_pressure_offset_get(stmdev_ctx_t *ctx, int16_t *val) +{ + uint8_t buff[2]; + int32_t ret; + + ret = lps22hh_read_reg(ctx, LPS22HH_RPDS_L, buff, 2); + *val = (int16_t)buff[1]; + *val = (*val * 256) + (int16_t)buff[0]; + + return ret; +} + +/** + * @brief Read all the interrupt/status flag of the device.[get] + * + * @param ctx read / write interface definitions + * @param val registers STATUS,FIFO_STATUS2,INT_SOURCE + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_all_sources_get(stmdev_ctx_t *ctx, + lps22hh_all_sources_t *val) +{ + int32_t ret; + + ret = lps22hh_read_reg(ctx, LPS22HH_INT_SOURCE, + (uint8_t *) & (val->int_source), 1); + + if (ret == 0) + { + ret = lps22hh_read_reg(ctx, LPS22HH_FIFO_STATUS2, + (uint8_t *) & (val->fifo_status2), 1); + } + + if (ret == 0) + { + ret = lps22hh_read_reg(ctx, LPS22HH_STATUS, + (uint8_t *) & (val->status), 1); + } + + return ret; +} + +/** + * @brief The STATUS_REG register is read by the primary interface.[get] + * + * @param ctx read / write interface definitions + * @param val structure of registers from STATUS to STATUS_REG + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_status_reg_get(stmdev_ctx_t *ctx, + lps22hh_status_t *val) +{ + int32_t ret; + + ret = lps22hh_read_reg(ctx, LPS22HH_STATUS, (uint8_t *) val, 1); + + return ret; +} + +/** + * @brief Pressure new data available.[get] + * + * @param ctx read / write interface definitions + * @param val change the values of p_da in reg STATUS + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_press_flag_data_ready_get(stmdev_ctx_t *ctx, + uint8_t *val) +{ + lps22hh_status_t reg; + int32_t ret; + + ret = lps22hh_read_reg(ctx, LPS22HH_STATUS, (uint8_t *) ®, 1); + *val = reg.p_da; + + return ret; +} + +/** + * @brief Temperature data available.[get] + * + * @param ctx read / write interface definitions + * @param val change the values of t_da in reg STATUS + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_temp_flag_data_ready_get(stmdev_ctx_t *ctx, + uint8_t *val) +{ + lps22hh_status_t reg; + int32_t ret; + + ret = lps22hh_read_reg(ctx, LPS22HH_STATUS, (uint8_t *) ®, 1); + *val = reg.t_da; + + return ret; +} + +/** + * @} + * + */ + +/** + * @defgroup LPS22HH_Data_Output + * @brief This section groups all the data output functions. + * @{ + * + */ + +/** + * @brief Pressure output value.[get] + * + * @param ctx read / write interface definitions + * @param buff buffer that stores data read + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_pressure_raw_get(stmdev_ctx_t *ctx, uint32_t *buff) +{ + int32_t ret; + + uint8_t reg[3]; + ret = lps22hh_read_reg(ctx, LPS22HH_PRESS_OUT_XL, reg, 3); + *buff = reg[2]; + *buff = (*buff * 256) + reg[1]; + *buff = (*buff * 256) + reg[0]; + *buff *= 256; + + return ret; +} + +/** + * @brief Temperature output value.[get] + * + * @param ctx read / write interface definitions + * @param buff buffer that stores data read + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_temperature_raw_get(stmdev_ctx_t *ctx, int16_t *buff) +{ + int32_t ret; + + uint8_t reg[2]; + ret = lps22hh_read_reg(ctx, LPS22HH_TEMP_OUT_L, reg, 2); + *buff = reg[1]; + *buff = (*buff * 256) + reg[0]; + + return ret; +} + +/** + * @brief Pressure output from FIFO value.[get] + * + * @param ctx read / write interface definitions + * @param buff buffer that stores data read + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_fifo_pressure_raw_get(stmdev_ctx_t *ctx, + uint32_t *buff) +{ + int32_t ret; + + uint8_t reg[3]; + ret = lps22hh_read_reg(ctx, LPS22HH_FIFO_DATA_OUT_PRESS_XL, reg, 3); + *buff = reg[2]; + *buff = (*buff * 256) + reg[1]; + *buff = (*buff * 256) + reg[0]; + *buff *= 256; + + return ret; +} + +/** + * @brief Temperature output from FIFO value.[get] + * + * @param ctx read / write interface definitions + * @param buff buffer that stores data read + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_fifo_temperature_raw_get(stmdev_ctx_t *ctx, + int16_t *buff) +{ + int32_t ret; + + uint8_t reg[2]; + ret = lps22hh_read_reg(ctx, LPS22HH_FIFO_DATA_OUT_TEMP_L, reg, 2); + *buff = reg[1]; + *buff = (*buff * 256) + reg[0]; + + return ret; +} + +/** + * @} + * + */ + +/** + * @defgroup LPS22HH_Common + * @brief This section groups common useful functions. + * @{ + * + */ + +/** + * @brief DeviceWhoamI[get] + * + * @param ctx read / write interface definitions + * @param buff buffer that stores data read + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_device_id_get(stmdev_ctx_t *ctx, uint8_t *buff) +{ + int32_t ret; + + ret = lps22hh_read_reg(ctx, LPS22HH_WHO_AM_I, buff, 1); + + return ret; +} + +/** + * @brief Software reset. Restore the default values + * in user registers.[set] + * + * @param ctx read / write interface definitions + * @param val change the values of swreset in reg CTRL_REG2 + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_reset_set(stmdev_ctx_t *ctx, uint8_t val) +{ + lps22hh_ctrl_reg2_t reg; + int32_t ret; + + ret = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG2, (uint8_t *) ®, 1); + + if (ret == 0) + { + reg.swreset = val; + ret = lps22hh_write_reg(ctx, LPS22HH_CTRL_REG2, (uint8_t *) ®, 1); + } + + return ret; +} + +/** + * @brief Software reset. Restore the default values + * in user registers.[get] + * + * @param ctx read / write interface definitions + * @param val change the values of swreset in reg CTRL_REG2 + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_reset_get(stmdev_ctx_t *ctx, uint8_t *val) +{ + lps22hh_ctrl_reg2_t reg; + int32_t ret; + + ret = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG2, (uint8_t *) ®, 1); + *val = reg.swreset; + + return ret; +} + +/** + * @brief Register address automatically + * incremented during a multiple byte access + * with a serial interface.[set] + * + * @param ctx read / write interface definitions + * @param val change the values of if_add_inc in reg CTRL_REG2 + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_auto_increment_set(stmdev_ctx_t *ctx, uint8_t val) +{ + lps22hh_ctrl_reg2_t reg; + int32_t ret; + + ret = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG2, (uint8_t *) ®, 1); + + if (ret == 0) + { + reg.if_add_inc = val; + ret = lps22hh_write_reg(ctx, LPS22HH_CTRL_REG2, (uint8_t *) ®, 1); + } + + return ret; +} + +/** + * @brief Register address automatically + * incremented during a multiple byte + * access with a serial interface.[get] + * + * @param ctx read / write interface definitions + * @param val change the values of if_add_inc in reg CTRL_REG2 + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_auto_increment_get(stmdev_ctx_t *ctx, uint8_t *val) +{ + lps22hh_ctrl_reg2_t reg; + int32_t ret; + + ret = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG2, (uint8_t *) ®, 1); + *val = reg.if_add_inc; + + return ret; +} + +/** + * @brief Reboot memory content. Reload the calibration + * parameters.[set] + * + * @param ctx read / write interface definitions + * @param val change the values of boot in reg CTRL_REG2 + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_boot_set(stmdev_ctx_t *ctx, uint8_t val) +{ + lps22hh_ctrl_reg2_t reg; + int32_t ret; + + ret = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG2, (uint8_t *) ®, 1); + + if (ret == 0) + { + reg.boot = val; + ret = lps22hh_write_reg(ctx, LPS22HH_CTRL_REG2, (uint8_t *) ®, 1); + } + + return ret; +} + +/** + * @brief Reboot memory content. Reload the calibration + * parameters.[get] + * + * @param ctx read / write interface definitions + * @param val change the values of boot in reg CTRL_REG2 + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_boot_get(stmdev_ctx_t *ctx, uint8_t *val) +{ + lps22hh_ctrl_reg2_t reg; + int32_t ret; + + ret = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG2, (uint8_t *) ®, 1); + *val = reg.boot; + + return ret; +} + +/** + * @} + * + */ + +/** + * @defgroup LPS22HH_Filters + * @brief This section group all the functions concerning the + * filters configuration. + * @{ + * + */ + +/** + * @brief Low-pass bandwidth selection.[set] + * + * @param ctx read / write interface definitions + * @param val change the values of lpfp_cfg in reg CTRL_REG1 + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_lp_bandwidth_set(stmdev_ctx_t *ctx, + lps22hh_lpfp_cfg_t val) +{ + lps22hh_ctrl_reg1_t reg; + int32_t ret; + + ret = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG1, (uint8_t *) ®, 1); + + if (ret == 0) + { + reg.lpfp_cfg = (uint8_t)val; + ret = lps22hh_write_reg(ctx, LPS22HH_CTRL_REG1, (uint8_t *) ®, 1); + } + + return ret; +} + +/** + * @brief Low-pass bandwidth selection.[get] + * + * @param ctx read / write interface definitions + * @param val Get the values of lpfp_cfg in reg CTRL_REG1 + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_lp_bandwidth_get(stmdev_ctx_t *ctx, + lps22hh_lpfp_cfg_t *val) +{ + lps22hh_ctrl_reg1_t reg; + int32_t ret; + + ret = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG1, (uint8_t *) ®, 1); + + switch (reg.lpfp_cfg) + { + case LPS22HH_LPF_ODR_DIV_2: + *val = LPS22HH_LPF_ODR_DIV_2; + break; + + case LPS22HH_LPF_ODR_DIV_9: + *val = LPS22HH_LPF_ODR_DIV_9; + break; + + case LPS22HH_LPF_ODR_DIV_20: + *val = LPS22HH_LPF_ODR_DIV_20; + break; + + default: + *val = LPS22HH_LPF_ODR_DIV_2; + break; + } + + return ret; +} + +/** + * @} + * + */ + +/** + * @defgroup LPS22HH_Serial_Interface + * @brief This section groups all the functions concerning serial + * interface management + * @{ + * + */ + +/** + * @brief Enable/Disable I2C interface.[set] + * + * @param ctx read / write interface definitions + * @param val change the values of i2c_disable in reg IF_CTRL + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_i2c_interface_set(stmdev_ctx_t *ctx, + lps22hh_i2c_disable_t val) +{ + lps22hh_if_ctrl_t reg; + int32_t ret; + + ret = lps22hh_read_reg(ctx, LPS22HH_IF_CTRL, (uint8_t *) ®, 1); + + if (ret == 0) + { + reg.i2c_disable = (uint8_t)val; + ret = lps22hh_write_reg(ctx, LPS22HH_IF_CTRL, (uint8_t *) ®, 1); + } + + return ret; +} + +/** + * @brief Enable/Disable I2C interface.[get] + * + * @param ctx read / write interface definitions + * @param val Get the values of i2c_disable in reg IF_CTRL + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_i2c_interface_get(stmdev_ctx_t *ctx, + lps22hh_i2c_disable_t *val) +{ + lps22hh_if_ctrl_t reg; + int32_t ret; + + ret = lps22hh_read_reg(ctx, LPS22HH_IF_CTRL, (uint8_t *) ®, 1); + + switch (reg.i2c_disable) + { + case LPS22HH_I2C_ENABLE: + *val = LPS22HH_I2C_ENABLE; + break; + + case LPS22HH_I2C_DISABLE: + *val = LPS22HH_I2C_DISABLE; + break; + + default: + *val = LPS22HH_I2C_ENABLE; + break; + } + + return ret; +} + +/** + * @brief I3C Enable/Disable communication protocol.[set] + * + * @param ctx read / write interface definitions + * @param val change the values of int_en_i3c in reg IF_CTRL + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_i3c_interface_set(stmdev_ctx_t *ctx, + lps22hh_i3c_disable_t val) +{ + lps22hh_if_ctrl_t reg; + int32_t ret; + + ret = lps22hh_read_reg(ctx, LPS22HH_IF_CTRL, (uint8_t *) ®, 1); + + if (ret == 0) + { + reg.i3c_disable = ((uint8_t)val & 0x01u); + reg.int_en_i3c = ((uint8_t)val & 0x10U) >> 4; + ret = lps22hh_write_reg(ctx, LPS22HH_IF_CTRL, (uint8_t *) ®, 1); + } + + return ret; +} + +/** + * @brief I3C Enable/Disable communication protocol.[get] + * + * @param ctx read / write interface definitions + * @param val change the values of int_en_i3c in reg IF_CTRL + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_i3c_interface_get(stmdev_ctx_t *ctx, + lps22hh_i3c_disable_t *val) +{ + lps22hh_if_ctrl_t reg; + int32_t ret; + + ret = lps22hh_read_reg(ctx, LPS22HH_IF_CTRL, (uint8_t *) ®, 1); + + switch ((reg.int_en_i3c << 4) + reg.int_en_i3c) + { + case LPS22HH_I3C_ENABLE: + *val = LPS22HH_I3C_ENABLE; + break; + + case LPS22HH_I3C_ENABLE_INT_PIN_ENABLE: + *val = LPS22HH_I3C_ENABLE_INT_PIN_ENABLE; + break; + + case LPS22HH_I3C_DISABLE: + *val = LPS22HH_I3C_DISABLE; + break; + + default: + *val = LPS22HH_I3C_ENABLE; + break; + } + + return ret; +} + +/** + * @brief Enable/Disable pull-up on SDO pin.[set] + * + * @param ctx read / write interface definitions + * @param val change the values of sdo_pu_en in reg IF_CTRL + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_sdo_sa0_mode_set(stmdev_ctx_t *ctx, + lps22hh_pu_en_t val) +{ + lps22hh_if_ctrl_t reg; + int32_t ret; + + ret = lps22hh_read_reg(ctx, LPS22HH_IF_CTRL, (uint8_t *) ®, 1); + + if (ret == 0) + { + reg.sdo_pu_en = (uint8_t)val; + ret = lps22hh_write_reg(ctx, LPS22HH_IF_CTRL, (uint8_t *) ®, 1); + } + + return ret; +} + +/** + * @brief Enable/Disable pull-up on SDO pin.[get] + * + * @param ctx read / write interface definitions + * @param val Get the values of sdo_pu_en in reg IF_CTRL + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_sdo_sa0_mode_get(stmdev_ctx_t *ctx, + lps22hh_pu_en_t *val) +{ + lps22hh_if_ctrl_t reg; + int32_t ret; + + ret = lps22hh_read_reg(ctx, LPS22HH_IF_CTRL, (uint8_t *) ®, 1); + + switch (reg.sdo_pu_en) + { + case LPS22HH_PULL_UP_DISCONNECT: + *val = LPS22HH_PULL_UP_DISCONNECT; + break; + + case LPS22HH_PULL_UP_CONNECT: + *val = LPS22HH_PULL_UP_CONNECT; + break; + + default: + *val = LPS22HH_PULL_UP_DISCONNECT; + break; + } + + return ret; +} + +/** + * @brief Connect/Disconnect SDO/SA0 internal pull-up.[set] + * + * @param ctx read / write interface definitions + * @param val change the values of sda_pu_en in reg IF_CTRL + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_sda_mode_set(stmdev_ctx_t *ctx, lps22hh_pu_en_t val) +{ + lps22hh_if_ctrl_t reg; + int32_t ret; + + ret = lps22hh_read_reg(ctx, LPS22HH_IF_CTRL, (uint8_t *) ®, 1); + + if (ret == 0) + { + reg.sda_pu_en = (uint8_t)val; + ret = lps22hh_write_reg(ctx, LPS22HH_IF_CTRL, (uint8_t *) ®, 1); + } + + return ret; +} + +/** + * @brief Connect/Disconnect SDO/SA0 internal pull-up.[get] + * + * @param ctx read / write interface definitions + * @param val Get the values of sda_pu_en in reg IF_CTRL + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_sda_mode_get(stmdev_ctx_t *ctx, lps22hh_pu_en_t *val) +{ + lps22hh_if_ctrl_t reg; + int32_t ret; + + ret = lps22hh_read_reg(ctx, LPS22HH_IF_CTRL, (uint8_t *) ®, 1); + + switch (reg.sda_pu_en) + { + case LPS22HH_PULL_UP_DISCONNECT: + *val = LPS22HH_PULL_UP_DISCONNECT; + break; + + case LPS22HH_PULL_UP_CONNECT: + *val = LPS22HH_PULL_UP_CONNECT; + break; + + default: + *val = LPS22HH_PULL_UP_DISCONNECT; + break; + } + + return ret; +} + +/** + * @brief SPI Serial Interface Mode selection.[set] + * + * @param ctx read / write interface definitions + * @param val change the values of sim in reg CTRL_REG1 + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_spi_mode_set(stmdev_ctx_t *ctx, lps22hh_sim_t val) +{ + lps22hh_ctrl_reg1_t reg; + int32_t ret; + + ret = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG1, (uint8_t *) ®, 1); + + if (ret == 0) + { + reg.sim = (uint8_t)val; + ret = lps22hh_write_reg(ctx, LPS22HH_CTRL_REG1, (uint8_t *) ®, 1); + } + + return ret; +} + +/** + * @brief SPI Serial Interface Mode selection.[get] + * + * @param ctx read / write interface definitions + * @param val Get the values of sim in reg CTRL_REG1 + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_spi_mode_get(stmdev_ctx_t *ctx, lps22hh_sim_t *val) +{ + lps22hh_ctrl_reg1_t reg; + int32_t ret; + + ret = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG1, (uint8_t *) ®, 1); + + switch (reg.sim) + { + case LPS22HH_SPI_4_WIRE: + *val = LPS22HH_SPI_4_WIRE; + break; + + case LPS22HH_SPI_3_WIRE: + *val = LPS22HH_SPI_3_WIRE; + break; + + default: + *val = LPS22HH_SPI_4_WIRE; + break; + } + + return ret; +} + +/** + * @} + * + */ + +/** + * @defgroup LPS22HH_Interrupt_Pins + * @brief This section groups all the functions that manage + * interrupt pins. + * @{ + * + */ + +/** + * @brief Latch interrupt request to the INT_SOURCE (24h) register.[set] + * + * @param ctx read / write interface definitions + * @param val change the values of lir in reg INTERRUPT_CFG + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_int_notification_set(stmdev_ctx_t *ctx, + lps22hh_lir_t val) +{ + lps22hh_interrupt_cfg_t reg; + int32_t ret; + + ret = lps22hh_read_reg(ctx, LPS22HH_INTERRUPT_CFG, (uint8_t *) ®, 1); + + if (ret == 0) + { + reg.lir = (uint8_t)val; + ret = lps22hh_write_reg(ctx, LPS22HH_INTERRUPT_CFG, (uint8_t *) ®, 1); + } + + return ret; +} + +/** + * @brief Latch interrupt request to the INT_SOURCE (24h) register.[get] + * + * @param ctx read / write interface definitions + * @param val Get the values of lir in reg INTERRUPT_CFG + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_int_notification_get(stmdev_ctx_t *ctx, + lps22hh_lir_t *val) +{ + lps22hh_interrupt_cfg_t reg; + int32_t ret; + + ret = lps22hh_read_reg(ctx, LPS22HH_INTERRUPT_CFG, (uint8_t *) ®, 1); + + switch (reg.lir) + { + case LPS22HH_INT_PULSED: + *val = LPS22HH_INT_PULSED; + break; + + case LPS22HH_INT_LATCHED: + *val = LPS22HH_INT_LATCHED; + break; + + default: + *val = LPS22HH_INT_PULSED; + break; + } + + return ret; +} + +/** + * @brief Push-pull/open drain selection on interrupt pads.[set] + * + * @param ctx read / write interface definitions + * @param val change the values of pp_od in reg CTRL_REG2 + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_pin_mode_set(stmdev_ctx_t *ctx, lps22hh_pp_od_t val) +{ + lps22hh_ctrl_reg2_t reg; + int32_t ret; + + ret = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG2, (uint8_t *) ®, 1); + + if (ret == 0) + { + reg.pp_od = (uint8_t)val; + ret = lps22hh_write_reg(ctx, LPS22HH_CTRL_REG2, (uint8_t *) ®, 1); + } + + return ret; +} + +/** + * @brief Push-pull/open drain selection on interrupt pads.[get] + * + * @param ctx read / write interface definitions + * @param val Get the values of pp_od in reg CTRL_REG2 + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_pin_mode_get(stmdev_ctx_t *ctx, lps22hh_pp_od_t *val) +{ + lps22hh_ctrl_reg2_t reg; + int32_t ret; + + ret = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG2, (uint8_t *) ®, 1); + + switch (reg.pp_od) + { + case LPS22HH_PUSH_PULL: + *val = LPS22HH_PUSH_PULL; + break; + + case LPS22HH_OPEN_DRAIN: + *val = LPS22HH_OPEN_DRAIN; + break; + + default: + *val = LPS22HH_PUSH_PULL; + break; + } + + return ret; +} + +/** + * @brief Interrupt active-high/low.[set] + * + * @param ctx read / write interface definitions + * @param val change the values of int_h_l in reg CTRL_REG2 + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_pin_polarity_set(stmdev_ctx_t *ctx, + lps22hh_int_h_l_t val) +{ + lps22hh_ctrl_reg2_t reg; + int32_t ret; + + ret = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG2, (uint8_t *) ®, 1); + + if (ret == 0) + { + reg.int_h_l = (uint8_t)val; + ret = lps22hh_write_reg(ctx, LPS22HH_CTRL_REG2, (uint8_t *) ®, 1); + } + + return ret; +} + +/** + * @brief Interrupt active-high/low.[get] + * + * @param ctx read / write interface definitions + * @param val Get the values of int_h_l in reg CTRL_REG2 + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_pin_polarity_get(stmdev_ctx_t *ctx, + lps22hh_int_h_l_t *val) +{ + lps22hh_ctrl_reg2_t reg; + int32_t ret; + + ret = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG2, (uint8_t *) ®, 1); + + switch (reg.int_h_l) + { + case LPS22HH_ACTIVE_HIGH: + *val = LPS22HH_ACTIVE_HIGH; + break; + + case LPS22HH_ACTIVE_LOW: + *val = LPS22HH_ACTIVE_LOW; + break; + + default: + *val = LPS22HH_ACTIVE_HIGH; + break; + } + + return ret; +} + +/** + * @brief Select the signal that need to route on int pad.[set] + * + * @param ctx read / write interface definitions + * @param val registers CTRL_REG3 + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_pin_int_route_set(stmdev_ctx_t *ctx, + lps22hh_ctrl_reg3_t *val) +{ + int32_t ret; + + ret = lps22hh_write_reg(ctx, LPS22HH_CTRL_REG3, (uint8_t *) val, 1); + + return ret; +} + +/** + * @brief Select the signal that need to route on int pad.[get] + * + * @param ctx read / write interface definitions + * @param val registers CTRL_REG3 + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_pin_int_route_get(stmdev_ctx_t *ctx, + lps22hh_ctrl_reg3_t *val) +{ + int32_t ret; + + ret = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG3, (uint8_t *) val, 1); + + return ret; +} + +/** + * @} + * + */ + +/** + * @defgroup LPS22HH_Interrupt_on_Threshold + * @brief This section groups all the functions that manage the + * interrupt on threshold event generation. + * @{ + * + */ + +/** + * @brief Enable interrupt generation on pressure low/high event.[set] + * + * @param ctx read / write interface definitions + * @param val change the values of pe in reg INTERRUPT_CFG + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_int_on_threshold_set(stmdev_ctx_t *ctx, + lps22hh_pe_t val) +{ + lps22hh_interrupt_cfg_t reg; + int32_t ret; + + ret = lps22hh_read_reg(ctx, LPS22HH_INTERRUPT_CFG, (uint8_t *) ®, 1); + + if (ret == 0) + { + reg.pe = (uint8_t)val; + + if (val == LPS22HH_NO_THRESHOLD) + { + reg.diff_en = PROPERTY_DISABLE; + } + + else + { + reg.diff_en = PROPERTY_ENABLE; + } + + ret = lps22hh_write_reg(ctx, LPS22HH_INTERRUPT_CFG, (uint8_t *) ®, 1); + } + + return ret; +} + +/** + * @brief Enable interrupt generation on pressure low/high event.[get] + * + * @param ctx read / write interface definitions + * @param val Get the values of pe in reg INTERRUPT_CFG + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_int_on_threshold_get(stmdev_ctx_t *ctx, + lps22hh_pe_t *val) +{ + lps22hh_interrupt_cfg_t reg; + int32_t ret; + + ret = lps22hh_read_reg(ctx, LPS22HH_INTERRUPT_CFG, (uint8_t *) ®, 1); + + switch (reg.pe) + { + case LPS22HH_NO_THRESHOLD: + *val = LPS22HH_NO_THRESHOLD; + break; + + case LPS22HH_POSITIVE: + *val = LPS22HH_POSITIVE; + break; + + case LPS22HH_NEGATIVE: + *val = LPS22HH_NEGATIVE; + break; + + case LPS22HH_BOTH: + *val = LPS22HH_BOTH; + break; + + default: + *val = LPS22HH_NO_THRESHOLD; + break; + } + + return ret; +} + +/** + * @brief User-defined threshold value for pressure interrupt event.[set] + * + * @param ctx read / write interface definitions + * @param buff buffer that contains data to write + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_int_treshold_set(stmdev_ctx_t *ctx, uint16_t buff) +{ + int32_t ret; + + lps22hh_ths_p_l_t ths_p_l; + lps22hh_ths_p_h_t ths_p_h; + ths_p_h.ths = (uint8_t)(buff / 256U); + ths_p_l.ths = (uint8_t)(buff - (ths_p_h.ths * 256U)); + ret = lps22hh_write_reg(ctx, LPS22HH_THS_P_L, + (uint8_t *)&ths_p_l, 1); + + if (ret == 0) + { + ret = lps22hh_write_reg(ctx, LPS22HH_THS_P_H, + (uint8_t *)&ths_p_h, 1); + } + + return ret; +} + +/** + * @brief User-defined threshold value for pressure interrupt event.[get] + * + * @param ctx read / write interface definitions + * @param buff buffer that stores data read + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_int_treshold_get(stmdev_ctx_t *ctx, uint16_t *buff) +{ + int32_t ret; + + lps22hh_ths_p_l_t ths_p_l; + lps22hh_ths_p_h_t ths_p_h; + ret = lps22hh_read_reg(ctx, LPS22HH_THS_P_L, + (uint8_t *)&ths_p_l, 1); + + if (ret == 0) + { + ret = lps22hh_read_reg(ctx, LPS22HH_THS_P_H, + (uint8_t *)&ths_p_h, 1); + *buff = (uint16_t)ths_p_h.ths; + *buff = (*buff * 256U) + (uint16_t)ths_p_l.ths; + } + + return ret; +} + +/** + * @} + * + */ + +/** + * @defgroup LPS22HH_Fifo + * @brief This section group all the functions concerning the fifo usage. + * @{ + * + */ + +/** + * @brief Fifo Mode selection.[set] + * + * @param ctx read / write interface definitions + * @param val change the values of f_mode in reg FIFO_CTRL + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_fifo_mode_set(stmdev_ctx_t *ctx, lps22hh_f_mode_t val) +{ + lps22hh_fifo_ctrl_t reg; + int32_t ret; + + ret = lps22hh_read_reg(ctx, LPS22HH_FIFO_CTRL, (uint8_t *) ®, 1); + + if (ret == 0) + { + reg.f_mode = (uint8_t)val; + ret = lps22hh_write_reg(ctx, LPS22HH_FIFO_CTRL, (uint8_t *) ®, 1); + } + + return ret; +} + +/** + * @brief Fifo Mode selection.[get] + * + * @param ctx read / write interface definitions + * @param val Get the values of f_mode in reg FIFO_CTRL + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_fifo_mode_get(stmdev_ctx_t *ctx, + lps22hh_f_mode_t *val) +{ + lps22hh_fifo_ctrl_t reg; + int32_t ret; + + ret = lps22hh_read_reg(ctx, LPS22HH_FIFO_CTRL, (uint8_t *) ®, 1); + + switch (reg.f_mode) + { + case LPS22HH_BYPASS_MODE: + *val = LPS22HH_BYPASS_MODE; + break; + + case LPS22HH_FIFO_MODE: + *val = LPS22HH_FIFO_MODE; + break; + + case LPS22HH_STREAM_MODE: + *val = LPS22HH_STREAM_MODE; + break; + + case LPS22HH_DYNAMIC_STREAM_MODE: + *val = LPS22HH_DYNAMIC_STREAM_MODE; + break; + + case LPS22HH_BYPASS_TO_FIFO_MODE: + *val = LPS22HH_BYPASS_TO_FIFO_MODE; + break; + + case LPS22HH_BYPASS_TO_STREAM_MODE: + *val = LPS22HH_BYPASS_TO_STREAM_MODE; + break; + + case LPS22HH_STREAM_TO_FIFO_MODE: + *val = LPS22HH_STREAM_TO_FIFO_MODE; + break; + + default: + *val = LPS22HH_BYPASS_MODE; + break; + } + + return ret; +} + +/** + * @brief Sensing chain FIFO stop values memorization at + * threshold level.[set] + * + * @param ctx read / write interface definitions + * @param val change the values of stop_on_wtm in reg FIFO_CTRL + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_fifo_stop_on_wtm_set(stmdev_ctx_t *ctx, uint8_t val) +{ + lps22hh_fifo_ctrl_t reg; + int32_t ret; + + ret = lps22hh_read_reg(ctx, LPS22HH_FIFO_CTRL, (uint8_t *) ®, 1); + + if (ret == 0) + { + reg.stop_on_wtm = val; + ret = lps22hh_write_reg(ctx, LPS22HH_FIFO_CTRL, (uint8_t *) ®, 1); + } + + return ret; +} + +/** + * @brief Sensing chain FIFO stop values memorization at threshold + * level.[get] + * + * @param ctx read / write interface definitions + * @param val change the values of stop_on_wtm in reg FIFO_CTRL + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_fifo_stop_on_wtm_get(stmdev_ctx_t *ctx, uint8_t *val) +{ + lps22hh_fifo_ctrl_t reg; + int32_t ret; + + ret = lps22hh_read_reg(ctx, LPS22HH_FIFO_CTRL, (uint8_t *) ®, 1); + *val = reg.stop_on_wtm; + + return ret; +} + +/** + * @brief FIFO watermark level selection.[set] + * + * @param ctx read / write interface definitions + * @param val change the values of wtm in reg FIFO_WTM + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_fifo_watermark_set(stmdev_ctx_t *ctx, uint8_t val) +{ + lps22hh_fifo_wtm_t reg; + int32_t ret; + + ret = lps22hh_read_reg(ctx, LPS22HH_FIFO_WTM, (uint8_t *) ®, 1); + + if (ret == 0) + { + reg.wtm = val; + ret = lps22hh_write_reg(ctx, LPS22HH_FIFO_WTM, (uint8_t *) ®, 1); + } + + return ret; +} + +/** + * @brief FIFO watermark level selection.[get] + * + * @param ctx read / write interface definitions + * @param val change the values of wtm in reg FIFO_WTM + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_fifo_watermark_get(stmdev_ctx_t *ctx, uint8_t *val) +{ + lps22hh_fifo_wtm_t reg; + int32_t ret; + + ret = lps22hh_read_reg(ctx, LPS22HH_FIFO_WTM, (uint8_t *) ®, 1); + *val = reg.wtm; + + return ret; +} + +/** + * @brief FIFO stored data level.[get] + * + * @param ctx read / write interface definitions + * @param buff buffer that stores data read + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_fifo_data_level_get(stmdev_ctx_t *ctx, uint8_t *buff) +{ + int32_t ret; + + ret = lps22hh_read_reg(ctx, LPS22HH_FIFO_STATUS1, buff, 1); + + return ret; +} + +/** + * @brief Read all the FIFO status flag of the device.[get] + * + * @param ctx read / write interface definitions + * @param val registers FIFO_STATUS2 + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_fifo_src_get(stmdev_ctx_t *ctx, + lps22hh_fifo_status2_t *val) +{ + int32_t ret; + + ret = lps22hh_read_reg(ctx, LPS22HH_FIFO_STATUS2, (uint8_t *) val, 1); + + return ret; +} + +/** + * @brief Smart FIFO full status.[get] + * + * @param ctx read / write interface definitions + * @param val change the values of fifo_full_ia in reg FIFO_STATUS2 + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_fifo_full_flag_get(stmdev_ctx_t *ctx, uint8_t *val) +{ + lps22hh_fifo_status2_t reg; + int32_t ret; + + ret = lps22hh_read_reg(ctx, LPS22HH_FIFO_STATUS2, (uint8_t *) ®, 1); + *val = reg.fifo_full_ia; + + return ret; +} + +/** + * @brief FIFO overrun status.[get] + * + * @param ctx read / write interface definitions + * @param val change the values of fifo_ovr_ia in reg FIFO_STATUS2 + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_fifo_ovr_flag_get(stmdev_ctx_t *ctx, uint8_t *val) +{ + lps22hh_fifo_status2_t reg; + int32_t ret; + + ret = lps22hh_read_reg(ctx, LPS22HH_FIFO_STATUS2, (uint8_t *) ®, 1); + *val = reg.fifo_ovr_ia; + + return ret; +} + +/** + * @brief FIFO watermark status.[get] + * + * @param ctx read / write interface definitions + * @param val change the values of fifo_wtm_ia in reg FIFO_STATUS2 + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_fifo_wtm_flag_get(stmdev_ctx_t *ctx, uint8_t *val) +{ + lps22hh_fifo_status2_t reg; + int32_t ret; + + ret = lps22hh_read_reg(ctx, LPS22HH_FIFO_STATUS2, (uint8_t *)®, 1); + *val = reg.fifo_wtm_ia; + + return ret; +} + +/** + * @brief FIFO overrun interrupt on INT_DRDY pin.[set] + * + * @param stmdev_ctx_t *ctx: read / write interface definitions + * @param uint8_t val: change the values of f_ovr in reg CTRL_REG3 + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_fifo_ovr_on_int_set(stmdev_ctx_t *ctx, uint8_t val) +{ + lps22hh_ctrl_reg3_t reg; + int32_t ret; + + ret = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG3, (uint8_t *)®, 1); + + if (ret == 0) + { + reg.int_f_ovr = val; + ret = lps22hh_write_reg(ctx, LPS22HH_CTRL_REG3, (uint8_t *)®, 1); + } + + return ret; +} + +/** + * @brief FIFO overrun interrupt on INT_DRDY pin.[get] + * + * @param stmdev_ctx_t *ctx: read / write interface definitions + * @param uint8_t: change the values of f_ovr in reg CTRL_REG3 + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_fifo_ovr_on_int_get(stmdev_ctx_t *ctx, uint8_t *val) +{ + lps22hh_ctrl_reg3_t reg; + int32_t ret; + + ret = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG3, (uint8_t *)®, 1); + *val = reg.int_f_ovr; + + return ret; +} + +/** + * @brief FIFO watermark status on INT_DRDY pin.[set] + * + * @param stmdev_ctx_t *ctx: read / write interface definitions + * @param uint8_t val: change the values of f_fth in reg CTRL_REG3 + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_fifo_threshold_on_int_set(stmdev_ctx_t *ctx, + uint8_t val) +{ + lps22hh_ctrl_reg3_t reg; + int32_t ret; + + ret = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG3, (uint8_t *)®, 1); + + if (ret == 0) + { + reg.int_f_wtm = val; + ret = lps22hh_write_reg(ctx, LPS22HH_CTRL_REG3, (uint8_t *)®, 1); + } + + return ret; +} + +/** + * @brief FIFO watermark status on INT_DRDY pin.[get] + * + * @param lps22hb_ctx_t *ctx: read / write interface definitions + * @param uint8_t: change the values of f_fth in reg CTRL_REG3 + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_fifo_threshold_on_int_get(stmdev_ctx_t *ctx, + uint8_t *val) +{ + lps22hh_ctrl_reg3_t reg; + int32_t ret; + + ret = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG3, (uint8_t *)®, 1); + *val = reg.int_f_wtm; + + return ret; +} + +/** + * @brief FIFO full flag on INT_DRDY pin.[set] + * + * @param stmdev_ctx_t *ctx: read / write interface definitions + * @param uint8_t val: change the values of f_fss5 in reg CTRL_REG3 + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_fifo_full_on_int_set(stmdev_ctx_t *ctx, uint8_t val) +{ + lps22hh_ctrl_reg3_t reg; + int32_t ret; + + ret = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG3, (uint8_t *)®, 1); + + if (ret == 0) + { + reg.int_f_full = val; + ret = lps22hh_write_reg(ctx, LPS22HH_CTRL_REG3, (uint8_t *)®, 1); + } + + return ret; +} + +/** + * @brief FIFO full flag on INT_DRDY pin.[get] + * + * @param stmdev_ctx_t *ctx: read / write interface definitions + * @param uint8_t: change the values of f_fss5 in reg CTRL_REG3 + * @retval interface status (MANDATORY: return 0 -> no Error) + * + */ +int32_t lps22hh_fifo_full_on_int_get(stmdev_ctx_t *ctx, uint8_t *val) +{ + lps22hh_ctrl_reg3_t reg; + int32_t ret; + + ret = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG3, (uint8_t *)®, 1); + *val = reg.int_f_full; + + return ret; +} + +/** + * @} + * + */ + +/** + * @} + * + */ diff --git a/Drivers/BSP/Components/lps22hh/lps22hh_reg.h b/Drivers/BSP/Components/lps22hh/lps22hh_reg.h new file mode 100644 index 0000000..dfe396c --- /dev/null +++ b/Drivers/BSP/Components/lps22hh/lps22hh_reg.h @@ -0,0 +1,695 @@ +/** + ****************************************************************************** + * @file lps22hh_reg.h + * @author Sensors Software Solution Team + * @brief This file contains all the functions prototypes for the + * lps22hh_reg.c driver. + ****************************************************************************** + * @attention + * + * Copyright (c) 2019 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef LPS22HH_REGS_H +#define LPS22HH_REGS_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include +#include +#include + +/** @addtogroup LPS22HH + * @{ + * + */ + +/** @defgroup Endianness definitions + * @{ + * + */ + +#ifndef DRV_BYTE_ORDER +#ifndef __BYTE_ORDER__ + +#define DRV_LITTLE_ENDIAN 1234 +#define DRV_BIG_ENDIAN 4321 + +/** if _BYTE_ORDER is not defined, choose the endianness of your architecture + * by uncommenting the define which fits your platform endianness + */ +//#define DRV_BYTE_ORDER DRV_BIG_ENDIAN +#define DRV_BYTE_ORDER DRV_LITTLE_ENDIAN + +#else /* defined __BYTE_ORDER__ */ + +#define DRV_LITTLE_ENDIAN __ORDER_LITTLE_ENDIAN__ +#define DRV_BIG_ENDIAN __ORDER_BIG_ENDIAN__ +#define DRV_BYTE_ORDER __BYTE_ORDER__ + +#endif /* __BYTE_ORDER__*/ +#endif /* DRV_BYTE_ORDER */ + +/** + * @} + * + */ + +/** @defgroup STMicroelectronics sensors common types + * @{ + * + */ + +#ifndef MEMS_SHARED_TYPES +#define MEMS_SHARED_TYPES + +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t bit0 : 1; + uint8_t bit1 : 1; + uint8_t bit2 : 1; + uint8_t bit3 : 1; + uint8_t bit4 : 1; + uint8_t bit5 : 1; + uint8_t bit6 : 1; + uint8_t bit7 : 1; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t bit7 : 1; + uint8_t bit6 : 1; + uint8_t bit5 : 1; + uint8_t bit4 : 1; + uint8_t bit3 : 1; + uint8_t bit2 : 1; + uint8_t bit1 : 1; + uint8_t bit0 : 1; +#endif /* DRV_BYTE_ORDER */ +} bitwise_t; + +#define PROPERTY_DISABLE (0U) +#define PROPERTY_ENABLE (1U) + +/** @addtogroup Interfaces_Functions + * @brief This section provide a set of functions used to read and + * write a generic register of the device. + * MANDATORY: return 0 -> no Error. + * @{ + * + */ + +typedef int32_t (*stmdev_write_ptr)(void *, uint8_t, uint8_t *, uint16_t); +typedef int32_t (*stmdev_read_ptr)(void *, uint8_t, uint8_t *, uint16_t); +typedef void (*stmdev_mdelay_ptr)(uint32_t millisec); + +typedef struct +{ + /** Component mandatory fields **/ + stmdev_write_ptr write_reg; + stmdev_read_ptr read_reg; + /** Component optional fields **/ + stmdev_mdelay_ptr mdelay; + /** Customizable optional pointer **/ + void *handle; +} stmdev_ctx_t; + +/** + * @} + * + */ + +#endif /* MEMS_SHARED_TYPES */ + +#ifndef MEMS_UCF_SHARED_TYPES +#define MEMS_UCF_SHARED_TYPES + +/** @defgroup Generic address-data structure definition + * @brief This structure is useful to load a predefined configuration + * of a sensor. + * You can create a sensor configuration by your own or using + * Unico / Unicleo tools available on STMicroelectronics + * web site. + * + * @{ + * + */ + +typedef struct +{ + uint8_t address; + uint8_t data; +} ucf_line_t; + +/** + * @} + * + */ + +#endif /* MEMS_UCF_SHARED_TYPES */ + +/** + * @} + * + */ + +/** @defgroup LPS22HH_Infos + * @{ + * + */ + +/** I2C Device Address 8 bit format if SA0=0 -> B9 if SA0=1 -> BB **/ +#define LPS22HH_I2C_ADD_H 0xBBU +#define LPS22HH_I2C_ADD_L 0xB9U + +/** Device Identification (Who am I) **/ +#define LPS22HH_ID 0xB3U + +/** + * @} + * + */ + +#define LPS22HH_INTERRUPT_CFG 0x0BU +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t pe : 2; /* ple + phe */ + uint8_t lir : 1; + uint8_t diff_en : 1; + uint8_t reset_az : 1; + uint8_t autozero : 1; + uint8_t reset_arp : 1; + uint8_t autorefp : 1; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t autorefp : 1; + uint8_t reset_arp : 1; + uint8_t autozero : 1; + uint8_t reset_az : 1; + uint8_t diff_en : 1; + uint8_t lir : 1; + uint8_t pe : 2; /* ple + phe */ +#endif /* DRV_BYTE_ORDER */ +} lps22hh_interrupt_cfg_t; + +#define LPS22HH_THS_P_L 0x0CU +typedef struct +{ + uint8_t ths : 8; +} lps22hh_ths_p_l_t; + +#define LPS22HH_THS_P_H 0x0DU +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t ths : 7; + uint8_t not_used_01 : 1; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t not_used_01 : 1; + uint8_t ths : 7; +#endif /* DRV_BYTE_ORDER */ +} lps22hh_ths_p_h_t; + +#define LPS22HH_IF_CTRL 0x0EU +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t i2c_disable : 1; + uint8_t i3c_disable : 1; + uint8_t pd_dis_int1 : 1; + uint8_t sdo_pu_en : 1; + uint8_t sda_pu_en : 1; + uint8_t not_used_01 : 2; + uint8_t int_en_i3c : 1; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t int_en_i3c : 1; + uint8_t not_used_01 : 2; + uint8_t sda_pu_en : 1; + uint8_t sdo_pu_en : 1; + uint8_t pd_dis_int1 : 1; + uint8_t i3c_disable : 1; + uint8_t i2c_disable : 1; +#endif /* DRV_BYTE_ORDER */ +} lps22hh_if_ctrl_t; + +#define LPS22HH_WHO_AM_I 0x0FU +#define LPS22HH_CTRL_REG1 0x10U +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t sim : 1; + uint8_t bdu : 1; + uint8_t lpfp_cfg : 2; /* en_lpfp + lpfp_cfg */ + uint8_t odr : 3; + uint8_t not_used_01 : 1; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t not_used_01 : 1; + uint8_t odr : 3; + uint8_t lpfp_cfg : 2; /* en_lpfp + lpfp_cfg */ + uint8_t bdu : 1; + uint8_t sim : 1; +#endif /* DRV_BYTE_ORDER */ +} lps22hh_ctrl_reg1_t; + +#define LPS22HH_CTRL_REG2 0x11U +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t one_shot : 1; + uint8_t low_noise_en : 1; + uint8_t swreset : 1; + uint8_t not_used_01 : 1; + uint8_t if_add_inc : 1; + uint8_t pp_od : 1; + uint8_t int_h_l : 1; + uint8_t boot : 1; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t boot : 1; + uint8_t int_h_l : 1; + uint8_t pp_od : 1; + uint8_t if_add_inc : 1; + uint8_t not_used_01 : 1; + uint8_t swreset : 1; + uint8_t low_noise_en : 1; + uint8_t one_shot : 1; +#endif /* DRV_BYTE_ORDER */ +} lps22hh_ctrl_reg2_t; + +#define LPS22HH_CTRL_REG3 0x12U +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t int_s : 2; + uint8_t drdy : 1; + uint8_t int_f_ovr : 1; + uint8_t int_f_wtm : 1; + uint8_t int_f_full : 1; + uint8_t not_used_01 : 2; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t not_used_01 : 2; + uint8_t int_f_full : 1; + uint8_t int_f_wtm : 1; + uint8_t int_f_ovr : 1; + uint8_t drdy : 1; + uint8_t int_s : 2; +#endif /* DRV_BYTE_ORDER */ +} lps22hh_ctrl_reg3_t; + +#define LPS22HH_FIFO_CTRL 0x13U +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN +uint8_t f_mode : + 3; /* f_mode + trig_modes */ + uint8_t stop_on_wtm : 1; + uint8_t not_used_01 : 4; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t not_used_01 : 4; + uint8_t stop_on_wtm : 1; +uint8_t f_mode : + 3; /* f_mode + trig_modes */ +#endif /* DRV_BYTE_ORDER */ +} lps22hh_fifo_ctrl_t; + +#define LPS22HH_FIFO_WTM 0x14U +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t wtm : 7; + uint8_t not_used_01 : 1; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t not_used_01 : 1; + uint8_t wtm : 7; +#endif /* DRV_BYTE_ORDER */ +} lps22hh_fifo_wtm_t; + +#define LPS22HH_REF_P_L 0x15U +#define LPS22HH_REF_P_H 0x16U +#define LPS22HH_RPDS_L 0x18U +#define LPS22HH_RPDS_H 0x19U +#define LPS22HH_INT_SOURCE 0x24U +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t ph : 1; + uint8_t pl : 1; + uint8_t ia : 1; + uint8_t not_used_01 : 4; + uint8_t boot_on : 1; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t boot_on : 1; + uint8_t not_used_01 : 4; + uint8_t ia : 1; + uint8_t pl : 1; + uint8_t ph : 1; +#endif /* DRV_BYTE_ORDER */ +} lps22hh_int_source_t; + +#define LPS22HH_FIFO_STATUS1 0x25U +#define LPS22HH_FIFO_STATUS2 0x26U +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t not_used_01 : 5; + uint8_t fifo_full_ia : 1; + uint8_t fifo_ovr_ia : 1; + uint8_t fifo_wtm_ia : 1; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t fifo_wtm_ia : 1; + uint8_t fifo_ovr_ia : 1; + uint8_t fifo_full_ia : 1; + uint8_t not_used_01 : 5; +#endif /* DRV_BYTE_ORDER */ +} lps22hh_fifo_status2_t; + +#define LPS22HH_STATUS 0x27U +typedef struct +{ +#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN + uint8_t p_da : 1; + uint8_t t_da : 1; + uint8_t not_used_01 : 2; + uint8_t p_or : 1; + uint8_t t_or : 1; + uint8_t not_used_02 : 2; +#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN + uint8_t not_used_02 : 2; + uint8_t t_or : 1; + uint8_t p_or : 1; + uint8_t not_used_01 : 2; + uint8_t t_da : 1; + uint8_t p_da : 1; +#endif /* DRV_BYTE_ORDER */ +} lps22hh_status_t; + +#define LPS22HH_PRESS_OUT_XL 0x28U +#define LPS22HH_PRESS_OUT_L 0x29U +#define LPS22HH_PRESS_OUT_H 0x2AU +#define LPS22HH_TEMP_OUT_L 0x2BU +#define LPS22HH_TEMP_OUT_H 0x2CU +#define LPS22HH_FIFO_DATA_OUT_PRESS_XL 0x78U +#define LPS22HH_FIFO_DATA_OUT_PRESS_L 0x79U +#define LPS22HH_FIFO_DATA_OUT_PRESS_H 0x7AU +#define LPS22HH_FIFO_DATA_OUT_TEMP_L 0x7BU +#define LPS22HH_FIFO_DATA_OUT_TEMP_H 0x7CU + +/** + * @defgroup LPS22HH_Register_Union + * @brief This union group all the registers having a bit-field + * description. + * This union is useful but it's not needed by the driver. + * + * REMOVING this union you are compliant with: + * MISRA-C 2012 [Rule 19.2] -> " Union are not allowed " + * + * @{ + * + */ +typedef union +{ + lps22hh_interrupt_cfg_t interrupt_cfg; + lps22hh_if_ctrl_t if_ctrl; + lps22hh_ctrl_reg1_t ctrl_reg1; + lps22hh_ctrl_reg2_t ctrl_reg2; + lps22hh_ctrl_reg3_t ctrl_reg3; + lps22hh_fifo_ctrl_t fifo_ctrl; + lps22hh_fifo_wtm_t fifo_wtm; + lps22hh_int_source_t int_source; + lps22hh_fifo_status2_t fifo_status2; + lps22hh_status_t status; + bitwise_t bitwise; + uint8_t byte; +} lps22hh_reg_t; + +/** + * @} + * + */ + +#ifndef __weak +#define __weak __attribute__((weak)) +#endif /* __weak */ + +/* + * These are the basic platform dependent I/O routines to read + * and write device registers connected on a standard bus. + * The driver keeps offering a default implementation based on function + * pointers to read/write routines for backward compatibility. + * The __weak directive allows the final application to overwrite + * them with a custom implementation. + */ +int32_t lps22hh_read_reg(stmdev_ctx_t *ctx, uint8_t reg, + uint8_t *data, + uint16_t len); +int32_t lps22hh_write_reg(stmdev_ctx_t *ctx, uint8_t reg, + uint8_t *data, + uint16_t len); + +float_t lps22hh_from_lsb_to_hpa(uint32_t lsb); + +float_t lps22hh_from_lsb_to_celsius(int16_t lsb); + +int32_t lps22hh_autozero_rst_set(stmdev_ctx_t *ctx, uint8_t val); +int32_t lps22hh_autozero_rst_get(stmdev_ctx_t *ctx, uint8_t *val); + +int32_t lps22hh_autozero_set(stmdev_ctx_t *ctx, uint8_t val); +int32_t lps22hh_autozero_get(stmdev_ctx_t *ctx, uint8_t *val); + +int32_t lps22hh_pressure_snap_rst_set(stmdev_ctx_t *ctx, uint8_t val); +int32_t lps22hh_pressure_snap_rst_get(stmdev_ctx_t *ctx, + uint8_t *val); + +int32_t lps22hh_pressure_snap_set(stmdev_ctx_t *ctx, uint8_t val); +int32_t lps22hh_pressure_snap_get(stmdev_ctx_t *ctx, uint8_t *val); + +int32_t lps22hh_block_data_update_set(stmdev_ctx_t *ctx, uint8_t val); +int32_t lps22hh_block_data_update_get(stmdev_ctx_t *ctx, + uint8_t *val); + +typedef enum +{ + LPS22HH_POWER_DOWN = 0x00, + LPS22HH_ONE_SHOOT = 0x08, + LPS22HH_1_Hz = 0x01, + LPS22HH_10_Hz = 0x02, + LPS22HH_25_Hz = 0x03, + LPS22HH_50_Hz = 0x04, + LPS22HH_75_Hz = 0x05, + LPS22HH_1_Hz_LOW_NOISE = 0x11, + LPS22HH_10_Hz_LOW_NOISE = 0x12, + LPS22HH_25_Hz_LOW_NOISE = 0x13, + LPS22HH_50_Hz_LOW_NOISE = 0x14, + LPS22HH_75_Hz_LOW_NOISE = 0x15, + LPS22HH_100_Hz = 0x06, + LPS22HH_200_Hz = 0x07, +} lps22hh_odr_t; +int32_t lps22hh_data_rate_set(stmdev_ctx_t *ctx, lps22hh_odr_t val); +int32_t lps22hh_data_rate_get(stmdev_ctx_t *ctx, lps22hh_odr_t *val); + +int32_t lps22hh_pressure_ref_set(stmdev_ctx_t *ctx, int16_t val); +int32_t lps22hh_pressure_ref_get(stmdev_ctx_t *ctx, int16_t *val); + +int32_t lps22hh_pressure_offset_set(stmdev_ctx_t *ctx, int16_t val); +int32_t lps22hh_pressure_offset_get(stmdev_ctx_t *ctx, int16_t *val); + +typedef struct +{ + lps22hh_int_source_t int_source; + lps22hh_fifo_status2_t fifo_status2; + lps22hh_status_t status; +} lps22hh_all_sources_t; +int32_t lps22hh_all_sources_get(stmdev_ctx_t *ctx, + lps22hh_all_sources_t *val); + +int32_t lps22hh_status_reg_get(stmdev_ctx_t *ctx, + lps22hh_status_t *val); + +int32_t lps22hh_press_flag_data_ready_get(stmdev_ctx_t *ctx, + uint8_t *val); + +int32_t lps22hh_temp_flag_data_ready_get(stmdev_ctx_t *ctx, + uint8_t *val); + +int32_t lps22hh_pressure_raw_get(stmdev_ctx_t *ctx, uint32_t *buff); + +int32_t lps22hh_temperature_raw_get(stmdev_ctx_t *ctx, int16_t *buff); + +int32_t lps22hh_fifo_pressure_raw_get(stmdev_ctx_t *ctx, + uint32_t *buff); + +int32_t lps22hh_fifo_temperature_raw_get(stmdev_ctx_t *ctx, + int16_t *buff); + +int32_t lps22hh_device_id_get(stmdev_ctx_t *ctx, uint8_t *buff); + +int32_t lps22hh_reset_set(stmdev_ctx_t *ctx, uint8_t val); +int32_t lps22hh_reset_get(stmdev_ctx_t *ctx, uint8_t *val); + +int32_t lps22hh_auto_increment_set(stmdev_ctx_t *ctx, uint8_t val); +int32_t lps22hh_auto_increment_get(stmdev_ctx_t *ctx, uint8_t *val); + +int32_t lps22hh_boot_set(stmdev_ctx_t *ctx, uint8_t val); +int32_t lps22hh_boot_get(stmdev_ctx_t *ctx, uint8_t *val); + +typedef enum +{ + LPS22HH_LPF_ODR_DIV_2 = 0, + LPS22HH_LPF_ODR_DIV_9 = 2, + LPS22HH_LPF_ODR_DIV_20 = 3, +} lps22hh_lpfp_cfg_t; +int32_t lps22hh_lp_bandwidth_set(stmdev_ctx_t *ctx, + lps22hh_lpfp_cfg_t val); +int32_t lps22hh_lp_bandwidth_get(stmdev_ctx_t *ctx, + lps22hh_lpfp_cfg_t *val); + +typedef enum +{ + LPS22HH_I2C_ENABLE = 0, + LPS22HH_I2C_DISABLE = 1, +} lps22hh_i2c_disable_t; +int32_t lps22hh_i2c_interface_set(stmdev_ctx_t *ctx, + lps22hh_i2c_disable_t val); +int32_t lps22hh_i2c_interface_get(stmdev_ctx_t *ctx, + lps22hh_i2c_disable_t *val); + +typedef enum +{ + LPS22HH_I3C_ENABLE = 0x00, + LPS22HH_I3C_ENABLE_INT_PIN_ENABLE = 0x10, + LPS22HH_I3C_DISABLE = 0x11, +} lps22hh_i3c_disable_t; +int32_t lps22hh_i3c_interface_set(stmdev_ctx_t *ctx, + lps22hh_i3c_disable_t val); +int32_t lps22hh_i3c_interface_get(stmdev_ctx_t *ctx, + lps22hh_i3c_disable_t *val); + +typedef enum +{ + LPS22HH_PULL_UP_DISCONNECT = 0, + LPS22HH_PULL_UP_CONNECT = 1, +} lps22hh_pu_en_t; +int32_t lps22hh_sdo_sa0_mode_set(stmdev_ctx_t *ctx, + lps22hh_pu_en_t val); +int32_t lps22hh_sdo_sa0_mode_get(stmdev_ctx_t *ctx, + lps22hh_pu_en_t *val); +int32_t lps22hh_sda_mode_set(stmdev_ctx_t *ctx, lps22hh_pu_en_t val); +int32_t lps22hh_sda_mode_get(stmdev_ctx_t *ctx, lps22hh_pu_en_t *val); + +typedef enum +{ + LPS22HH_SPI_4_WIRE = 0, + LPS22HH_SPI_3_WIRE = 1, +} lps22hh_sim_t; +int32_t lps22hh_spi_mode_set(stmdev_ctx_t *ctx, lps22hh_sim_t val); +int32_t lps22hh_spi_mode_get(stmdev_ctx_t *ctx, lps22hh_sim_t *val); + +typedef enum +{ + LPS22HH_INT_PULSED = 0, + LPS22HH_INT_LATCHED = 1, +} lps22hh_lir_t; +int32_t lps22hh_int_notification_set(stmdev_ctx_t *ctx, + lps22hh_lir_t val); +int32_t lps22hh_int_notification_get(stmdev_ctx_t *ctx, + lps22hh_lir_t *val); + +typedef enum +{ + LPS22HH_PUSH_PULL = 0, + LPS22HH_OPEN_DRAIN = 1, +} lps22hh_pp_od_t; +int32_t lps22hh_pin_mode_set(stmdev_ctx_t *ctx, lps22hh_pp_od_t val); +int32_t lps22hh_pin_mode_get(stmdev_ctx_t *ctx, lps22hh_pp_od_t *val); + +typedef enum +{ + LPS22HH_ACTIVE_HIGH = 0, + LPS22HH_ACTIVE_LOW = 1, +} lps22hh_int_h_l_t; +int32_t lps22hh_pin_polarity_set(stmdev_ctx_t *ctx, + lps22hh_int_h_l_t val); +int32_t lps22hh_pin_polarity_get(stmdev_ctx_t *ctx, + lps22hh_int_h_l_t *val); + +int32_t lps22hh_pin_int_route_set(stmdev_ctx_t *ctx, + lps22hh_ctrl_reg3_t *val); +int32_t lps22hh_pin_int_route_get(stmdev_ctx_t *ctx, + lps22hh_ctrl_reg3_t *val); + +typedef enum +{ + LPS22HH_NO_THRESHOLD = 0, + LPS22HH_POSITIVE = 1, + LPS22HH_NEGATIVE = 2, + LPS22HH_BOTH = 3, +} lps22hh_pe_t; +int32_t lps22hh_int_on_threshold_set(stmdev_ctx_t *ctx, + lps22hh_pe_t val); +int32_t lps22hh_int_on_threshold_get(stmdev_ctx_t *ctx, + lps22hh_pe_t *val); + +int32_t lps22hh_int_treshold_set(stmdev_ctx_t *ctx, uint16_t buff); +int32_t lps22hh_int_treshold_get(stmdev_ctx_t *ctx, uint16_t *buff); + +typedef enum +{ + LPS22HH_BYPASS_MODE = 0, + LPS22HH_FIFO_MODE = 1, + LPS22HH_STREAM_MODE = 2, + LPS22HH_DYNAMIC_STREAM_MODE = 3, + LPS22HH_BYPASS_TO_FIFO_MODE = 5, + LPS22HH_BYPASS_TO_STREAM_MODE = 6, + LPS22HH_STREAM_TO_FIFO_MODE = 7, +} lps22hh_f_mode_t; +int32_t lps22hh_fifo_mode_set(stmdev_ctx_t *ctx, + lps22hh_f_mode_t val); +int32_t lps22hh_fifo_mode_get(stmdev_ctx_t *ctx, + lps22hh_f_mode_t *val); + +int32_t lps22hh_fifo_stop_on_wtm_set(stmdev_ctx_t *ctx, uint8_t val); +int32_t lps22hh_fifo_stop_on_wtm_get(stmdev_ctx_t *ctx, uint8_t *val); + +int32_t lps22hh_fifo_watermark_set(stmdev_ctx_t *ctx, uint8_t val); +int32_t lps22hh_fifo_watermark_get(stmdev_ctx_t *ctx, uint8_t *val); + +int32_t lps22hh_fifo_data_level_get(stmdev_ctx_t *ctx, uint8_t *buff); + +int32_t lps22hh_fifo_src_get(stmdev_ctx_t *ctx, + lps22hh_fifo_status2_t *val); + +int32_t lps22hh_fifo_full_flag_get(stmdev_ctx_t *ctx, uint8_t *val); + +int32_t lps22hh_fifo_ovr_flag_get(stmdev_ctx_t *ctx, uint8_t *val); + +int32_t lps22hh_fifo_wtm_flag_get(stmdev_ctx_t *ctx, uint8_t *val); + +int32_t lps22hh_fifo_ovr_on_int_set(stmdev_ctx_t *ctx, uint8_t val); +int32_t lps22hh_fifo_ovr_on_int_get(stmdev_ctx_t *ctx, uint8_t *val); + +int32_t lps22hh_fifo_threshold_on_int_set(stmdev_ctx_t *ctx, + uint8_t val); +int32_t lps22hh_fifo_threshold_on_int_get(stmdev_ctx_t *ctx, + uint8_t *val); + +int32_t lps22hh_fifo_full_on_int_set(stmdev_ctx_t *ctx, uint8_t val); +int32_t lps22hh_fifo_full_on_int_get(stmdev_ctx_t *ctx, uint8_t *val); + +/** + * @} + * + */ + +#ifdef __cplusplus +} +#endif + +#endif /*LPS22HH_REGS_H */