You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2021/04/09 13:16:54 UTC

[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a change in pull request #3487: Adds common master bus interface and implementation for onewire support

xiaoxiang781216 commented on a change in pull request #3487:
URL: https://github.com/apache/incubator-nuttx/pull/3487#discussion_r610611656



##########
File path: include/nuttx/1wire/1wire_master.h
##########
@@ -0,0 +1,179 @@
+/****************************************************************************
+ * include/nuttx/1wire/1wire_master.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_1WIRE_1WIRE_MASTER_H
+#define __INCLUDE_NUTTX_1WIRE_1WIRE_MASTER_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdbool.h>
+
+/****************************************************************************
+ * Public Types
+ ****************************************************************************/
+
+struct onewire_dev_s;
+struct onewire_master_s;
+
+struct onewire_config_s
+{
+  uint64_t romcode;                 /* Unique device identifier */
+};
+
+/****************************************************************************
+ * Public Function Prototypes
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: onewire_search
+ *
+ * Description:
+ *   Search all devices from a 1-wire network. This is the 1-wire search
+ *   algorithm from Maxim Application Note 187.
+ *
+ * Input Parameters:
+ *   master    - Pointer to the allocated 1-wire interface
+ *   family    - Limit search to devices of matching family
+ *   alarmonly - Limit search to devices on alarm state
+ *   cb_search - Callback to call on each device found
+ *   arg       - Argument passed to cb_search
+ *
+ * Return Value:
+ *   Number of slaves present and matching family.
+ *
+ ****************************************************************************/
+
+int onewire_search(FAR struct onewire_master_s *master,
+                   int family,
+                   bool alarmonly,
+                   CODE void (*cb_search)(int family,
+                                          uint64_t romcode,
+                                          FAR void *arg),
+                   FAR  void *arg);

Review comment:
       ```suggestion
                      FAR void *arg);
   ```
   

##########
File path: include/nuttx/1wire/1wire_master.h
##########
@@ -0,0 +1,179 @@
+/****************************************************************************
+ * include/nuttx/1wire/1wire_master.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_1WIRE_1WIRE_MASTER_H
+#define __INCLUDE_NUTTX_1WIRE_1WIRE_MASTER_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdbool.h>

Review comment:
       add #include <stdint.h>
   

##########
File path: drivers/1wire/ds28e17.c
##########
@@ -45,6 +45,7 @@
 
 #include <nuttx/kmalloc.h>
 #include <nuttx/i2c/i2c_master.h>

Review comment:
       remove too

##########
File path: drivers/1wire/1wire.c
##########
@@ -45,6 +45,7 @@
 
 #include <nuttx/kmalloc.h>
 #include <nuttx/i2c/i2c_master.h>
+#include <nuttx/1wire/1wire_master.h>
 #include <nuttx/drivers/1wire.h>

Review comment:
       should we move 1wire.h from nuttx/drivers/ to nuttx/1wire too?

##########
File path: include/nuttx/1wire/1wire_master.h
##########
@@ -0,0 +1,179 @@
+/****************************************************************************
+ * include/nuttx/1wire/1wire_master.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_1WIRE_1WIRE_MASTER_H
+#define __INCLUDE_NUTTX_1WIRE_1WIRE_MASTER_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdbool.h>
+
+/****************************************************************************
+ * Public Types
+ ****************************************************************************/
+
+struct onewire_dev_s;
+struct onewire_master_s;
+
+struct onewire_config_s
+{
+  uint64_t romcode;                 /* Unique device identifier */
+};
+
+/****************************************************************************
+ * Public Function Prototypes
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: onewire_search
+ *
+ * Description:
+ *   Search all devices from a 1-wire network. This is the 1-wire search
+ *   algorithm from Maxim Application Note 187.
+ *
+ * Input Parameters:
+ *   master    - Pointer to the allocated 1-wire interface
+ *   family    - Limit search to devices of matching family
+ *   alarmonly - Limit search to devices on alarm state
+ *   cb_search - Callback to call on each device found
+ *   arg       - Argument passed to cb_search
+ *
+ * Return Value:
+ *   Number of slaves present and matching family.
+ *
+ ****************************************************************************/
+
+int onewire_search(FAR struct onewire_master_s *master,
+                   int family,
+                   bool alarmonly,
+                   CODE void (*cb_search)(int family,
+                                          uint64_t romcode,
+                                          FAR void *arg),
+                   FAR  void *arg);
+
+/****************************************************************************
+ * Name: onewire_write
+ *
+ * Description:
+ *   Send a block of data on 1WIRE. Each write operation will be an 'atomic'
+ *   operation in the sense that any other 1WIRE actions will be serialized
+ *   and pend until this write completes.
+ *
+ * Input Parameters:
+ *   master - Device-specific state data
+ *   config - Described the 1WIRE configuration
+ *   buffer - A pointer to the read-only buffer of data to be written to
+ *            device
+ *   buflen - The number of bytes to send from the buffer
+ *
+ * Returned Value:
+ *   0: success, <0: A negated errno
+ *
+ ****************************************************************************/
+
+int onewire_write(FAR struct onewire_master_s *master,
+                  FAR const struct onewire_config_s *config,
+                  FAR const uint8_t *buffer, int buflen);

Review comment:
       can we change all buffer pointer type to void * or const void *?

##########
File path: include/nuttx/1wire/1wire_master.h
##########
@@ -0,0 +1,179 @@
+/****************************************************************************
+ * include/nuttx/1wire/1wire_master.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_1WIRE_1WIRE_MASTER_H
+#define __INCLUDE_NUTTX_1WIRE_1WIRE_MASTER_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdbool.h>
+
+/****************************************************************************
+ * Public Types
+ ****************************************************************************/
+
+struct onewire_dev_s;
+struct onewire_master_s;
+
+struct onewire_config_s
+{
+  uint64_t romcode;                 /* Unique device identifier */
+};
+
+/****************************************************************************
+ * Public Function Prototypes
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: onewire_search
+ *
+ * Description:
+ *   Search all devices from a 1-wire network. This is the 1-wire search
+ *   algorithm from Maxim Application Note 187.
+ *
+ * Input Parameters:
+ *   master    - Pointer to the allocated 1-wire interface
+ *   family    - Limit search to devices of matching family
+ *   alarmonly - Limit search to devices on alarm state
+ *   cb_search - Callback to call on each device found
+ *   arg       - Argument passed to cb_search
+ *
+ * Return Value:
+ *   Number of slaves present and matching family.
+ *
+ ****************************************************************************/
+
+int onewire_search(FAR struct onewire_master_s *master,
+                   int family,
+                   bool alarmonly,
+                   CODE void (*cb_search)(int family,
+                                          uint64_t romcode,
+                                          FAR void *arg),
+                   FAR  void *arg);
+
+/****************************************************************************
+ * Name: onewire_write
+ *
+ * Description:
+ *   Send a block of data on 1WIRE. Each write operation will be an 'atomic'
+ *   operation in the sense that any other 1WIRE actions will be serialized
+ *   and pend until this write completes.
+ *
+ * Input Parameters:
+ *   master - Device-specific state data
+ *   config - Described the 1WIRE configuration
+ *   buffer - A pointer to the read-only buffer of data to be written to
+ *            device
+ *   buflen - The number of bytes to send from the buffer
+ *
+ * Returned Value:
+ *   0: success, <0: A negated errno
+ *
+ ****************************************************************************/
+
+int onewire_write(FAR struct onewire_master_s *master,
+                  FAR const struct onewire_config_s *config,
+                  FAR const uint8_t *buffer, int buflen);
+
+/****************************************************************************
+ * Name: onewire_read
+ *
+ * Description:
+ *   Receive a block of data from 1WIRE. Each read operation will be an
+ *   'atomic' operation in the sense that any other 1WIRE actions will be
+ *   serialized and pend until this read completes.
+ *
+ * Input Parameters:
+ *   master - Device-specific state data
+ *   config - Described the 1WIRE configuration
+ *   buffer - A pointer to a buffer of data to receive the data from the
+ *            device
+ *   buflen - The requested number of bytes to be read
+ *
+ * Returned Value:
+ *   0: success, <0: A negated errno
+ *
+ ****************************************************************************/
+
+int onewire_read(FAR struct onewire_master_s *master,
+                 FAR const struct onewire_config_s *config,
+                 FAR uint8_t *buffer, int buflen);
+
+/****************************************************************************
+ * Name: onewire_writeread
+ *
+ * Description:
+ *   Receive a block of data from 1WIRE. Each read operation will be an
+ *   'atomic' operation in the sense that any other 1WIRE actions will be
+ *   serialized and pend until this read completes.
+ *
+ * Input Parameters:
+ *   master  - Device-specific state data
+ *   config  - Described the 1WIRE configuration
+ *   wbuffer - A pointer to the read-only buffer of data to be written to
+ *             device
+ *   wbuflen - The number of bytes to send from the buffer
+ *   rbuffer - A pointer to a buffer of data to receive the data from the
+ *             device
+ *   rbuflen - The requested number of bytes to be read
+ *
+ * Returned Value:
+ *   0: success, <0: A negated errno
+ *
+ ****************************************************************************/
+
+int onewire_writeread(FAR struct onewire_master_s *master,
+                      FAR const struct onewire_config_s *config,
+                      FAR const uint8_t *wbuffer, int wbuflen,
+                      FAR uint8_t *rbuffer, int rbuflen);
+
+/****************************************************************************
+ * Name: onewire_initialize
+ *
+ * Description:
+ *   Return 1-wire bus master from 1-wire lower half device.
+ *
+ * Input Parameters:
+ *   dev       - Pointer to the allocated 1-wire lower half
+ *   maxslaves - Maximum number of 1-wire slave devices
+ *
+ ****************************************************************************/
+
+FAR struct onewire_master_s *
+  onewire_initialize(FAR struct onewire_dev_s *dev, int maxslaves);

Review comment:
       remove the space at the beginning

##########
File path: drivers/1wire/1wire.c
##########
@@ -45,6 +45,7 @@
 
 #include <nuttx/kmalloc.h>
 #include <nuttx/i2c/i2c_master.h>

Review comment:
       remove?




-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org