pkarashchenko commented on code in PR #7466: URL: https://github.com/apache/incubator-nuttx/pull/7466#discussion_r1009045059
########## drivers/sensors/ltr308.c: ########## @@ -0,0 +1,1000 @@ +/**************************************************************************** + * drivers/sensors/ltr308.c + * + * 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. + * + ****************************************************************************/ + +/* Character driver for the LTR-308ALS-01 Lite-On ambient light sensor */ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> + +#include <stdio.h> +#include <stdlib.h> +#include <debug.h> + +#include <nuttx/kmalloc.h> +#include <nuttx/fs/fs.h> +#include <nuttx/i2c/i2c_master.h> +#include <nuttx/sensors/ltr308.h> + +#if defined(CONFIG_I2C) && defined(CONFIG_SENSORS_LTR308) + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define LTR308_ADDR 0x53 +#define LTR308_FREQ CONFIG_LTR308_I2C_FREQUENCY +#define DEVID 0xB1 + +#define LTR308_CTRL 0x00 +#define LTR308_MEAS_RATE 0x04 +#define LTR308_ALS_GAIN 0x05 +#define LTR308_PART_ID 0x06 +#define LTR308_STATUS 0x07 +#define LTR308_DATA_0 0x0D +#define LTR308_DATA_1 0x0E +#define LTR308_DATA_2 0x0F +#define LTR308_INTERRUPT 0x19 +#define LTR308_INTR_PERS 0x1A +#define LTR308_THRES_UP_0 0x21 +#define LTR308_THRES_UP_1 0x22 +#define LTR308_THRES_UP_2 0x23 +#define LTR308_THRES_LOW_0 0x24 +#define LTR308_THRES_LOW_1 0x25 +#define LTR308_THRES_LOW_2 0x26 + +#define BYTE_TO_BITS 8 + +/**************************************************************************** + * Private Type Definitions + ****************************************************************************/ + +struct ltr308_dev_s +{ + FAR struct i2c_master_s *i2c; /* I2C interface */ + uint8_t addr; /* I2C address */ + int freq; /* I2C bus frequency */ +#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS + bool unlinked; /* True, driver has been unlinked */ + int16_t crefs; /* Number of open references */ +#endif + sem_t devsem; +}; + +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + +#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS +static int ltr308_open(FAR struct file *filep); +static int ltr308_close(FAR struct file *filep); +#endif +static ssize_t ltr308_read(FAR struct file *filep, FAR char *buffer, + size_t len); +static ssize_t ltr308_ioctl(FAR struct file *filep, int cmd, + unsigned long arg); +#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS +static int ltr308_unlink(FAR struct inode *inode); +#endif + +/**************************************************************************** + * Private Data +****************************************************************************/ + +static const struct file_operations g_ltr308fops = +{ +#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS + .open = ltr308_open, Review Comment: Yes. The common code should be C89 compliant. -- 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