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 2022/06/20 03:22:29 UTC

[GitHub] [incubator-nuttx] no1wudi opened a new pull request, #6487: risc-v/esp32c3: Implement up_perf_xxx API

no1wudi opened a new pull request, #6487:
URL: https://github.com/apache/incubator-nuttx/pull/6487

   ## Summary
   Implement up_perf_xxx API
   ## Impact
   New feature for esp32c3
   ## Testing
   Custom board
   


-- 
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-unsubscribe@nuttx.apache.org

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


[GitHub] [incubator-nuttx] gustavonihei commented on a diff in pull request #6487: risc-v/esp32c3: Implement up_perf_xxx API

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on code in PR #6487:
URL: https://github.com/apache/incubator-nuttx/pull/6487#discussion_r901662567


##########
arch/risc-v/src/esp32c3/esp32c3_perf.c:
##########
@@ -0,0 +1,84 @@
+/****************************************************************************
+ * arch/risc-v/src/esp32c3/esp32c3_perf.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this args 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 <nuttx/clock.h>
+
+#include <stdint.h>
+#include <time.h>
+
+#include "esp32c3_attr.h"
+#include "riscv_internal.h"
+#include "hardware/esp32c3_system.h"
+#include "esp32c3_clockconfig.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define NSEC_PER_CYCLE (1000 / CONFIG_ESP32C3_CPU_FREQ_MHZ)
+#define CYCLE_PER_SEC  (NSEC_PER_SEC / NSEC_PER_CYCLE)
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: up_perf_init
+ ****************************************************************************/
+
+void up_perf_init(FAR void *arg)
+{
+  WRITE_CSR(CSR_PCER_MACHINE, 0x1);
+  WRITE_CSR(CSR_PCMR_MACHINE, 0x1);
+}
+
+/****************************************************************************
+ * Name: up_perf_gettime
+ ****************************************************************************/
+
+uint32_t IRAM_ATTR up_perf_gettime(void)
+{
+  return READ_CSR(CSR_PCCR_MACHINE);
+}
+
+/****************************************************************************
+ * Name: up_perf_getfreq
+ ****************************************************************************/
+
+uint32_t up_perf_getfreq(void)
+{
+  return CYCLE_PER_SEC;
+}
+
+/****************************************************************************
+ * Name: up_perf_convert
+ ****************************************************************************/
+
+void up_perf_convert(uint32_t elapsed, FAR struct timespec *ts)

Review Comment:
   ```suggestion
   void up_perf_convert(uint32_t elapsed, struct timespec *ts)
   ```



-- 
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-unsubscribe@nuttx.apache.org

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


[GitHub] [incubator-nuttx] xiaoxiang781216 merged pull request #6487: risc-v/esp32c3: Implement up_perf_xxx API

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 merged PR #6487:
URL: https://github.com/apache/incubator-nuttx/pull/6487


-- 
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-unsubscribe@nuttx.apache.org

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


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #6487: risc-v/esp32c3: Implement up_perf_xxx API

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #6487:
URL: https://github.com/apache/incubator-nuttx/pull/6487#discussion_r901382191


##########
arch/risc-v/src/esp32c3/esp32c3_perf.c:
##########
@@ -0,0 +1,84 @@
+/****************************************************************************
+ * arch/risc-v/src/esp32c3/esp32c3_perf.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this args 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 <nuttx/clock.h>
+
+#include <stdint.h>
+#include <time.h>
+
+#include "esp32c3_attr.h"
+#include "riscv_internal.h"
+#include "hardware/esp32c3_system.h"
+#include "esp32c3_clockconfig.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define NSEC_PER_CYCLE (1000 / CONFIG_ESP32C3_CPU_FREQ_MHZ)
+#define CYCLE_PER_SEC  (NSEC_PER_SEC / NSEC_PER_CYCLE)

Review Comment:
   change to:
   (1000000 * CONFIG_ESP32C3_CPU_FREQ_MHZ)
   avoid the potential round error



-- 
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-unsubscribe@nuttx.apache.org

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


[GitHub] [incubator-nuttx] pkarashchenko commented on a diff in pull request #6487: risc-v/esp32c3: Implement up_perf_xxx API

Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on code in PR #6487:
URL: https://github.com/apache/incubator-nuttx/pull/6487#discussion_r901552737


##########
arch/risc-v/src/esp32c3/esp32c3_perf.c:
##########
@@ -0,0 +1,84 @@
+/****************************************************************************
+ * arch/risc-v/src/esp32c3/esp32c3_perf.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this args 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 <nuttx/clock.h>
+
+#include <stdint.h>
+#include <time.h>
+
+#include "esp32c3_attr.h"
+#include "riscv_internal.h"
+#include "hardware/esp32c3_system.h"
+#include "esp32c3_clockconfig.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define NSEC_PER_CYCLE (1000 / CONFIG_ESP32C3_CPU_FREQ_MHZ)
+#define CYCLE_PER_SEC  (NSEC_PER_SEC / NSEC_PER_CYCLE)

Review Comment:
   or `USEC_PER_SEC * CONFIG_ESP32C3_CPU_FREQ_MHZ`



-- 
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-unsubscribe@nuttx.apache.org

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


[GitHub] [incubator-nuttx] gustavonihei commented on a diff in pull request #6487: risc-v/esp32c3: Implement up_perf_xxx API

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on code in PR #6487:
URL: https://github.com/apache/incubator-nuttx/pull/6487#discussion_r901662366


##########
arch/risc-v/src/esp32c3/esp32c3_perf.c:
##########
@@ -0,0 +1,84 @@
+/****************************************************************************
+ * arch/risc-v/src/esp32c3/esp32c3_perf.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this args 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 <nuttx/clock.h>
+
+#include <stdint.h>
+#include <time.h>
+
+#include "esp32c3_attr.h"
+#include "riscv_internal.h"
+#include "hardware/esp32c3_system.h"
+#include "esp32c3_clockconfig.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define NSEC_PER_CYCLE (1000 / CONFIG_ESP32C3_CPU_FREQ_MHZ)
+#define CYCLE_PER_SEC  (NSEC_PER_SEC / NSEC_PER_CYCLE)
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: up_perf_init
+ ****************************************************************************/
+
+void up_perf_init(FAR void *arg)

Review Comment:
   ```suggestion
   void up_perf_init(void *arg)
   ```
   No need to add `FAR` here



-- 
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-unsubscribe@nuttx.apache.org

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