You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "acassis (via GitHub)" <gi...@apache.org> on 2023/07/08 18:26:13 UTC
[GitHub] [nuttx] acassis commented on a diff in pull request #9746: NRF91: more work towards a usable port
acassis commented on code in PR #9746:
URL: https://github.com/apache/nuttx/pull/9746#discussion_r1257326355
##########
arch/arm/src/nrf91/nrf91_flash.c:
##########
@@ -0,0 +1,399 @@
+/****************************************************************************
+ * arch/arm/src/nrf91/nrf91_flash.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 <errno.h>
+
+#include <nuttx/arch.h>
+#include <nuttx/progmem.h>
+
+#include "arm_internal.h"
+#include "barriers.h"
+
+#include "hardware/nrf91_ficr.h"
+#include "hardware/nrf91_nvmc.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define MEMORY_SYNC() ARM_ISB(); ARM_DSB()
+
+/* Sizes and masks */
+
+#define NRF91_FLASH_ERASEDVAL (0xff)
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+static inline uint32_t nrf91_get_flash_size(void)
+{
+ return getreg32(NRF91_FICR_INFO_FLASH) * 1024;
+}
+
+static inline uint32_t nrf91_get_page_size(void)
+{
+ return getreg32(NRF91_FICR_INFO_CODEPAGESIZE);
+}
+
+static inline uint32_t nrf91_get_pages_num(void)
+{
+ return getreg32(NRF91_FICR_INFO_CODESIZE);
+}
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: up_progmem_pagesize
+ *
+ * Description:
+ * Return page size
+ *
+ ****************************************************************************/
+
+size_t up_progmem_pagesize(size_t page)
+{
+ if (page >= up_progmem_neraseblocks())
+ {
+ return 0;
+ }
+ else
+ {
+ return nrf91_get_page_size();
+ }
+}
+
+/****************************************************************************
+ * Name: up_progmem_erasesize
+ *
+ * Description:
+ * Return erase block size
+ *
Review Comment:
Ditto: size_t block
##########
arch/arm/src/nrf91/nrf91_flash.c:
##########
@@ -0,0 +1,399 @@
+/****************************************************************************
+ * arch/arm/src/nrf91/nrf91_flash.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 <errno.h>
+
+#include <nuttx/arch.h>
+#include <nuttx/progmem.h>
+
+#include "arm_internal.h"
+#include "barriers.h"
+
+#include "hardware/nrf91_ficr.h"
+#include "hardware/nrf91_nvmc.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define MEMORY_SYNC() ARM_ISB(); ARM_DSB()
+
+/* Sizes and masks */
+
+#define NRF91_FLASH_ERASEDVAL (0xff)
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+static inline uint32_t nrf91_get_flash_size(void)
+{
+ return getreg32(NRF91_FICR_INFO_FLASH) * 1024;
+}
+
+static inline uint32_t nrf91_get_page_size(void)
+{
+ return getreg32(NRF91_FICR_INFO_CODEPAGESIZE);
+}
+
+static inline uint32_t nrf91_get_pages_num(void)
+{
+ return getreg32(NRF91_FICR_INFO_CODESIZE);
+}
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: up_progmem_pagesize
+ *
+ * Description:
+ * Return page size
+ *
Review Comment:
Please include the input "size_t page" parameter
--
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