TimJTi commented on code in PR #8789: URL: https://github.com/apache/nuttx/pull/8789#discussion_r1143709072
########## include/nuttx/sensors/apds9922.h: ########## @@ -0,0 +1,315 @@ +/**************************************************************************** + * include/nuttx/sensors/apds9922.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __INCLUDE_NUTTX_SENSORS_APDS9922_H +#define __INCLUDE_NUTTX_SENSORS_APDS9922_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> +#include <nuttx/irq.h> +#include <nuttx/i2c/i2c_master.h> +#include <nuttx/sensors/ioctl.h> + +#if defined(CONFIG_SENSORS_APDS9922) + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ +#define APDS9922_I2C_ADDR (0x53) +#define APDS9922_ID_VAL (0xb3) + +#define PS_DEF_THRESHU (0x07ff) +#define PS_DEF_THRESHL (0) +#define PS_DEF_CANCEL_LVL (0) +#define PS_DEF_PULSES (0x08) +#define ALS_DEF_THRESHU (0x0fffff) +#define ALS_DEF_THRESHL (0) +#define PS_DEF_PERSISTANCE (0) +#define ALS_DEF_PERSISTANCE (0) +#define ALS_DEF_VAR (0) + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +enum apds9922_als_rate +{ + ALS_RATE25MS = 0, + ALS_RATE50MS, + ALS_RATE100MS, + ALS_RATE200MS, + ALS_RATE500MS, + ALS_RATE1000MS, + ALS_RATE2000MS, + ALS_RATE4000MS, +}; + +static const uint32_t apds9922_als_res_table[] = Review Comment: The values are actually sequential integers and map to the register value very conveniently, and the names are descriptive to make it clear what the integer value represents in milliseconds. Isn't this unnecessary? What are you trying to achieve - if I understand that I can come up with something, hopefully? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org