risc-v/esp32c3: Add board_ioctl and board_uniqueid

This commit is contained in:
Dong Heng
2021-07-02 16:48:45 +08:00
committed by Xiang Xiao
parent 935c206bd4
commit 475becac37
6 changed files with 237 additions and 0 deletions
+1
View File
@@ -50,6 +50,7 @@ CHIP_CSRCS += esp32c3_irq.c
CHIP_CSRCS += esp32c3_clockconfig.c esp32c3_gpio.c
CHIP_CSRCS += esp32c3_lowputc.c
CHIP_CSRCS += esp32c3_systemreset.c esp32c3_resetcause.c
CHIP_CSRCS += esp32c3_uid.c
ifeq ($(CONFIG_SCHED_TICKLESS),y)
CHIP_CSRCS += esp32c3_tickless.c
+58
View File
@@ -0,0 +1,58 @@
/****************************************************************************
* arch/risc-v/src/esp32c3/esp32c3_uid.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 <stdint.h>
#include <nuttx/arch.h>
#include <nuttx/board.h>
#include "hardware/esp32c3_efuse.h"
#include "esp32c3.h"
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: esp32c3_get_uniqueid
*
* Description:
* Get CPU unique ID.
*
* Parameters:
* uniqueid - unique ID buffer
*
****************************************************************************/
void esp32c3_get_uniqueid(uint8_t *uniqueid)
{
int i;
for (i = 0; i < 16; i++)
{
uniqueid[i] = getreg8(EFUSE_RD_SYS_DATA_PART1_0_REG + i);
}
}
+50
View File
@@ -0,0 +1,50 @@
/****************************************************************************
* arch/risc-v/src/esp32c3/esp32c3_uid.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 __ARCH_RISCV_SRC_ESP32C3_ESP32C3_UID_H
#define __ARCH_RISCV_SRC_ESP32C3_ESP32C3_UID_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/irq.h>
#include <stdint.h>
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/****************************************************************************
* Name: esp32c3_get_uniqueid
*
* Description:
* Get CPU unique ID.
*
* Parameters:
* uniqueid - unique ID buffer
*
****************************************************************************/
void esp32c3_get_uniqueid(uint8_t *uniqueid);
#endif /* __ARCH_RISCV_SRC_ESP32C3_ESP32C3_UID_H */