; *************************************************************************** ; copyright : (C) 2025 by Martin Preuss ; email : martin@libchipcard.de ; ; *************************************************************************** ; * This file is part of the project "AqHome". * ; * Please see toplevel file COPYING of that project for license details. * ; *************************************************************************** ; *************************************************************************** ; defines .equ SGP30_FLAGS_PRESENT_BIT = 7 .equ SGP30_FLAGS_DATAVALID_BIT = 6 .equ SGP30_CMD_INIT = 0x2003 .equ SGP30_CMD_MEASURE = 0x2008 .equ SGP30_VALUE_TVOC = 0x01 .equ SGP30_VALUE_CO2 = 0x02 ; *************************************************************************** ; data .dseg sgp30DataBegin: sgp30Flags: .byte 1 sgp30LastCo2: .byte 2 sgp30LastTvoc: .byte 2 sgp30DataEnd: ; *************************************************************************** ; code .cseg ; --------------------------------------------------------------------------- ; SGP30_Init ; SGP30_Init: ldi xh, HIGH(sgp30DataBegin) ldi xl, LOW(sgp30DataBegin) clr r16 ldi r17, (sgp30DataEnd-sgp30DataBegin) rcall Utils_FillSram rjmp sg30InitIfNeeded ; @end ; --------------------------------------------------------------------------- ; SGP30_Fini ; SGP30_Fini: sec ret ; @end ; --------------------------------------------------------------------------- ; @routine SGP30_GetValue @global ; ; @param R16 value to get (SI7021_VALUE_TEMP, SI7021_VALUE_HUMIDITY) ; @return CFLAG set if value available, cleared otherwise ; @return R19:R18 value ; @return R21:R20 denom (e.g. 100, meaning value must be divided by 100) ; @clobbers SGP30_GetValue: lds r18, sgp30Flags andi r18, (1<