pkarashchenko commented on code in PR #6345: URL: https://github.com/apache/incubator-nuttx/pull/6345#discussion_r885034885
########## boards/arm/cxd56xx/common/src/cxd56_isx019.c: ########## @@ -0,0 +1,203 @@ +/**************************************************************************** + * boards/arm/cxd56xx/common/src/cxd56_isx019.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. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> + +#include <stdio.h> +#include <debug.h> +#include <errno.h> + +#include <nuttx/arch.h> +#include <nuttx/board.h> +#include <nuttx/signal.h> + +#include "cxd56_gpio.h" +#include "cxd56_pinconfig.h" +#include "cxd56_i2c.h" +#include "cxd56_clock.h" + +#include <arch/board/board.h> + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* Check if the following are defined in the board.h */ + +#ifndef IMAGER_RST +# error "IMAGER_RST must be defined in board.h !!" +#endif + +#define POWER_CHECK_TIME (1 * 1000) /* ms */ +#define POWER_OFF_TIME (50 * 1000) /* ms */ + +#define POWER_CHECK_RETRY (10) + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +int board_isx019_power_on(void) +{ + int ret; + int i; + + ret = board_power_control(POWER_IMAGE_SENSOR, true); + if (ret) + { + _err("ERROR: Failed to power on ImageSensor. %d\n", ret); + return -ENODEV; + } + + ret = -ETIMEDOUT; + for (i = 0; i < POWER_CHECK_RETRY; i++) + { + /* Need to wait for a while after power-on */ + + nxsig_usleep(POWER_CHECK_TIME); + + if (board_power_monitor(POWER_IMAGE_SENSOR)) + { + ret = OK; + break; + } + } + + return ret; +} + +int board_isx019_power_off(void) +{ + int ret; + int i; + + ret = board_power_control(POWER_IMAGE_SENSOR, false); + if (ret) + { + _err("ERROR: Failed to power off ImageSensor. %d\n", ret); + return -ENODEV; + } + + /* Need to wait for power-off to be reflected */ + + nxsig_usleep(POWER_OFF_TIME); + + ret = -ETIMEDOUT; + for (i = 0; i < POWER_CHECK_RETRY; i++) + { + if (!board_power_monitor(POWER_IMAGE_SENSOR)) + { + ret = OK; + break; + } + + nxsig_usleep(POWER_CHECK_TIME); + } + + return ret; +} + +void board_isx019_set_reset(void) +{ + cxd56_gpio_write(IMAGER_RST, false); +} + +void board_isx019_release_reset(void) +{ + cxd56_gpio_write(IMAGER_RST, true); +} + +struct i2c_master_s *board_isx019_initialize(void) +{ + int retry = 50; + + _info("Initializing ISX019...\n"); + + while (!g_rtc_enabled && 0 < retry--) + { + /* ISX019 requires stable RTC */ + + nxsig_usleep(100 * 1000); Review Comment: Optional ```suggestion nxsig_usleep(100 * USEC_PER_MSEC); ``` ########## drivers/video/isx019.c: ########## @@ -0,0 +1,3249 @@ +/**************************************************************************** + * drivers/video/isx019.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. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> +#include <sys/time.h> +#include <stdio.h> +#include <string.h> +#include <assert.h> +#include <errno.h> +#include <debug.h> +#include <nuttx/i2c/i2c_master.h> +#include <nuttx/signal.h> +#include <arch/board/board.h> +#include <nuttx/video/isx019.h> +#include <nuttx/video/imgsensor.h> +#include <math.h> +#include <nuttx/semaphore.h> + +#include "isx019_reg.h" +#include "isx019_range.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* Wait time on power on sequence. */ + +#define TRANSITION_TIME_TO_STARTUP (120 * 1000) /* unit : usec */ +#define TRANSITION_TIME_TO_STREAMING (30 * 1000) /* unit : usec */ + +/* For get_supported_value() I/F */ + +#define SET_RANGE(range, min, max, s, def) \ + do \ + { \ + range.minimum = min; \ + range.maximum = max; \ + range.step = s; \ + range.default_value = def; \ Review Comment: ```suggestion (range).minimum = (min); \ (range).maximum = (max); \ (range).step = (s); \ (range).default_value = (def); \ ``` ########## drivers/video/isx019.c: ########## @@ -0,0 +1,3249 @@ +/**************************************************************************** + * drivers/video/isx019.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. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> +#include <sys/time.h> +#include <stdio.h> +#include <string.h> +#include <assert.h> +#include <errno.h> +#include <debug.h> +#include <nuttx/i2c/i2c_master.h> +#include <nuttx/signal.h> +#include <arch/board/board.h> +#include <nuttx/video/isx019.h> +#include <nuttx/video/imgsensor.h> +#include <math.h> +#include <nuttx/semaphore.h> + +#include "isx019_reg.h" +#include "isx019_range.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* Wait time on power on sequence. */ + +#define TRANSITION_TIME_TO_STARTUP (120 * 1000) /* unit : usec */ +#define TRANSITION_TIME_TO_STREAMING (30 * 1000) /* unit : usec */ + +/* For get_supported_value() I/F */ + +#define SET_RANGE(range, min, max, s, def) \ + do \ + { \ + range.minimum = min; \ + range.maximum = max; \ + range.step = s; \ + range.default_value = def; \ + } \ + while (0); + +#define SET_DISCRETE(disc, nr, val, def) \ + do \ + { \ + disc.nr_values = nr; \ + disc.values = val; \ + disc.default_value = def; \ + } \ + while (0); + +#define SET_ELEMS(elem, nr, min, max, s) \ + do \ + { \ + elem.nr_elems = nr; \ + elem.minimum = min; \ + elem.maximum = max; \ + elem.step = s; \ Review Comment: ```suggestion (elem).nr_elems = (nr); \ (elem).minimum = (min); \ (elem).maximum = (max); \ (elem).step = (s); \ ``` ########## boards/arm/cxd56xx/common/src/cxd56_isx019.c: ########## @@ -0,0 +1,203 @@ +/**************************************************************************** + * boards/arm/cxd56xx/common/src/cxd56_isx019.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. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> + +#include <stdio.h> +#include <debug.h> +#include <errno.h> + +#include <nuttx/arch.h> +#include <nuttx/board.h> +#include <nuttx/signal.h> + +#include "cxd56_gpio.h" +#include "cxd56_pinconfig.h" +#include "cxd56_i2c.h" +#include "cxd56_clock.h" + +#include <arch/board/board.h> + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* Check if the following are defined in the board.h */ + +#ifndef IMAGER_RST +# error "IMAGER_RST must be defined in board.h !!" +#endif + +#define POWER_CHECK_TIME (1 * 1000) /* ms */ +#define POWER_OFF_TIME (50 * 1000) /* ms */ Review Comment: Optional ```suggestion #define POWER_CHECK_TIME (1 * USEC_PER_MSEC) /* ms */ #define POWER_OFF_TIME (50 * USEC_PER_MSEC) /* ms */ ``` ########## drivers/video/isx019.c: ########## @@ -0,0 +1,3249 @@ +/**************************************************************************** + * drivers/video/isx019.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. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> +#include <sys/time.h> +#include <stdio.h> +#include <string.h> +#include <assert.h> +#include <errno.h> +#include <debug.h> +#include <nuttx/i2c/i2c_master.h> +#include <nuttx/signal.h> +#include <arch/board/board.h> +#include <nuttx/video/isx019.h> +#include <nuttx/video/imgsensor.h> +#include <math.h> +#include <nuttx/semaphore.h> + +#include "isx019_reg.h" +#include "isx019_range.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* Wait time on power on sequence. */ + +#define TRANSITION_TIME_TO_STARTUP (120 * 1000) /* unit : usec */ +#define TRANSITION_TIME_TO_STREAMING (30 * 1000) /* unit : usec */ Review Comment: Optional ```suggestion #define TRANSITION_TIME_TO_STARTUP (120 * USEC_PER_MSEC) /* unit : usec */ #define TRANSITION_TIME_TO_STREAMING (30 * USEC_PER_MSEC) /* unit : usec */ ``` ########## drivers/video/isx019.c: ########## @@ -0,0 +1,3249 @@ +/**************************************************************************** + * drivers/video/isx019.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. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> +#include <sys/time.h> +#include <stdio.h> +#include <string.h> +#include <assert.h> +#include <errno.h> +#include <debug.h> +#include <nuttx/i2c/i2c_master.h> +#include <nuttx/signal.h> +#include <arch/board/board.h> +#include <nuttx/video/isx019.h> +#include <nuttx/video/imgsensor.h> +#include <math.h> +#include <nuttx/semaphore.h> + +#include "isx019_reg.h" +#include "isx019_range.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* Wait time on power on sequence. */ + +#define TRANSITION_TIME_TO_STARTUP (120 * 1000) /* unit : usec */ +#define TRANSITION_TIME_TO_STREAMING (30 * 1000) /* unit : usec */ + +/* For get_supported_value() I/F */ + +#define SET_RANGE(range, min, max, s, def) \ + do \ + { \ + range.minimum = min; \ + range.maximum = max; \ + range.step = s; \ + range.default_value = def; \ + } \ + while (0); + +#define SET_DISCRETE(disc, nr, val, def) \ + do \ + { \ + disc.nr_values = nr; \ + disc.values = val; \ + disc.default_value = def; \ Review Comment: ```suggestion (disc).nr_values = (nr); \ (disc).values = (val); \ (disc).default_value = (def); \ ``` -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
