mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-10-10 18:58:32 +08:00
[bsp]1.update es32f0334 libraries.
2.adapt to the new power management interface.
3.move es32f0334 folder to essemi folder.
This commit is contained in:
@@ -1,74 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018 Shanghai Eastsoft Microelectronics Co., Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2019-04-08 wangyq the first version
|
||||
* 2019-05-06 Zero-Free adapt to the new power management interface
|
||||
*/
|
||||
|
||||
#include <rthw.h>
|
||||
#include <rtdevice.h>
|
||||
#include "board.h"
|
||||
#include "drv_pm.h"
|
||||
#include <ald_pmu.h>
|
||||
|
||||
#ifdef RT_USING_PM
|
||||
|
||||
static void _drv_pm_enter(struct rt_pm *pm, uint8_t mode)
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
case PM_SLEEP_MODE_NONE:
|
||||
break;
|
||||
|
||||
case PM_SLEEP_MODE_IDLE:
|
||||
__WFI();
|
||||
break;
|
||||
|
||||
case PM_SLEEP_MODE_LIGHT:
|
||||
break;
|
||||
|
||||
case PM_SLEEP_MODE_DEEP:
|
||||
pmu_stop2_enter();
|
||||
break;
|
||||
|
||||
case PM_SLEEP_MODE_STANDBY:
|
||||
pmu_standby_enter(PMU_STANDBY_PORT_NONE);
|
||||
break;
|
||||
|
||||
case PM_SLEEP_MODE_SHUTDOWN:
|
||||
break;
|
||||
|
||||
default:
|
||||
RT_ASSERT(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static int drv_hw_pm_init(void)
|
||||
{
|
||||
static const struct rt_pm_ops _ops =
|
||||
{
|
||||
_drv_pm_enter,
|
||||
RT_NULL,
|
||||
RT_NULL,
|
||||
RT_NULL,
|
||||
RT_NULL
|
||||
};
|
||||
|
||||
rt_uint8_t timer_mask = 0;
|
||||
|
||||
/* initialize timer mask(no need tickless) */
|
||||
// timer_mask = 1UL << PM_SLEEP_MODE_DEEP;
|
||||
|
||||
/* initialize system pm module */
|
||||
rt_system_pm_init(&_ops, timer_mask, RT_NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
INIT_BOARD_EXPORT(drv_hw_pm_init);
|
||||
|
||||
#endif
|
||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@@ -1,11 +0,0 @@
|
||||
Import('ES32_SDK_ROOT')
|
||||
|
||||
from building import *
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
src = Glob('*.c')
|
||||
include_path = [cwd]
|
||||
|
||||
group = DefineGroup('CMSIS2', src, depend = [''], CPPPATH = include_path)
|
||||
|
||||
Return('group')
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,14 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>Redirect to the CMSIS main page after 0 seconds</title>
|
||||
<meta http-equiv="refresh" content="0; URL=Documentation/General/html/index.html">
|
||||
<meta name="keywords" content="automatic redirection">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
If the automatic redirection is failing, click <a href="Documentation/General/html/index.html">open CMSIS Documentation</a>.
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,184 +0,0 @@
|
||||
/**
|
||||
*********************************************************************************
|
||||
*
|
||||
* @file ald_bkpc.h
|
||||
* @brief Header file of BKPC module driver.
|
||||
*
|
||||
* @version V1.0
|
||||
* @date 15 Dec 2017
|
||||
* @author AE Team
|
||||
* @note
|
||||
*
|
||||
* Copyright (C) Shanghai Eastsoft Microelectronics Co. Ltd. All rights reserved.
|
||||
*
|
||||
********************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __ALD_BKPC_H__
|
||||
#define __ALD_BKPC_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
|
||||
/** @addtogroup ES32FXXX_ALD
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup BKPC
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup BKPC_Public_Macros BKPC Public Macros
|
||||
* @{
|
||||
*/
|
||||
#define BKPC_LOCK() (WRITE_REG(BKPC->PROT, 0))
|
||||
#define BKPC_UNLOCK() (WRITE_REG(BKPC->PROT, 0x9669AA55))
|
||||
#define BKPC_LRC_ENABLE() \
|
||||
do { \
|
||||
BKPC_UNLOCK(); \
|
||||
SET_BIT(BKPC->CR, BKPC_CR_LRCEN_MSK); \
|
||||
BKPC_LOCK(); \
|
||||
} while (0)
|
||||
#define BKPC_LRC_DISABLE() \
|
||||
do { \
|
||||
BKPC_UNLOCK(); \
|
||||
CLEAR_BIT(BKPC->CR, BKPC_CR_LRCEN_MSK); \
|
||||
BKPC_LOCK(); \
|
||||
} while (0)
|
||||
#define BKPC_LOSM_ENABLE() \
|
||||
do { \
|
||||
BKPC_UNLOCK(); \
|
||||
SET_BIT(BKPC->CR, BKPC_CR_LOSMEN_MSK); \
|
||||
BKPC_LOCK(); \
|
||||
} while (0)
|
||||
#define BKPC_LOSM_DISABLE() \
|
||||
do { \
|
||||
BKPC_UNLOCK(); \
|
||||
CLEAR_BIT(BKPC->CR, BKPC_CR_LOSMEN_MSK);\
|
||||
BKPC_LOCK(); \
|
||||
} while (0)
|
||||
#define BKPC_LOSC_ENABLE() \
|
||||
do { \
|
||||
BKPC_UNLOCK(); \
|
||||
SET_BIT(BKPC->CR, BKPC_CR_LOSCEN_MSK); \
|
||||
BKPC_LOCK(); \
|
||||
} while (0)
|
||||
#define BKPC_LOSC_DISABLE() \
|
||||
do { \
|
||||
BKPC_UNLOCK(); \
|
||||
CLEAR_BIT(BKPC->CR, BKPC_CR_LOSCEN_MSK);\
|
||||
BKPC_LOCK(); \
|
||||
} while (0)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup BKPC_Public_Types BKPC Public Types
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @brief BKPC ldo output select
|
||||
*/
|
||||
typedef enum {
|
||||
BKPC_LDO_OUTPUT_1_6 = 0x0, /**< 1.6V */
|
||||
BKPC_LDO_OUTPUT_1_3 = 0x1, /**< 1.3V */
|
||||
BKPC_LDO_OUTPUT_1_4 = 0x2, /**< 1.4V */
|
||||
BKPC_LDO_OUTPUT_1_5 = 0x4, /**< 1.5V */
|
||||
} bkpc_ldo_output_t;
|
||||
|
||||
/**
|
||||
* @brief BKPC BOR voltage select
|
||||
*/
|
||||
typedef enum {
|
||||
BKPC_BOR_VOL_1_7 = 0x0, /**< 1.7V */
|
||||
BKPC_BOR_VOL_2_0 = 0x1, /**< 2.0V */
|
||||
BKPC_BOR_VOL_2_1 = 0x2, /**< 2.1V */
|
||||
BKPC_BOR_VOL_2_2 = 0x3, /**< 2.2V */
|
||||
BKPC_BOR_VOL_2_3 = 0x4, /**< 2.3V */
|
||||
BKPC_BOR_VOL_2_4 = 0x5, /**< 2.4V */
|
||||
BKPC_BOR_VOL_2_5 = 0x6, /**< 2.5V */
|
||||
BKPC_BOR_VOL_2_6 = 0x7, /**< 2.6V */
|
||||
BKPC_BOR_VOL_2_8 = 0x8, /**< 2.8V */
|
||||
BKPC_BOR_VOL_3_0 = 0x9, /**< 3.0V */
|
||||
BKPC_BOR_VOL_3_1 = 0xA, /**< 3.1V */
|
||||
BKPC_BOR_VOL_3_3 = 0xB, /**< 3.3V */
|
||||
BKPC_BOR_VOL_3_6 = 0xC, /**< 3.6V */
|
||||
BKPC_BOR_VOL_3_7 = 0xD, /**< 3.7V */
|
||||
BKPC_BOR_VOL_4_0 = 0xE, /**< 4.0V */
|
||||
BKPC_BOR_VOL_4_3 = 0xF, /**< 4.3V */
|
||||
} bkpc_bor_vol_t;
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup BKPC_Private_Macros BKPC Private Macros
|
||||
* @{
|
||||
*/
|
||||
#define IS_BKPC_LDO_OUTPUT(x) (((x) == BKPC_LDO_OUTPUT_1_6) || \
|
||||
((x) == BKPC_LDO_OUTPUT_1_3) || \
|
||||
((x) == BKPC_LDO_OUTPUT_1_4) || \
|
||||
((x) == BKPC_LDO_OUTPUT_1_5))
|
||||
#define IS_BKPC_BOR_VOL(x) (((x) == BKPC_BOR_VOL_1_7) || \
|
||||
((x) == BKPC_BOR_VOL_2_0) || \
|
||||
((x) == BKPC_BOR_VOL_2_1) || \
|
||||
((x) == BKPC_BOR_VOL_2_2) || \
|
||||
((x) == BKPC_BOR_VOL_2_3) || \
|
||||
((x) == BKPC_BOR_VOL_2_4) || \
|
||||
((x) == BKPC_BOR_VOL_2_5) || \
|
||||
((x) == BKPC_BOR_VOL_2_6) || \
|
||||
((x) == BKPC_BOR_VOL_2_8) || \
|
||||
((x) == BKPC_BOR_VOL_3_0) || \
|
||||
((x) == BKPC_BOR_VOL_3_1) || \
|
||||
((x) == BKPC_BOR_VOL_3_3) || \
|
||||
((x) == BKPC_BOR_VOL_3_6) || \
|
||||
((x) == BKPC_BOR_VOL_3_7) || \
|
||||
((x) == BKPC_BOR_VOL_4_0) || \
|
||||
((x) == BKPC_BOR_VOL_4_3))
|
||||
#define IS_BKPC_RAM_IDX(x) ((x) < 32)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup BKPC_Public_Functions
|
||||
* @{
|
||||
*/
|
||||
/** @addtogroup BKPC_Public_Functions_Group1
|
||||
* @{
|
||||
*/
|
||||
/* control functions */
|
||||
extern void bkpc_ldo_config(bkpc_ldo_output_t output, type_func_t state);
|
||||
extern void bkpc_bor_config(bkpc_bor_vol_t vol, type_func_t state);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/** @addtogroup BKPC_Public_Functions_Group2
|
||||
* @{
|
||||
*/
|
||||
/* IO operation functions */
|
||||
extern void bkpc_write_ram(uint8_t idx, uint32_t value);
|
||||
extern uint32_t bkpc_read_ram(uint8_t idx);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ALD_BKPC_H__ */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,191 +0,0 @@
|
||||
/**
|
||||
*********************************************************************************
|
||||
*
|
||||
* @file ald_crc.h
|
||||
* @brief Header file of CRC module driver.
|
||||
*
|
||||
* @version V1.0
|
||||
* @date 6 Dec 2017
|
||||
* @author AE Team
|
||||
* @note
|
||||
*
|
||||
* Copyright (C) Shanghai Eastsoft Microelectronics Co. Ltd. All rights reserved.
|
||||
*
|
||||
*********************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __ALD_CRC_H__
|
||||
#define __ALD_CRC_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "utils.h"
|
||||
#include "ald_dma.h"
|
||||
|
||||
/** @addtogroup ES32FXXX_ALD
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup CRC
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup CRC_Public_Types CRC Public Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief CRC mode
|
||||
*/
|
||||
typedef enum {
|
||||
CRC_MODE_CCITT = 0, /**< Ccitt */
|
||||
CRC_MODE_8 = 1, /**< Crc8 */
|
||||
CRC_MODE_16 = 2, /**< Crc16 */
|
||||
CRC_MODE_32 = 3, /**< Crc32 */
|
||||
} crc_mode_t;
|
||||
|
||||
/**
|
||||
* @brief CRC input length
|
||||
*/
|
||||
typedef enum {
|
||||
CRC_LEN_AUTO = 0, /**< Auto */
|
||||
CRC_DATASIZE_8 = 1, /**< Byte */
|
||||
CRC_DATASIZE_16 = 2, /**< Half word */
|
||||
CRC_DATASIZE_32 = 3, /**< Word */
|
||||
} crc_datasize_t;
|
||||
|
||||
/**
|
||||
* @brief CRC whether write error or no
|
||||
*/
|
||||
typedef enum {
|
||||
CRC_WERR_NO = 0, /**< No error */
|
||||
CRC_WERR_ERR = 1, /**< Error */
|
||||
} crc_werr_t;
|
||||
|
||||
/**
|
||||
* @brief CRC state structures definition
|
||||
*/
|
||||
typedef enum {
|
||||
CRC_STATE_RESET = 0x0, /**< Peripheral is not initialized */
|
||||
CRC_STATE_READY = 0x1, /**< Peripheral Initialized and ready for use */
|
||||
CRC_STATE_BUSY = 0x2, /**< An internal process is ongoing */
|
||||
CRC_STATE_ERROR = 0x4, /**< Error */
|
||||
} crc_state_t;
|
||||
|
||||
/**
|
||||
* @brief CRC init structure definition
|
||||
*/
|
||||
typedef struct {
|
||||
crc_mode_t mode; /**< CRC mode */
|
||||
type_func_t data_rev; /**< CRC data reverse or no */
|
||||
type_func_t data_inv; /**< CRC data inverse or no */
|
||||
type_func_t chs_rev; /**< CRC check sum reverse or no */
|
||||
type_func_t chs_inv; /**< CRC check sum inverse or no */
|
||||
uint32_t seed; /**< CRC seed */
|
||||
} crc_init_t;
|
||||
|
||||
/**
|
||||
* @brief CRC Handle Structure definition
|
||||
*/
|
||||
typedef struct crc_handle_s {
|
||||
CRC_TypeDef *perh; /**< Register base address */
|
||||
crc_init_t init; /**< CRC required parameters */
|
||||
uint8_t *cal_buf; /**< The pointer of preparing buffer */
|
||||
uint32_t *cal_res; /**< The pointer of result */
|
||||
#ifdef ALD_DMA
|
||||
dma_handle_t hdma; /**< CRC DMA handle parameters */
|
||||
#endif
|
||||
lock_state_t lock; /**< Locking object */
|
||||
crc_state_t state; /**< CRC operation state */
|
||||
|
||||
void (*cal_cplt_cbk)(struct crc_handle_s *arg); /**< Calculate completed callback */
|
||||
void (*err_cplt_cbk)(struct crc_handle_s *arg); /**< Calculate error callback */
|
||||
} crc_handle_t;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup CRC_Public_Macros CRC Public Macros
|
||||
* @{
|
||||
*/
|
||||
#define CRC_ENABLE(handle) (SET_BIT((handle)->perh->CR, CRC_CR_EN_MSK))
|
||||
#define CRC_DISABLE(handle) (CLEAR_BIT((handle)->perh->CR, CRC_CR_EN_MSK))
|
||||
#define CRC_RESET(handle) (SET_BIT((handle)->perh->CR, CRC_CR_RST_MSK))
|
||||
#define CRC_DMA_ENABLE(handle) (SET_BIT((handle)->perh->CR, CRC_CR_DMAEN_MSK))
|
||||
#define CRC_DMA_DISABLE(handle) (CLEAR_BIT((handle)->perh->CR, CRC_CR_DMAEN_MSK))
|
||||
#define CRC_CLEAR_ERROR_FLAG(handle) (SET_BIT((handle)->perh->CR, CRC_CR_WERR_MSK))
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup CRC_Private_Macros CRC Private Macros
|
||||
* @{
|
||||
*/
|
||||
#define IS_CRC(x) ((x) == CRC)
|
||||
#define IS_CRC_MODE(x) (((x) == CRC_MODE_CCITT) || \
|
||||
((x) == CRC_MODE_8) || \
|
||||
((x) == CRC_MODE_16) || \
|
||||
((x) == CRC_MODE_32))
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup CRC_Public_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup CRC_Public_Functions_Group1
|
||||
* @{
|
||||
*/
|
||||
ald_status_t crc_init(crc_handle_t *hperh);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup CRC_Public_Functions_Group2
|
||||
* @{
|
||||
*/
|
||||
uint32_t crc_calculate(crc_handle_t *hperh, uint8_t *buf, uint32_t size);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef ALD_DMA
|
||||
/** @addtogroup CRC_Public_Functions_Group3
|
||||
* @{
|
||||
*/
|
||||
ald_status_t crc_calculate_by_dma(crc_handle_t *hperh, uint8_t *buf, uint32_t *res, uint16_t size, uint8_t channel);
|
||||
ald_status_t crc_dma_pause(crc_handle_t *hperh);
|
||||
ald_status_t crc_dma_resume(crc_handle_t *hperh);
|
||||
ald_status_t crc_dma_stop(crc_handle_t *hperh);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
#endif
|
||||
/** @addtogroup CRC_Public_Functions_Group4
|
||||
* @{
|
||||
*/
|
||||
crc_state_t crc_get_state(crc_handle_t *hperh);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ALD_CRC_H__ */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,156 +0,0 @@
|
||||
/**
|
||||
*********************************************************************************
|
||||
*
|
||||
* @file ald_dbgc.h
|
||||
* @brief DEBUGCON module driver.
|
||||
*
|
||||
* @version V1.0
|
||||
* @date 04 Jun 2017
|
||||
* @author AE Team
|
||||
* @note
|
||||
*
|
||||
* Copyright (C) Shanghai Eastsoft Microelectronics Co. Ltd. All rights reserved.
|
||||
*
|
||||
*********************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __ALD_DBGC_H__
|
||||
#define __ALD_DBGC_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
|
||||
/** @addtogroup ES32FXXX_ALD
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup DBGC DBGC
|
||||
* @brief DBGC module driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/** @defgroup DBGC_Public_Types DBGC Public Types
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @brief Debug mode select
|
||||
*/
|
||||
typedef enum {
|
||||
DEBC_MODE_SLEEP = (1u << 0), /**< Sleep mode */
|
||||
DEBC_MODE_STOP1 = (1u << 1), /**< STOP1 mode */
|
||||
DEBC_MODE_STOP2 = (1u << 2), /**< STOP2 mode */
|
||||
DEBC_MODE_STANDBY = (1u << 3), /**< Standby mode */
|
||||
} dbgc_mode_t;
|
||||
|
||||
/**
|
||||
* @brief Debug peripheral select
|
||||
*/
|
||||
typedef enum {
|
||||
DEBC_PERH_TIMER0 = (1u << 0), /**< AD16C4T0 */
|
||||
DEBC_PERH_TIMER1 = (1u << 1), /**< BS16T0 */
|
||||
DEBC_PERH_TIMER2 = (1u << 2), /**< GP16C2T0 */
|
||||
DEBC_PERH_TIMER3 = (1u << 3), /**< GP16C2T1 */
|
||||
DEBC_PERH_TIMER4 = (1u << 4), /**< BS16T1 */
|
||||
DEBC_PERH_TIMER5 = (1u << 5), /**< BS16T2 */
|
||||
DEBC_PERH_TIMER6 = (1u << 6), /**< GP16C4T0 */
|
||||
DEBC_PERH_TIMER7 = (1u << 7), /**< BS16T3 */
|
||||
DEBC_PERH_I2C0 = (1u << 8), /**< I2C0 SMBUS */
|
||||
DEBC_PERH_I2C1 = (1u << 9), /**< I2C1 SMBUS */
|
||||
DEBC_PERH_CAN = (1u << 12), /**< CAN */
|
||||
DEBC_PERH_LPTIM0 = (1u << 0) | (1u << 16), /**< LPTIM0 */
|
||||
DEBC_PERH_IWDT = (1u << 8) | (1u << 16), /**< IWDT */
|
||||
DEBC_PERH_WWDT = (1u << 9) | (1u << 16), /**< WWDT */
|
||||
DEBC_PERH_RTC = (1u << 10) | (1u << 16), /**< RTC */
|
||||
} dbgc_perh_t;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup DBGC_Public_Functions DBGC Public Functions
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @brief Gets version.
|
||||
* @retval Version
|
||||
*/
|
||||
__INLINE uint32_t dbgc_get_rev_id(void)
|
||||
{
|
||||
return (DBGC->IDCODE >> 16);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets core id.
|
||||
* @retval Core id
|
||||
*/
|
||||
__INLINE uint32_t dbgc_get_core_id(void)
|
||||
{
|
||||
return (DBGC->IDCODE >> 12) & 0xF;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets device id
|
||||
* @retval device id
|
||||
*/
|
||||
__INLINE uint32_t dbgc_get_device_id(void)
|
||||
{
|
||||
return DBGC->IDCODE & 0xFFF;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configures low power debug mode
|
||||
* @param mode: The mode of low power.
|
||||
* @param state: ENABLE/DISABLE
|
||||
* @retval None
|
||||
*/
|
||||
__INLINE void dbgc_mode_config(dbgc_mode_t mode, type_func_t state)
|
||||
{
|
||||
if (state)
|
||||
SET_BIT(DBGC->CR, mode);
|
||||
else
|
||||
CLEAR_BIT(DBGC->CR, mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configures peripheral debug mode
|
||||
* @param perh: The peripheral.
|
||||
* @param state: ENABLE/DISABLE
|
||||
* @retval None
|
||||
*/
|
||||
__INLINE void dbgc_perh_config(dbgc_perh_t perh, type_func_t state)
|
||||
{
|
||||
if ((perh >> 16) & 0x1) {
|
||||
if (state)
|
||||
SET_BIT(DBGC->APB2FZ, perh);
|
||||
else
|
||||
CLEAR_BIT(DBGC->APB2FZ, perh);
|
||||
}
|
||||
else {
|
||||
if (state)
|
||||
SET_BIT(DBGC->APB1FZ, perh);
|
||||
else
|
||||
CLEAR_BIT(DBGC->APB1FZ, perh);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,199 +0,0 @@
|
||||
/**
|
||||
*********************************************************************************
|
||||
*
|
||||
* @file ald_temp.h
|
||||
* @brief Header file of TEMP module driver.
|
||||
*
|
||||
* @version V1.0
|
||||
* @date 15 Dec 2017
|
||||
* @author AE Team
|
||||
* @note
|
||||
*
|
||||
* Copyright (C) Shanghai Eastsoft Microelectronics Co. Ltd. All rights reserved.
|
||||
*
|
||||
********************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __ALD_TEMP_H__
|
||||
#define __ALD_TEMP_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
|
||||
/** @addtogroup ES32FXXX_ALD
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup TEMP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup TEMP_Public_Macros TEMP Public Macros
|
||||
* @{
|
||||
*/
|
||||
#define TEMP_LOCK() (WRITE_REG(TEMP->WPR, 0x0))
|
||||
#define TEMP_UNLOCK() (WRITE_REG(TEMP->WPR, 0xA55A9669))
|
||||
#define TEMP_ENABLE() \
|
||||
do { \
|
||||
TEMP_UNLOCK(); \
|
||||
SET_BIT(TEMP->CR, TEMP_CR_EN_MSK); \
|
||||
TEMP_LOCK(); \
|
||||
} while (0)
|
||||
#define TEMP_DISABLE() \
|
||||
do { \
|
||||
TEMP_UNLOCK(); \
|
||||
CLEAR_BIT(TEMP->CR, TEMP_CR_EN_MSK); \
|
||||
TEMP_LOCK(); \
|
||||
} while (0)
|
||||
#define TEMP_REQ_ENABLE() \
|
||||
do { \
|
||||
TEMP_UNLOCK(); \
|
||||
SET_BIT(TEMP->CR, TEMP_CR_REQEN_MSK); \
|
||||
TEMP_LOCK(); \
|
||||
} while (0)
|
||||
#define TEMP_REQ_DISABLE() \
|
||||
do { \
|
||||
TEMP_UNLOCK(); \
|
||||
CLEAR_BIT(TEMP->CR, TEMP_CR_REQEN_MSK); \
|
||||
TEMP_LOCK(); \
|
||||
} while (0)
|
||||
#define TEMP_CTN_ENABLE() \
|
||||
do { \
|
||||
TEMP_UNLOCK(); \
|
||||
SET_BIT(TEMP->CR, TEMP_CR_CTN_MSK); \
|
||||
TEMP_LOCK(); \
|
||||
} while (0)
|
||||
#define TEMP_CTN_DISABLE() \
|
||||
do { \
|
||||
TEMP_UNLOCK(); \
|
||||
CLEAR_BIT(TEMP->CR, TEMP_CR_CTN_MSK); \
|
||||
TEMP_LOCK(); \
|
||||
} while (0)
|
||||
#define TEMP_RESET() \
|
||||
do { \
|
||||
TEMP_UNLOCK(); \
|
||||
SET_BIT(TEMP->CR, TEMP_CR_RST_MSK); \
|
||||
TEMP_LOCK(); \
|
||||
} while (0)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup TEMP_Public_Types TEMP Public Types
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @brief Temperature update time
|
||||
*/
|
||||
typedef enum {
|
||||
TEMP_UPDATE_CYCLE_3 = 0x3, /**< 3 Cycles */
|
||||
TEMP_UPDATE_CYCLE_4 = 0x4, /**< 4 Cycles */
|
||||
TEMP_UPDATE_CYCLE_5 = 0x5, /**< 5 Cycles */
|
||||
TEMP_UPDATE_CYCLE_6 = 0x6, /**< 6 Cycles */
|
||||
TEMP_UPDATE_CYCLE_7 = 0x7, /**< 7 Cycles */
|
||||
} temp_update_cycle_t;
|
||||
|
||||
/**
|
||||
* @brief Temperature output mode
|
||||
*/
|
||||
typedef enum {
|
||||
TEMP_OUTPUT_MODE_200 = 0x0, /**< 200 cycles update one temperature */
|
||||
TEMP_OUTPUT_MODE_400 = 0x1, /**< 400 cycles update one temperature */
|
||||
TEMP_OUTPUT_MODE_800 = 0x2, /**< 800 cycles update one temperature */
|
||||
TEMP_OUTPUT_MODE_1600 = 0x3, /**< 1600 cycles update one temperature */
|
||||
TEMP_OUTPUT_MODE_3200 = 0x4, /**< 3200 cycles update one temperature */
|
||||
} temp_output_mode_t;
|
||||
|
||||
/**
|
||||
* @brief Source select
|
||||
*/
|
||||
typedef enum {
|
||||
TEMP_SOURCE_LOSC = 0x0, /**< LOSC */
|
||||
TEMP_SOURCE_LRC = 0x1, /**< LRC */
|
||||
TEMP_SOURCE_HRC_DIV_1M = 0x2, /**< HRC divide to 1MHz */
|
||||
TEMP_SOURCE_HOSC_DIV_1M = 0x3, /**< HOSC divide to 1MHz */
|
||||
} temp_source_sel_t;
|
||||
|
||||
|
||||
/**
|
||||
* @brief TEMP init structure definition
|
||||
*/
|
||||
typedef struct {
|
||||
temp_update_cycle_t cycle; /**< Temperature update time */
|
||||
temp_output_mode_t mode; /**< Temperature output mode */
|
||||
uint8_t ctn; /**< Continue mode */
|
||||
uint8_t psc; /**< Perscaler */
|
||||
} temp_init_t;
|
||||
|
||||
/**
|
||||
* @brief Define callback function type
|
||||
*/
|
||||
typedef void (*temp_cbk)(uint16_t value, ald_status_t status);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup TEMP_Private_Macros TEMP Private Macros
|
||||
* @{
|
||||
*/
|
||||
#define IS_TEMP_UPDATE_CYCLE(x) (((x) == TEMP_UPDATE_CYCLE_3) || \
|
||||
((x) == TEMP_UPDATE_CYCLE_4) || \
|
||||
((x) == TEMP_UPDATE_CYCLE_5) || \
|
||||
((x) == TEMP_UPDATE_CYCLE_6) || \
|
||||
((x) == TEMP_UPDATE_CYCLE_7))
|
||||
#define IS_TEMP_OUTPUT_MODE(x) (((x) == TEMP_OUTPUT_MODE_200) || \
|
||||
((x) == TEMP_OUTPUT_MODE_400) || \
|
||||
((x) == TEMP_OUTPUT_MODE_800) || \
|
||||
((x) == TEMP_OUTPUT_MODE_1600) || \
|
||||
((x) == TEMP_OUTPUT_MODE_3200))
|
||||
#define IS_TEMP_SOURCE_SEL(x) (((x) == TEMP_SOURCE_LOSC) || \
|
||||
((x) == TEMP_SOURCE_LRC) || \
|
||||
((x) == TEMP_SOURCE_HRC_DIV_1M ) || \
|
||||
((x) == TEMP_SOURCE_HOSC_DIV_1M))
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup TEMP_Public_Functions
|
||||
* @{
|
||||
*/
|
||||
/** @addtogroup TEMP_Public_Functions_Group1
|
||||
* @{
|
||||
*/
|
||||
/* Initialization functions */
|
||||
extern void temp_init(temp_init_t *init);
|
||||
extern void temp_source_selcet(temp_source_sel_t sel);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/** @addtogroup TEMP_Public_Functions_Group2
|
||||
* @{
|
||||
*/
|
||||
/* Control functions */
|
||||
extern ald_status_t temp_get_value(uint16_t *temp);
|
||||
extern void temp_get_value_by_it(temp_cbk cbk);
|
||||
void temp_irq_handle(void);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ALD_TEMP_H__ */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,176 +0,0 @@
|
||||
/**
|
||||
*********************************************************************************
|
||||
*
|
||||
* @file ald_trng.h
|
||||
* @brief Header file of TRNG module driver.
|
||||
*
|
||||
* @version V1.0
|
||||
* @date 04 Dec 2017
|
||||
* @author AE Team
|
||||
* @note
|
||||
*
|
||||
* Copyright (C) Shanghai Eastsoft Microelectronics Co. Ltd. All rights reserved.
|
||||
*
|
||||
********************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __ALD_TRNG_H__
|
||||
#define __ALD_TRNG_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
|
||||
/** @addtogroup ES32FXXX_ALD
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup TRNG
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup TRNG_Public_Macros TRNG Public Macros
|
||||
* @{
|
||||
*/
|
||||
#define TRNG_ENABLE() (SET_BIT(TRNG->CR, TRNG_CR_TRNGEN_MSK))
|
||||
#define TRNG_DISABLE() (CLEAR_BIT(TRNG->CR, TRNG_CR_TRNGEN_MSK))
|
||||
#define TRNG_ADJM_ENABLE() (SET_BIT(TRNG->CR, TRNG_CR_ADJM_MSK))
|
||||
#define TRNG_ADJM_DISABLE() (CLEAR_BIT(TRNG->CR, TRNG_CR_ADJM_MSK))
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup TRNG_Public_Types TRNG Public Types
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @brief Data width
|
||||
*/
|
||||
typedef enum {
|
||||
TRNG_DSEL_1B = 0x0, /**< 1-bit */
|
||||
TRNG_DSEL_8B = 0x1, /**< 8-bit */
|
||||
TRNG_DSEL_16B = 0x2, /**< 16-bit */
|
||||
TRNG_DSEL_32B = 0x3, /**< 32-bit */
|
||||
} trng_data_width_t;
|
||||
|
||||
/**
|
||||
* @brief seed type
|
||||
*/
|
||||
typedef enum {
|
||||
TRNG_SEED_TYPE_0 = 0x0, /**< Using 0 as seed */
|
||||
TRNG_SEED_TYPE_1 = 0x1, /**< Using 1 as seed */
|
||||
TRNG_SEED_TYPE_LAST = 0x2, /**< Using last seed */
|
||||
TRNG_SEED_TYPE_SEED = 0x3, /**< Using value of register */
|
||||
} trng_seed_type_t;
|
||||
|
||||
/**
|
||||
* @brief TRNG init structure definition
|
||||
*/
|
||||
typedef struct {
|
||||
trng_data_width_t data_width; /**< The width of data */
|
||||
trng_seed_type_t seed_type; /**< The seed type */
|
||||
uint32_t seed; /**< The value of seed */
|
||||
uint16_t t_start; /**< T(start) = T(hclk) * (t_start + 1), T(start) > 1ms */
|
||||
uint8_t adjc; /**< Adjust parameter */
|
||||
uint8_t posten;
|
||||
} trng_init_t;
|
||||
|
||||
/**
|
||||
* @brief State type
|
||||
*/
|
||||
typedef enum {
|
||||
TRNG_STATUS_START = (1U << 0), /**< Start state */
|
||||
TRNG_STATUS_DAVLD = (1U << 1), /**< Data valid state */
|
||||
TRNG_STATUS_SERR = (1U << 2), /**< Error state */
|
||||
} trng_status_t;
|
||||
|
||||
/**
|
||||
* @brief Interrupt type
|
||||
*/
|
||||
typedef enum {
|
||||
TRNG_IT_START = (1U << 0), /**< Start */
|
||||
TRNG_IT_DAVLD = (1U << 1), /**< Data valid */
|
||||
TRNG_IT_SERR = (1U << 2), /**< Error */
|
||||
} trng_it_t;
|
||||
|
||||
/**
|
||||
* @brief Interrupt flag type
|
||||
*/
|
||||
typedef enum {
|
||||
TRNG_IF_START = (1U << 0), /**< Start */
|
||||
TRNG_IF_DAVLD = (1U << 1), /**< Data valid */
|
||||
TRNG_IF_SERR = (1U << 2), /**< Error */
|
||||
} trng_flag_t;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup TRNG_Private_Macros TRNG Private Macros
|
||||
* @{
|
||||
*/
|
||||
#define IS_TRNG_DATA_WIDTH(x) (((x) == TRNG_DSEL_1B) || \
|
||||
((x) == TRNG_DSEL_8B) || \
|
||||
((x) == TRNG_DSEL_16B) || \
|
||||
((x) == TRNG_DSEL_32B))
|
||||
#define IS_TRNG_SEED_TYPE(x) (((x) == TRNG_SEED_TYPE_0) || \
|
||||
((x) == TRNG_SEED_TYPE_1) || \
|
||||
((x) == TRNG_SEED_TYPE_LAST) || \
|
||||
((x) == TRNG_SEED_TYPE_SEED))
|
||||
#define IS_TRNG_STATUS(x) (((x) == TRNG_STATUS_START) || \
|
||||
((x) == TRNG_STATUS_DAVLD) || \
|
||||
((x) == TRNG_STATUS_SERR))
|
||||
#define IS_TRNG_IT(x) (((x) == TRNG_IT_START) || \
|
||||
((x) == TRNG_IT_DAVLD) || \
|
||||
((x) == TRNG_IT_SERR))
|
||||
#define IS_TRNG_FLAG(x) (((x) == TRNG_IF_START) || \
|
||||
((x) == TRNG_IF_DAVLD) || \
|
||||
((x) == TRNG_IF_SERR))
|
||||
#define IS_TRNG_ADJC(x) ((x) < 4)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup TRNG_Public_Functions
|
||||
* @{
|
||||
*/
|
||||
/** @addtogroup TRNG_Public_Functions_Group1
|
||||
* @{
|
||||
*/
|
||||
/* Initialization functions */
|
||||
extern void trng_init(trng_init_t *init);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/** @addtogroup TRNG_Public_Functions_Group2
|
||||
* @{
|
||||
*/
|
||||
/* Control functions */
|
||||
extern uint32_t trng_get_result(void);
|
||||
extern void trng_interrupt_config(trng_it_t it, type_func_t state);
|
||||
extern flag_status_t trng_get_status(trng_status_t status);
|
||||
extern it_status_t trng_get_it_status(trng_it_t it);
|
||||
extern flag_status_t trng_get_flag_status(trng_flag_t flag);
|
||||
extern void trng_clear_flag_status(trng_flag_t flag);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ALD_TRNG_H__ */
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,143 +0,0 @@
|
||||
/**
|
||||
*********************************************************************************
|
||||
*
|
||||
* @file ald_rmu.c
|
||||
* @brief RMU module driver.
|
||||
*
|
||||
* @version V1.0
|
||||
* @date 04 Dec 2017
|
||||
* @author AE Team
|
||||
* @note
|
||||
*
|
||||
* Copyright (C) Shanghai Eastsoft Microelectronics Co. Ltd. All rights reserved.
|
||||
*
|
||||
*********************************************************************************
|
||||
*/
|
||||
|
||||
#include "ald_rmu.h"
|
||||
#include "ald_syscfg.h"
|
||||
|
||||
/** @addtogroup ES32FXXX_ALD
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup RMU RMU
|
||||
* @brief RMU module driver
|
||||
* @{
|
||||
*/
|
||||
#ifdef ALD_RMU
|
||||
|
||||
/** @defgroup RMU_Public_Functions RMU Public Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Configure BOR parameters.
|
||||
* @param flt: filter time.
|
||||
* @param vol: The voltage.
|
||||
* @param state: The new status: ENABLE/DISABLE.
|
||||
* @retval None
|
||||
*/
|
||||
void rmu_bor_config(rmu_bor_filter_t flt, rmu_bor_vol_t vol, type_func_t state)
|
||||
{
|
||||
assert_param(IS_FUNC_STATE(state));
|
||||
|
||||
SYSCFG_UNLOCK();
|
||||
|
||||
if (state) {
|
||||
assert_param(IS_RMU_BORFLT(flt));
|
||||
assert_param(IS_RMU_BORVOL(vol));
|
||||
|
||||
MODIFY_REG(RMU->CR, RMU_CR_BORFLT_MSK, flt << RMU_CR_BORFLT_POSS);
|
||||
MODIFY_REG(RMU->CR, RMU_CR_BORVS_MSK, vol << RMU_CR_BORVS_POSS);
|
||||
SET_BIT(RMU->CR, RMU_CR_BOREN_MSK);
|
||||
}
|
||||
else {
|
||||
CLEAR_BIT(RMU->CR, RMU_CR_BOREN_MSK);
|
||||
}
|
||||
|
||||
SYSCFG_LOCK();
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get specified reset status
|
||||
* @param state: Speicifies the type of the reset,
|
||||
* @retval The status: SET/RESET.
|
||||
*/
|
||||
flag_status_t rmu_get_reset_status(rmu_state_t state)
|
||||
{
|
||||
assert_param(IS_RMU_STATE(state));
|
||||
|
||||
if (READ_BIT(RMU->RSTSR, state))
|
||||
return SET;
|
||||
|
||||
return RESET;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Clear the specified reset status
|
||||
* @param state: Specifies the type of the reset,
|
||||
* @retval None
|
||||
*/
|
||||
void rmu_clear_reset_status(rmu_state_t state)
|
||||
{
|
||||
assert_param(IS_RMU_STATE_CLEAR(state));
|
||||
|
||||
SYSCFG_UNLOCK();
|
||||
WRITE_REG(RMU->CRSTSR, state);
|
||||
SYSCFG_LOCK();
|
||||
|
||||
return;
|
||||
}
|
||||
/**
|
||||
* @brief Reset peripheral device
|
||||
* @param perh: The peripheral device,
|
||||
* @retval None
|
||||
*/
|
||||
void rmu_reset_periperal(rmu_peripheral_t perh)
|
||||
{
|
||||
uint32_t idx, pos;
|
||||
|
||||
assert_param(IS_RMU_PERH(perh));
|
||||
|
||||
idx = (perh >> 27) & 0x7;
|
||||
pos = perh & ~(0x7 << 27);
|
||||
SYSCFG_UNLOCK();
|
||||
|
||||
switch (idx) {
|
||||
case 0:
|
||||
WRITE_REG(RMU->AHB1RSTR, pos);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
WRITE_REG(RMU->AHB2RSTR, pos);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
WRITE_REG(RMU->APB1RSTR, pos);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
WRITE_REG(RMU->APB2RSTR, pos);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
SYSCFG_LOCK();
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
#endif /* ALD_RMU */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -8,7 +8,7 @@ config BSP_DIR
|
||||
config RTT_DIR
|
||||
string
|
||||
option env="RTT_ROOT"
|
||||
default "../.."
|
||||
default "../../.."
|
||||
|
||||
config PKGS_DIR
|
||||
string
|
||||
@@ -17,11 +17,10 @@ config PKGS_DIR
|
||||
|
||||
source "$RTT_DIR/Kconfig"
|
||||
source "$PKGS_DIR/Kconfig"
|
||||
source "drivers/Kconfig"
|
||||
|
||||
config SOC_ES32F0334LT
|
||||
bool
|
||||
select RT_USING_COMPONENTS_INIT
|
||||
select RT_USING_USER_MAIN
|
||||
default y
|
||||
|
||||
source "drivers/Kconfig"
|
||||
@@ -5,7 +5,7 @@ import rtconfig
|
||||
if os.getenv('RTT_ROOT'):
|
||||
RTT_ROOT = os.getenv('RTT_ROOT')
|
||||
else:
|
||||
RTT_ROOT = os.path.normpath(os.getcwd() + '/../..')
|
||||
RTT_ROOT = os.path.normpath(os.getcwd() + '/../../..')
|
||||
|
||||
sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')]
|
||||
try:
|
||||
@@ -42,6 +42,7 @@ if GetDepend(['BSP_USING_RTC']):
|
||||
# add pm driver code
|
||||
if GetDepend(['BSP_USING_PM']):
|
||||
src += ['drv_pm.c']
|
||||
src += ['drv_lptim.c']
|
||||
|
||||
# add adc driver code
|
||||
if GetDepend(['BSP_USING_ADC']):
|
||||
@@ -43,10 +43,10 @@ void NVIC_Configuration(void)
|
||||
void SystemClock_Config(void)
|
||||
{
|
||||
/* hosc 12MHz, from hosc/3 pll to 48MHz */
|
||||
cmu_pll1_config(CMU_PLL1_INPUT_HOSC_3, CMU_PLL1_OUTPUT_48M);
|
||||
ald_cmu_pll1_config(CMU_PLL1_INPUT_HOSC_3, CMU_PLL1_OUTPUT_48M);
|
||||
|
||||
/* MCLK 48MHz */
|
||||
cmu_clock_config(CMU_CLOCK_PLL1, 48000000);
|
||||
ald_cmu_clock_config(CMU_CLOCK_PLL1, 48000000);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -59,14 +59,14 @@ void SystemClock_Config(void)
|
||||
void SysTick_Configuration(void)
|
||||
{
|
||||
/* ticks = sysclk / RT_TICK_PER_SECOND */
|
||||
SysTick_Config(cmu_get_sys_clock() / RT_TICK_PER_SECOND);
|
||||
SysTick_Config(ald_cmu_get_sys_clock() / RT_TICK_PER_SECOND);
|
||||
}
|
||||
|
||||
/**
|
||||
* This is the timer interrupt service routine.
|
||||
*
|
||||
*/
|
||||
void systick_irq_cbk(void)
|
||||
void SysTick_Handler(void)
|
||||
{
|
||||
/* enter interrupt */
|
||||
rt_interrupt_enter();
|
||||
@@ -113,7 +113,7 @@ void rt_hw_us_delay(rt_uint32_t us)
|
||||
unsigned int start, now, delta, reload, us_tick;
|
||||
start = SysTick->VAL;
|
||||
reload = SysTick->LOAD;
|
||||
us_tick = cmu_get_sys_clock() / 1000000UL;
|
||||
us_tick = ald_cmu_get_sys_clock() / 1000000UL;
|
||||
do
|
||||
{
|
||||
now = SysTick->VAL;
|
||||
@@ -12,6 +12,7 @@
|
||||
#ifndef __BOARD_H__
|
||||
#define __BOARD_H__
|
||||
|
||||
#include <rtthread.h>
|
||||
#include <es32f033x.h>
|
||||
|
||||
#define ES32F0_SRAM_SIZE 0x8000
|
||||
@@ -6,6 +6,7 @@
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2019-04-08 wangyq the first version
|
||||
* 2019-11-01 wangyq update libraries
|
||||
*/
|
||||
|
||||
#include <rthw.h>
|
||||
@@ -58,67 +59,67 @@ static adc_channel_t es32f0_adc_get_channel(rt_uint32_t channel)
|
||||
{
|
||||
case 0:
|
||||
es32f0_channel = ADC_CHANNEL_0;
|
||||
gpio_init(GPIOC, GPIO_PIN_0, &gpio_initstruct);
|
||||
ald_gpio_init(GPIOC, GPIO_PIN_0, &gpio_initstruct);
|
||||
break;
|
||||
case 1:
|
||||
es32f0_channel = ADC_CHANNEL_1;
|
||||
gpio_init(GPIOC, GPIO_PIN_1, &gpio_initstruct);
|
||||
ald_gpio_init(GPIOC, GPIO_PIN_1, &gpio_initstruct);
|
||||
break;
|
||||
case 2:
|
||||
es32f0_channel = ADC_CHANNEL_2;
|
||||
gpio_init(GPIOC, GPIO_PIN_2, &gpio_initstruct);
|
||||
ald_gpio_init(GPIOC, GPIO_PIN_2, &gpio_initstruct);
|
||||
break;
|
||||
case 3:
|
||||
es32f0_channel = ADC_CHANNEL_3;
|
||||
gpio_init(GPIOC, GPIO_PIN_3, &gpio_initstruct);
|
||||
ald_gpio_init(GPIOC, GPIO_PIN_3, &gpio_initstruct);
|
||||
break;
|
||||
case 4:
|
||||
es32f0_channel = ADC_CHANNEL_4;
|
||||
gpio_init(GPIOA, GPIO_PIN_0, &gpio_initstruct);
|
||||
ald_gpio_init(GPIOA, GPIO_PIN_0, &gpio_initstruct);
|
||||
break;
|
||||
case 5:
|
||||
es32f0_channel = ADC_CHANNEL_5;
|
||||
gpio_init(GPIOA, GPIO_PIN_1, &gpio_initstruct);
|
||||
ald_gpio_init(GPIOA, GPIO_PIN_1, &gpio_initstruct);
|
||||
break;
|
||||
case 6:
|
||||
es32f0_channel = ADC_CHANNEL_6;
|
||||
gpio_init(GPIOA, GPIO_PIN_2, &gpio_initstruct);
|
||||
ald_gpio_init(GPIOA, GPIO_PIN_2, &gpio_initstruct);
|
||||
break;
|
||||
case 7:
|
||||
es32f0_channel = ADC_CHANNEL_7;
|
||||
gpio_init(GPIOA, GPIO_PIN_3, &gpio_initstruct);
|
||||
ald_gpio_init(GPIOA, GPIO_PIN_3, &gpio_initstruct);
|
||||
break;
|
||||
case 8:
|
||||
es32f0_channel = ADC_CHANNEL_8;
|
||||
gpio_init(GPIOA, GPIO_PIN_4, &gpio_initstruct);
|
||||
ald_gpio_init(GPIOA, GPIO_PIN_4, &gpio_initstruct);
|
||||
break;
|
||||
case 9:
|
||||
es32f0_channel = ADC_CHANNEL_9;
|
||||
gpio_init(GPIOA, GPIO_PIN_5, &gpio_initstruct);
|
||||
ald_gpio_init(GPIOA, GPIO_PIN_5, &gpio_initstruct);
|
||||
break;
|
||||
case 10:
|
||||
es32f0_channel = ADC_CHANNEL_10;
|
||||
gpio_init(GPIOA, GPIO_PIN_6, &gpio_initstruct);
|
||||
ald_gpio_init(GPIOA, GPIO_PIN_6, &gpio_initstruct);
|
||||
break;
|
||||
case 11:
|
||||
es32f0_channel = ADC_CHANNEL_11;
|
||||
gpio_init(GPIOA, GPIO_PIN_7, &gpio_initstruct);
|
||||
ald_gpio_init(GPIOA, GPIO_PIN_7, &gpio_initstruct);
|
||||
break;
|
||||
case 12:
|
||||
es32f0_channel = ADC_CHANNEL_12;
|
||||
gpio_init(GPIOC, GPIO_PIN_4, &gpio_initstruct);
|
||||
ald_gpio_init(GPIOC, GPIO_PIN_4, &gpio_initstruct);
|
||||
break;
|
||||
case 13:
|
||||
es32f0_channel = ADC_CHANNEL_13;
|
||||
gpio_init(GPIOC, GPIO_PIN_5, &gpio_initstruct);
|
||||
ald_gpio_init(GPIOC, GPIO_PIN_5, &gpio_initstruct);
|
||||
break;
|
||||
case 14:
|
||||
es32f0_channel = ADC_CHANNEL_14;
|
||||
gpio_init(GPIOB, GPIO_PIN_0, &gpio_initstruct);
|
||||
ald_gpio_init(GPIOB, GPIO_PIN_0, &gpio_initstruct);
|
||||
break;
|
||||
case 15:
|
||||
es32f0_channel = ADC_CHANNEL_15;
|
||||
gpio_init(GPIOB, GPIO_PIN_1, &gpio_initstruct);
|
||||
ald_gpio_init(GPIOB, GPIO_PIN_1, &gpio_initstruct);
|
||||
break;
|
||||
case 16:
|
||||
es32f0_channel = ADC_CHANNEL_16;
|
||||
@@ -139,21 +140,21 @@ static adc_channel_t es32f0_adc_get_channel(rt_uint32_t channel)
|
||||
static rt_err_t es32f0_get_adc_value(struct rt_adc_device *device, rt_uint32_t channel, rt_uint32_t *value)
|
||||
{
|
||||
adc_handle_t *_hadc = (adc_handle_t *)device->parent.user_data;
|
||||
adc_channel_conf_t nm_config;
|
||||
adc_nch_conf_t nm_config;
|
||||
|
||||
RT_ASSERT(device != RT_NULL);
|
||||
RT_ASSERT(value != RT_NULL);
|
||||
|
||||
/* config adc channel */
|
||||
nm_config.channel = es32f0_adc_get_channel(channel);
|
||||
nm_config.rank = ADC_NC_RANK_1;
|
||||
nm_config.sampling_time = ADC_SAMPLETIME_4;
|
||||
adc_normal_channel_config(_hadc, &nm_config);
|
||||
nm_config.rank = ADC_NCH_RANK_1;
|
||||
nm_config.samp_time = ADC_SAMPLETIME_4;
|
||||
ald_adc_normal_channel_config(_hadc, &nm_config);
|
||||
|
||||
adc_normal_start(_hadc);
|
||||
ald_adc_normal_start(_hadc);
|
||||
|
||||
if (adc_normal_poll_for_conversion(_hadc, 5000) == OK)
|
||||
*value = adc_normal_get_value(_hadc);
|
||||
if (ald_adc_normal_poll_for_conversion(_hadc, 5000) == OK)
|
||||
*value = ald_adc_normal_get_value(_hadc);
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
@@ -172,17 +173,16 @@ int rt_hw_adc_init(void)
|
||||
/* adc function initialization */
|
||||
_h_adc0.perh = ADC0;
|
||||
_h_adc0.init.data_align = ADC_DATAALIGN_RIGHT;
|
||||
_h_adc0.init.scan_mode = ADC_SCAN_DISABLE;
|
||||
_h_adc0.init.scan_mode = DISABLE;
|
||||
_h_adc0.init.cont_mode = DISABLE;
|
||||
_h_adc0.init.conv_nbr = ADC_NM_NBR_1;
|
||||
_h_adc0.init.disc_mode = DISABLE;
|
||||
_h_adc0.init.disc_mode = ADC_ALL_DISABLE;
|
||||
_h_adc0.init.disc_nbr = ADC_DISC_NBR_1;
|
||||
_h_adc0.init.conv_res = ADC_CONV_RES_10;
|
||||
_h_adc0.init.clk_div = ADC_CKDIV_128;
|
||||
_h_adc0.init.nche_mode = ADC_NCHESEL_MODE_ALL;
|
||||
_h_adc0.init.nche_sel = ADC_NCHESEL_MODE_ALL;
|
||||
_h_adc0.init.neg_ref = ADC_NEG_REF_VSS;
|
||||
_h_adc0.init.pos_ref = ADC_POS_REF_VDD;
|
||||
adc_init(&_h_adc0);
|
||||
ald_adc_init(&_h_adc0);
|
||||
|
||||
rt_hw_adc_register(&_device_adc0, "adc0", &es32f0_adc_ops, &_h_adc0);
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2019-03-01 wangyq the first version
|
||||
* 2019-11-01 wangyq update libraries
|
||||
*/
|
||||
|
||||
#include <rthw.h>
|
||||
@@ -167,7 +168,7 @@ void es32f0_pin_write(rt_device_t dev, rt_base_t pin, rt_base_t value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
gpio_write_pin(index->gpio, index->pin, value);
|
||||
ald_gpio_write_pin(index->gpio, index->pin, value);
|
||||
}
|
||||
|
||||
int es32f0_pin_read(rt_device_t dev, rt_base_t pin)
|
||||
@@ -180,7 +181,7 @@ int es32f0_pin_read(rt_device_t dev, rt_base_t pin)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
value = gpio_read_pin(index->gpio, index->pin);
|
||||
value = ald_gpio_read_pin(index->gpio, index->pin);
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -233,7 +234,7 @@ void es32f0_pin_mode(rt_device_t dev, rt_base_t pin, rt_base_t mode)
|
||||
gpio_initstruct.pupd = GPIO_FLOATING;
|
||||
gpio_initstruct.odos = GPIO_OPEN_DRAIN;
|
||||
}
|
||||
gpio_init(index->gpio, index->pin, &gpio_initstruct);
|
||||
ald_gpio_init(index->gpio, index->pin, &gpio_initstruct);
|
||||
}
|
||||
|
||||
rt_inline const struct pin_irq_map *get_pin_irq_map(rt_uint16_t gpio_pin)
|
||||
@@ -360,7 +361,7 @@ rt_err_t es32f0_pin_irq_enable(struct rt_device *device, rt_base_t pin,
|
||||
return RT_ENOSYS;
|
||||
}
|
||||
irqmap = &pin_irq_map[irqindex];
|
||||
gpio_exti_init(index->gpio, index->pin, &exti_initstruct);
|
||||
ald_gpio_exti_init(index->gpio, index->pin, &exti_initstruct);
|
||||
/* Configure GPIO_InitStructure */
|
||||
gpio_initstruct.mode = GPIO_MODE_INPUT;
|
||||
gpio_initstruct.func = GPIO_FUNC_1;
|
||||
@@ -368,18 +369,18 @@ rt_err_t es32f0_pin_irq_enable(struct rt_device *device, rt_base_t pin,
|
||||
{
|
||||
case PIN_IRQ_MODE_RISING:
|
||||
gpio_initstruct.pupd = GPIO_PUSH_DOWN;
|
||||
gpio_exti_interrupt_config(index->pin, EXTI_TRIGGER_RISING_EDGE, ENABLE);
|
||||
ald_gpio_exti_interrupt_config(index->pin, EXTI_TRIGGER_RISING_EDGE, ENABLE);
|
||||
break;
|
||||
case PIN_IRQ_MODE_FALLING:
|
||||
gpio_initstruct.pupd = GPIO_PUSH_UP;
|
||||
gpio_exti_interrupt_config(index->pin, EXTI_TRIGGER_TRAILING_EDGE, ENABLE);
|
||||
ald_gpio_exti_interrupt_config(index->pin, EXTI_TRIGGER_TRAILING_EDGE, ENABLE);
|
||||
break;
|
||||
case PIN_IRQ_MODE_RISING_FALLING:
|
||||
gpio_initstruct.pupd = GPIO_FLOATING;
|
||||
gpio_exti_interrupt_config(index->pin, EXTI_TRIGGER_BOTH_EDGE, ENABLE);
|
||||
ald_gpio_exti_interrupt_config(index->pin, EXTI_TRIGGER_BOTH_EDGE, ENABLE);
|
||||
break;
|
||||
}
|
||||
gpio_init(index->gpio, index->pin, &gpio_initstruct);
|
||||
ald_gpio_init(index->gpio, index->pin, &gpio_initstruct);
|
||||
NVIC_EnableIRQ(irqmap->irqno);
|
||||
rt_hw_interrupt_enable(level);
|
||||
}
|
||||
@@ -412,7 +413,7 @@ const static struct rt_pin_ops _es32f0_pin_ops =
|
||||
int rt_hw_pin_init(void)
|
||||
{
|
||||
int result;
|
||||
cmu_perh_clock_config(CMU_PERH_GPIO, ENABLE);
|
||||
ald_cmu_perh_clock_config(CMU_PERH_GPIO, ENABLE);
|
||||
result = rt_device_pin_register("pin", &_es32f0_pin_ops, RT_NULL);
|
||||
return result;
|
||||
}
|
||||
@@ -439,9 +440,9 @@ rt_inline void pin_irq_hdr(uint16_t GPIO_Pin)
|
||||
|
||||
void GPIO_EXTI_Callback(uint16_t GPIO_Pin)
|
||||
{
|
||||
if (gpio_exti_get_flag_status(GPIO_Pin) != RESET)
|
||||
if (ald_gpio_exti_get_flag_status(GPIO_Pin) != RESET)
|
||||
{
|
||||
gpio_exti_clear_flag_status(GPIO_Pin);
|
||||
ald_gpio_exti_clear_flag_status(GPIO_Pin);
|
||||
pin_irq_hdr(GPIO_Pin);
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2019-3-19 wangyq the first version
|
||||
* 2019-11-01 wangyq update libraries
|
||||
*/
|
||||
|
||||
#include <rthw.h>
|
||||
@@ -30,12 +31,12 @@ static struct es32f0_hwtimer_dev hwtimer0;
|
||||
|
||||
void BS16T0_Handler(void)
|
||||
{
|
||||
timer_clear_flag_status(hwtimer0.hwtimer_periph, TIMER_FLAG_UPDATE);
|
||||
ald_timer_clear_flag_status(hwtimer0.hwtimer_periph, TIMER_FLAG_UPDATE);
|
||||
rt_device_hwtimer_isr(&hwtimer0.parent);
|
||||
|
||||
if (HWTIMER_MODE_ONESHOT == hwtimer0.parent.mode)
|
||||
{
|
||||
timer_base_stop(hwtimer0.hwtimer_periph);
|
||||
ald_timer_base_stop(hwtimer0.hwtimer_periph);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -45,15 +46,15 @@ static struct es32f0_hwtimer_dev hwtimer1;
|
||||
|
||||
void BS16T1_UART2_Handler(void)
|
||||
{
|
||||
if (timer_get_it_status(hwtimer1.hwtimer_periph, TIMER_IT_UPDATE) &&
|
||||
timer_get_flag_status(hwtimer1.hwtimer_periph, TIMER_FLAG_UPDATE))
|
||||
if (ald_timer_get_it_status(hwtimer1.hwtimer_periph, TIMER_IT_UPDATE) &&
|
||||
ald_timer_get_flag_status(hwtimer1.hwtimer_periph, TIMER_FLAG_UPDATE))
|
||||
{
|
||||
timer_clear_flag_status(hwtimer1.hwtimer_periph, TIMER_FLAG_UPDATE);
|
||||
ald_timer_clear_flag_status(hwtimer1.hwtimer_periph, TIMER_FLAG_UPDATE);
|
||||
rt_device_hwtimer_isr(&hwtimer1.parent);
|
||||
|
||||
if (HWTIMER_MODE_ONESHOT == hwtimer1.parent.mode)
|
||||
{
|
||||
timer_base_stop(hwtimer1.hwtimer_periph);
|
||||
ald_timer_base_stop(hwtimer1.hwtimer_periph);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -64,15 +65,15 @@ static struct es32f0_hwtimer_dev hwtimer2;
|
||||
|
||||
void BS16T2_UART3_Handler(void)
|
||||
{
|
||||
if (timer_get_it_status(hwtimer2.hwtimer_periph, TIMER_IT_UPDATE) &&
|
||||
timer_get_flag_status(hwtimer2.hwtimer_periph, TIMER_FLAG_UPDATE))
|
||||
if (ald_timer_get_it_status(hwtimer2.hwtimer_periph, TIMER_IT_UPDATE) &&
|
||||
ald_timer_get_flag_status(hwtimer2.hwtimer_periph, TIMER_FLAG_UPDATE))
|
||||
{
|
||||
timer_clear_flag_status(hwtimer2.hwtimer_periph, TIMER_FLAG_UPDATE);
|
||||
ald_timer_clear_flag_status(hwtimer2.hwtimer_periph, TIMER_FLAG_UPDATE);
|
||||
rt_device_hwtimer_isr(&hwtimer2.parent);
|
||||
|
||||
if (HWTIMER_MODE_ONESHOT == hwtimer2.parent.mode)
|
||||
{
|
||||
timer_base_stop(hwtimer2.hwtimer_periph);
|
||||
ald_timer_base_stop(hwtimer2.hwtimer_periph);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -84,15 +85,15 @@ static struct es32f0_hwtimer_dev hwtimer3;
|
||||
void BS16T3_DAC0_Handler(void)
|
||||
{
|
||||
/* if BS16T3 it */
|
||||
if (timer_get_it_status(hwtimer3.hwtimer_periph, TIMER_IT_UPDATE) &&
|
||||
timer_get_flag_status(hwtimer3.hwtimer_periph, TIMER_FLAG_UPDATE))
|
||||
if (ald_timer_get_it_status(hwtimer3.hwtimer_periph, TIMER_IT_UPDATE) &&
|
||||
ald_timer_get_flag_status(hwtimer3.hwtimer_periph, TIMER_FLAG_UPDATE))
|
||||
{
|
||||
timer_clear_flag_status(hwtimer3.hwtimer_periph, TIMER_FLAG_UPDATE);
|
||||
ald_timer_clear_flag_status(hwtimer3.hwtimer_periph, TIMER_FLAG_UPDATE);
|
||||
rt_device_hwtimer_isr(&hwtimer3.parent);
|
||||
|
||||
if (HWTIMER_MODE_ONESHOT == hwtimer3.parent.mode)
|
||||
{
|
||||
timer_base_stop(hwtimer3.hwtimer_periph);
|
||||
ald_timer_base_stop(hwtimer3.hwtimer_periph);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -114,13 +115,13 @@ static void es32f0_hwtimer_init(rt_hwtimer_t *timer, rt_uint32_t state)
|
||||
|
||||
if (1 == state)
|
||||
{
|
||||
timer_base_init(hwtimer->hwtimer_periph);
|
||||
timer_interrupt_config(hwtimer->hwtimer_periph, TIMER_IT_UPDATE, ENABLE);
|
||||
ald_timer_base_init(hwtimer->hwtimer_periph);
|
||||
ald_timer_interrupt_config(hwtimer->hwtimer_periph, TIMER_IT_UPDATE, ENABLE);
|
||||
NVIC_EnableIRQ(hwtimer->IRQn);
|
||||
}
|
||||
hwtimer->parent.freq = cmu_get_pclk1_clock();
|
||||
es32f0_hwtimer_info.maxfreq = cmu_get_pclk1_clock();
|
||||
es32f0_hwtimer_info.minfreq = cmu_get_pclk1_clock();
|
||||
hwtimer->parent.freq = ald_cmu_get_pclk1_clock();
|
||||
es32f0_hwtimer_info.maxfreq = ald_cmu_get_pclk1_clock();
|
||||
es32f0_hwtimer_info.minfreq = ald_cmu_get_pclk1_clock();
|
||||
}
|
||||
|
||||
static rt_err_t es32f0_hwtimer_start(rt_hwtimer_t *timer,
|
||||
@@ -132,7 +133,7 @@ static rt_err_t es32f0_hwtimer_start(rt_hwtimer_t *timer,
|
||||
RT_ASSERT(hwtimer != RT_NULL);
|
||||
|
||||
WRITE_REG(hwtimer->hwtimer_periph->perh->AR, cnt);
|
||||
timer_base_start(hwtimer->hwtimer_periph);
|
||||
ald_timer_base_start(hwtimer->hwtimer_periph);
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
@@ -143,7 +144,7 @@ static void es32f0_hwtimer_stop(rt_hwtimer_t *timer)
|
||||
|
||||
RT_ASSERT(hwtimer != RT_NULL);
|
||||
|
||||
timer_base_stop(hwtimer->hwtimer_periph);
|
||||
ald_timer_base_stop(hwtimer->hwtimer_periph);
|
||||
}
|
||||
|
||||
static rt_uint32_t es32f0_hwtimer_count_get(rt_hwtimer_t *timer)
|
||||
@@ -172,14 +173,14 @@ static rt_err_t es32f0_hwtimer_control(rt_hwtimer_t *timer,
|
||||
{
|
||||
case HWTIMER_CTRL_FREQ_SET:
|
||||
freq = *(rt_uint32_t *)args;
|
||||
if (freq != cmu_get_pclk1_clock())
|
||||
if (freq != ald_cmu_get_pclk1_clock())
|
||||
{
|
||||
ret = -RT_ERROR;
|
||||
}
|
||||
break;
|
||||
|
||||
case HWTIMER_CTRL_STOP:
|
||||
timer_base_stop(hwtimer->hwtimer_periph);
|
||||
ald_timer_base_stop(hwtimer->hwtimer_periph);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -6,6 +6,7 @@
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2019-03-19 wangyq the first version
|
||||
* 2019-11-01 wangyq update libraries
|
||||
*/
|
||||
|
||||
#include <rthw.h>
|
||||
@@ -45,10 +46,10 @@ static void _i2c_init(void)
|
||||
_h_i2c0.init.general_call = I2C_GENERALCALL_DISABLE;
|
||||
_h_i2c0.init.no_stretch = I2C_NOSTRETCH_ENABLE;
|
||||
|
||||
i2c_reset(&_h_i2c0);
|
||||
i2c_init(&_h_i2c0);
|
||||
ald_i2c_reset(&_h_i2c0);
|
||||
ald_i2c_init(&_h_i2c0);
|
||||
/* I2C0_SCL->PB8, I2C0_SDA->PB9 */
|
||||
gpio_init(GPIOB, GPIO_PIN_8 | GPIO_PIN_9, &gpio_instruct);
|
||||
ald_gpio_init(GPIOB, GPIO_PIN_8 | GPIO_PIN_9, &gpio_instruct);
|
||||
#endif
|
||||
|
||||
#ifdef BSP_USING_I2C1
|
||||
@@ -61,10 +62,10 @@ static void _i2c_init(void)
|
||||
_h_i2c1.init.general_call = I2C_GENERALCALL_DISABLE;
|
||||
_h_i2c1.init.no_stretch = I2C_NOSTRETCH_ENABLE;
|
||||
|
||||
i2c_reset(&_h_i2c1);
|
||||
i2c_init(&_h_i2c1);
|
||||
ald_i2c_reset(&_h_i2c1);
|
||||
ald_i2c_init(&_h_i2c1);
|
||||
/* I2C1_SCL->PB10, I2C1_SDA->PB11 */
|
||||
gpio_init(GPIOB, GPIO_PIN_10 | GPIO_PIN_11, &gpio_instruct);
|
||||
ald_gpio_init(GPIOB, GPIO_PIN_10 | GPIO_PIN_11, &gpio_instruct);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -81,7 +82,7 @@ static rt_size_t es32f0_master_xfer(struct rt_i2c_bus_device *bus,
|
||||
msg = &msgs[i];
|
||||
if (msg->flags & RT_I2C_RD)
|
||||
{
|
||||
if (i2c_master_recv(bus->priv, msg->addr << 1, msg->buf, msg->len, TIMEOUT) != 0)
|
||||
if (ald_i2c_master_recv(bus->priv, msg->addr << 1, msg->buf, msg->len, TIMEOUT) != 0)
|
||||
{
|
||||
i2c_dbg("i2c bus write failed,i2c bus stop!\n");
|
||||
goto out;
|
||||
@@ -89,7 +90,7 @@ static rt_size_t es32f0_master_xfer(struct rt_i2c_bus_device *bus,
|
||||
}
|
||||
else
|
||||
{
|
||||
if (i2c_master_send(bus->priv, msg->addr << 1, msg->buf, msg->len, TIMEOUT) != 0)
|
||||
if (ald_i2c_master_send(bus->priv, msg->addr << 1, msg->buf, msg->len, TIMEOUT) != 0)
|
||||
{
|
||||
i2c_dbg("i2c bus write failed,i2c bus stop!\n");
|
||||
goto out;
|
||||
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
* Copyright (C) 2018 Shanghai Eastsoft Microelectronics Co., Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2019-11-01 wangyq first version
|
||||
*/
|
||||
|
||||
#include <board.h>
|
||||
#include <drv_lptim.h>
|
||||
#include <ald_lptim.h>
|
||||
|
||||
static lptim_handle_t h_lptim;
|
||||
|
||||
void LPTIM0_SPI2_Handler(void)
|
||||
{
|
||||
/* LPTIM Intetrupt */
|
||||
if (ald_lptim_get_it_status(&h_lptim, LPTIM_IT_ARRMAT) &&
|
||||
ald_lptim_get_flag_status(&h_lptim, LPTIM_FLAG_ARRMAT))
|
||||
{
|
||||
/* enter interrupt */
|
||||
rt_interrupt_enter();
|
||||
|
||||
ald_lptim_clear_flag_status(&h_lptim, LPTIM_FLAG_ARRMAT);
|
||||
|
||||
/* leave interrupt */
|
||||
rt_interrupt_leave();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function get current count value of LPTIM
|
||||
*
|
||||
* @return the count vlaue
|
||||
*/
|
||||
rt_uint32_t es32f0_lptim_get_current_tick(void)
|
||||
{
|
||||
return READ_REG(h_lptim.perh->CNT);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function get the max value that LPTIM can count
|
||||
*
|
||||
* @return the max count
|
||||
*/
|
||||
rt_uint32_t es32f0_lptim_get_tick_max(void)
|
||||
{
|
||||
return (0xFFFF);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function start LPTIM with reload value
|
||||
*
|
||||
* @param reload The value that LPTIM count down from
|
||||
*
|
||||
* @return RT_EOK
|
||||
*/
|
||||
rt_err_t es32f0_lptim_start(rt_uint32_t reload)
|
||||
{
|
||||
h_lptim.init.arr = reload;
|
||||
ald_lptim_toggle_start_by_it(&h_lptim);
|
||||
|
||||
return (RT_EOK);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function stop LPTIM
|
||||
*/
|
||||
void es32f0_lptim_stop(void)
|
||||
{
|
||||
ald_lptim_toggle_stop_by_it(&h_lptim);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function get the count clock of LPTIM
|
||||
*
|
||||
* @return the count clock frequency in Hz
|
||||
*/
|
||||
rt_uint32_t es32f0_lptim_get_countfreq(void)
|
||||
{
|
||||
return 1000000;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function initialize the lptim
|
||||
*/
|
||||
int es32f0_hw_lptim_init(void)
|
||||
{
|
||||
lptim_clock_source_init_t clock_config;
|
||||
lptim_trigger_init_t trigger_config;
|
||||
|
||||
/* Enable LPTIM clock */
|
||||
ald_cmu_perh_clock_config(CMU_PERH_LPTIM0, ENABLE);
|
||||
|
||||
/* LPTIM Configuration */
|
||||
h_lptim.perh = LPTIM0;
|
||||
h_lptim.init.psc = LPTIM_PRESC_1; // can not select other premeter
|
||||
h_lptim.init.arr = 0x0FFF;
|
||||
h_lptim.init.clock = CMU_LP_PERH_CLOCK_SEL_HRC_1M;
|
||||
h_lptim.init.mode = LPTIM_MODE_SINGLE;
|
||||
|
||||
ald_lptim_toggle_init(&h_lptim);
|
||||
|
||||
/* Initialize clock source */
|
||||
clock_config.sel = LPTIM_CKSEL_INTERNAL;
|
||||
clock_config.polarity = LPTIM_CKPOL_RISING;
|
||||
ald_lptim_clock_source_config(&h_lptim, &clock_config);
|
||||
|
||||
/* Initialize toggle */
|
||||
trigger_config.mode = LPTIM_TRIGEN_SW;
|
||||
ald_lptim_trigger_config(&h_lptim, &trigger_config);
|
||||
|
||||
ald_lptim_interrupt_config(&h_lptim, LPTIM_IT_ARRMAT, ENABLE);
|
||||
|
||||
NVIC_ClearPendingIRQ(LPTIM0_SPI2_IRQn);
|
||||
NVIC_SetPriority(LPTIM0_SPI2_IRQn, 0);
|
||||
NVIC_EnableIRQ(LPTIM0_SPI2_IRQn);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
INIT_DEVICE_EXPORT(es32f0_hw_lptim_init);
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright (C) 2018 Shanghai Eastsoft Microelectronics Co., Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2019-11-01 wangyq first version
|
||||
*/
|
||||
|
||||
#ifndef __DRV_PMTIMER_H__
|
||||
#define __DRV_PMTIMER_H__
|
||||
|
||||
#include <rtthread.h>
|
||||
|
||||
rt_uint32_t es32f0_lptim_get_countfreq(void);
|
||||
rt_uint32_t es32f0_lptim_get_tick_max(void);
|
||||
rt_uint32_t es32f0_lptim_get_current_tick(void);
|
||||
|
||||
rt_err_t es32f0_lptim_start(rt_uint32_t load);
|
||||
void es32f0_lptim_stop(void);
|
||||
|
||||
#endif /* __DRV_PMTIMER_H__ */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -6,6 +6,7 @@
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2019-03-19 wangyq the first version
|
||||
* 2019-11-01 wangyq update libraries
|
||||
*/
|
||||
|
||||
#include <rthw.h>
|
||||
@@ -18,7 +19,7 @@
|
||||
|
||||
static void pwm_set_freq(timer_handle_t *timer_initstruct, uint32_t ns)
|
||||
{
|
||||
uint64_t _arr = (uint64_t)cmu_get_pclk1_clock() * ns / 1000000000 /
|
||||
uint64_t _arr = (uint64_t)ald_cmu_get_pclk1_clock() * ns / 1000000000 /
|
||||
(timer_initstruct->init.prescaler + 1);
|
||||
|
||||
WRITE_REG(timer_initstruct->perh->AR, (uint32_t)_arr);
|
||||
@@ -27,7 +28,7 @@ static void pwm_set_freq(timer_handle_t *timer_initstruct, uint32_t ns)
|
||||
|
||||
static void pwm_set_duty(timer_handle_t *timer_initstruct, timer_channel_t ch, uint32_t ns)
|
||||
{
|
||||
uint64_t tmp = (uint64_t)cmu_get_pclk1_clock() * ns / 1000000000 /
|
||||
uint64_t tmp = (uint64_t)ald_cmu_get_pclk1_clock() * ns / 1000000000 /
|
||||
(timer_initstruct->init.prescaler + 1);
|
||||
|
||||
if (ch == TIMER_CHANNEL_1)
|
||||
@@ -88,11 +89,11 @@ static rt_err_t es32f0_pwm_control(struct rt_device_pwm *device, int cmd, void *
|
||||
switch (cmd)
|
||||
{
|
||||
case PWM_CMD_ENABLE:
|
||||
timer_pwm_start(timer_initstruct, pwm_channel);
|
||||
ald_timer_pwm_start(timer_initstruct, pwm_channel);
|
||||
break;
|
||||
|
||||
case PWM_CMD_DISABLE:
|
||||
timer_pwm_stop(timer_initstruct, pwm_channel);
|
||||
ald_timer_pwm_stop(timer_initstruct, pwm_channel);
|
||||
break;
|
||||
|
||||
case PWM_CMD_SET:
|
||||
@@ -106,13 +107,13 @@ static rt_err_t es32f0_pwm_control(struct rt_device_pwm *device, int cmd, void *
|
||||
while (timer_initstruct->init.period > 0xFFFF);
|
||||
/* update prescaler */
|
||||
WRITE_REG(timer_initstruct->perh->PRES, --timer_initstruct->init.prescaler);
|
||||
timer_oc_config_channel(timer_initstruct, &tim_ocinit, pwm_channel);
|
||||
ald_timer_oc_config_channel(timer_initstruct, &tim_ocinit, pwm_channel);
|
||||
pwm_set_duty(timer_initstruct, pwm_channel, cfg->pulse);
|
||||
timer_initstruct->perh->CCEP = _ccep;
|
||||
break;
|
||||
|
||||
case PWM_CMD_GET:
|
||||
cfg->pulse = timer_read_capture_value(timer_initstruct, pwm_channel) * 100 /
|
||||
cfg->pulse = ald_timer_read_capture_value(timer_initstruct, pwm_channel) * 100 /
|
||||
READ_REG(timer_initstruct->perh->AR);
|
||||
break;
|
||||
|
||||
@@ -143,15 +144,15 @@ int rt_hw_pwm_init(void)
|
||||
static struct rt_device_pwm pwm_dev0;
|
||||
static timer_handle_t timer_initstruct0;
|
||||
|
||||
timer_initstruct0.perh = AD16C4T0;
|
||||
timer_pwm_init(&timer_initstruct0);
|
||||
timer_initstruct0.perh = GP16C4T0;
|
||||
ald_timer_pwm_init(&timer_initstruct0);
|
||||
|
||||
/* gpio initialization */
|
||||
gpio_initstructure.func = GPIO_FUNC_2;
|
||||
gpio_init(GPIOA, GPIO_PIN_8, &gpio_initstructure);
|
||||
gpio_init(GPIOA, GPIO_PIN_9, &gpio_initstructure);
|
||||
gpio_init(GPIOA, GPIO_PIN_10, &gpio_initstructure);
|
||||
gpio_init(GPIOA, GPIO_PIN_11, &gpio_initstructure);
|
||||
ald_gpio_init(GPIOA, GPIO_PIN_8, &gpio_initstructure);
|
||||
ald_gpio_init(GPIOA, GPIO_PIN_9, &gpio_initstructure);
|
||||
ald_gpio_init(GPIOA, GPIO_PIN_10, &gpio_initstructure);
|
||||
ald_gpio_init(GPIOA, GPIO_PIN_11, &gpio_initstructure);
|
||||
|
||||
ret = rt_device_pwm_register(&pwm_dev0, "pwm0", &es32f0_pwm_ops,
|
||||
&timer_initstruct0);
|
||||
@@ -161,14 +162,14 @@ int rt_hw_pwm_init(void)
|
||||
static struct rt_device_pwm pwm_dev1;
|
||||
static timer_handle_t timer_initstruct1;
|
||||
|
||||
timer_initstruct1.perh = GP16C4T0;
|
||||
timer_pwm_init(&timer_initstruct1);
|
||||
timer_initstruct1.perh = GP16C4T1;
|
||||
ald_timer_pwm_init(&timer_initstruct1);
|
||||
|
||||
/* gpio initialization */
|
||||
gpio_initstructure.func = GPIO_FUNC_2;
|
||||
gpio_init(GPIOB, GPIO_PIN_6, &gpio_initstructure);
|
||||
gpio_init(GPIOB, GPIO_PIN_7, &gpio_initstructure);
|
||||
gpio_init(GPIOB, GPIO_PIN_8, &gpio_initstructure);
|
||||
ald_gpio_init(GPIOB, GPIO_PIN_6, &gpio_initstructure);
|
||||
ald_gpio_init(GPIOB, GPIO_PIN_7, &gpio_initstructure);
|
||||
ald_gpio_init(GPIOB, GPIO_PIN_8, &gpio_initstructure);
|
||||
|
||||
ret = rt_device_pwm_register(&pwm_dev1, "pwm1", &es32f0_pwm_ops,
|
||||
&timer_initstruct1);
|
||||
@@ -179,12 +180,12 @@ int rt_hw_pwm_init(void)
|
||||
static timer_handle_t timer_initstruct2;
|
||||
|
||||
timer_initstruct2.perh = GP16C2T0;
|
||||
timer_pwm_init(&timer_initstruct2);
|
||||
ald_timer_pwm_init(&timer_initstruct2);
|
||||
|
||||
/* gpio initialization */
|
||||
gpio_initstructure.func = GPIO_FUNC_2;
|
||||
gpio_init(GPIOA, GPIO_PIN_0, &gpio_initstructure);
|
||||
gpio_init(GPIOA, GPIO_PIN_1, &gpio_initstructure);
|
||||
ald_gpio_init(GPIOA, GPIO_PIN_0, &gpio_initstructure);
|
||||
ald_gpio_init(GPIOA, GPIO_PIN_1, &gpio_initstructure);
|
||||
|
||||
ret = rt_device_pwm_register(&pwm_dev2, "pwm2", &es32f0_pwm_ops,
|
||||
&timer_initstruct2);
|
||||
@@ -195,12 +196,12 @@ int rt_hw_pwm_init(void)
|
||||
static timer_handle_t timer_initstruct3;
|
||||
|
||||
timer_initstruct3.perh = GP16C2T1;
|
||||
timer_pwm_init(&timer_initstruct3);
|
||||
ald_timer_pwm_init(&timer_initstruct3);
|
||||
|
||||
/* gpio initialization */
|
||||
gpio_initstructure.func = GPIO_FUNC_3;
|
||||
gpio_init(GPIOC, GPIO_PIN_6, &gpio_initstructure);
|
||||
gpio_init(GPIOC, GPIO_PIN_7, &gpio_initstructure);
|
||||
ald_gpio_init(GPIOC, GPIO_PIN_6, &gpio_initstructure);
|
||||
ald_gpio_init(GPIOC, GPIO_PIN_7, &gpio_initstructure);
|
||||
|
||||
ret = rt_device_pwm_register(&pwm_dev3, "pwm3", &es32f0_pwm_ops,
|
||||
&timer_initstruct3);
|
||||
@@ -6,6 +6,7 @@
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2019-04-01 wangyq the first version
|
||||
* 2019-11-01 wangyq update libraries
|
||||
*/
|
||||
|
||||
#include <rthw.h>
|
||||
@@ -25,7 +26,7 @@ static void __rtc_init(rtc_init_t *init)
|
||||
assert_param(IS_RTC_OUTPUT_SEL(init->output));
|
||||
assert_param(IS_RTC_OUTPUT_POLARITY(init->output_polarity));
|
||||
|
||||
rtc_reset();
|
||||
ald_rtc_reset();
|
||||
RTC_UNLOCK();
|
||||
|
||||
MODIFY_REG(RTC->CON, RTC_CON_HFM_MSK, init->hour_format << RTC_CON_HFM_POS);
|
||||
@@ -51,7 +52,7 @@ static rt_err_t es32f0_rtc_control(rt_device_t dev, int cmd, void *args)
|
||||
{
|
||||
case RT_DEVICE_CTRL_RTC_GET_TIME:
|
||||
|
||||
rtc_get_date_time(&date, &time, RTC_FORMAT_DEC);
|
||||
ald_rtc_get_date_time(&date, &time, RTC_FORMAT_DEC);
|
||||
time_temp.tm_sec = time.second;
|
||||
time_temp.tm_min = time.minute;
|
||||
time_temp.tm_hour = time.hour;
|
||||
@@ -77,8 +78,8 @@ static rt_err_t es32f0_rtc_control(rt_device_t dev, int cmd, void *args)
|
||||
date.year = time_temp.tm_year + 1900 - 2000;
|
||||
date.month = time_temp.tm_mon + 1;
|
||||
date.day = time_temp.tm_mday;
|
||||
rtc_set_time(&time, RTC_FORMAT_DEC);
|
||||
rtc_set_date(&date, RTC_FORMAT_DEC);
|
||||
ald_rtc_set_time(&time, RTC_FORMAT_DEC);
|
||||
ald_rtc_set_date(&date, RTC_FORMAT_DEC);
|
||||
/* start RTC */
|
||||
RTC_UNLOCK();
|
||||
SET_BIT(RTC->CON, RTC_CON_GO_MSK);
|
||||
@@ -118,7 +119,7 @@ int rt_hw_rtc_init(void)
|
||||
|
||||
/* enable external 32.768kHz */
|
||||
CMU_LOSC_ENABLE();
|
||||
cmu_losc_safe_config(ENABLE);
|
||||
ald_cmu_losc_safe_config(ENABLE);
|
||||
/* set default time */
|
||||
RTC_UNLOCK();
|
||||
WRITE_REG(RTC->TIME, 0x134251);
|
||||
@@ -6,6 +6,7 @@
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2019-03-19 wangyq the first version
|
||||
* 2019-11-01 wangyq update libraries
|
||||
*/
|
||||
|
||||
#include <rtthread.h>
|
||||
@@ -80,14 +81,14 @@ rt_err_t spi_configure(struct rt_spi_device *device,
|
||||
}
|
||||
|
||||
/* config spi clock */
|
||||
if (cfg->max_hz >= cmu_get_pclk1_clock() / 2)
|
||||
if (cfg->max_hz >= ald_cmu_get_pclk1_clock() / 2)
|
||||
{
|
||||
/* pclk1 max speed 48MHz, spi master max speed 10MHz */
|
||||
if (cmu_get_pclk1_clock() / 2 <= 10000000)
|
||||
if (ald_cmu_get_pclk1_clock() / 2 <= 10000000)
|
||||
{
|
||||
hspi->init.baud = SPI_BAUD_2;
|
||||
}
|
||||
else if (cmu_get_pclk1_clock() / 4 <= 10000000)
|
||||
else if (ald_cmu_get_pclk1_clock() / 4 <= 10000000)
|
||||
{
|
||||
hspi->init.baud = SPI_BAUD_4;
|
||||
}
|
||||
@@ -96,10 +97,10 @@ rt_err_t spi_configure(struct rt_spi_device *device,
|
||||
hspi->init.baud = SPI_BAUD_8;
|
||||
}
|
||||
}
|
||||
else if (cfg->max_hz >= cmu_get_pclk1_clock() / 4)
|
||||
else if (cfg->max_hz >= ald_cmu_get_pclk1_clock() / 4)
|
||||
{
|
||||
/* pclk1 max speed 48MHz, spi master max speed 10MHz */
|
||||
if (cmu_get_pclk1_clock() / 4 <= 10000000)
|
||||
if (ald_cmu_get_pclk1_clock() / 4 <= 10000000)
|
||||
{
|
||||
hspi->init.baud = SPI_BAUD_4;
|
||||
}
|
||||
@@ -108,23 +109,23 @@ rt_err_t spi_configure(struct rt_spi_device *device,
|
||||
hspi->init.baud = SPI_BAUD_8;
|
||||
}
|
||||
}
|
||||
else if (cfg->max_hz >= cmu_get_pclk1_clock() / 8)
|
||||
else if (cfg->max_hz >= ald_cmu_get_pclk1_clock() / 8)
|
||||
{
|
||||
hspi->init.baud = SPI_BAUD_8;
|
||||
}
|
||||
else if (cfg->max_hz >= cmu_get_pclk1_clock() / 16)
|
||||
else if (cfg->max_hz >= ald_cmu_get_pclk1_clock() / 16)
|
||||
{
|
||||
hspi->init.baud = SPI_BAUD_16;
|
||||
}
|
||||
else if (cfg->max_hz >= cmu_get_pclk1_clock() / 32)
|
||||
else if (cfg->max_hz >= ald_cmu_get_pclk1_clock() / 32)
|
||||
{
|
||||
hspi->init.baud = SPI_BAUD_32;
|
||||
}
|
||||
else if (cfg->max_hz >= cmu_get_pclk1_clock() / 64)
|
||||
else if (cfg->max_hz >= ald_cmu_get_pclk1_clock() / 64)
|
||||
{
|
||||
hspi->init.baud = SPI_BAUD_64;
|
||||
}
|
||||
else if (cfg->max_hz >= cmu_get_pclk1_clock() / 128)
|
||||
else if (cfg->max_hz >= ald_cmu_get_pclk1_clock() / 128)
|
||||
{
|
||||
hspi->init.baud = SPI_BAUD_128;
|
||||
}
|
||||
@@ -132,7 +133,7 @@ rt_err_t spi_configure(struct rt_spi_device *device,
|
||||
{
|
||||
hspi->init.baud = SPI_BAUD_256;
|
||||
}
|
||||
spi_init(hspi);
|
||||
ald_spi_init(hspi);
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
@@ -157,7 +158,7 @@ static rt_uint32_t spixfer(struct rt_spi_device *device, struct rt_spi_message *
|
||||
{
|
||||
rt_pin_write(cs->pin, 0);
|
||||
}
|
||||
res = spi_send(hspi, (rt_uint8_t *)message->send_buf, (rt_int32_t)message->length, SPITIMEOUT);
|
||||
res = ald_spi_send(hspi, (rt_uint8_t *)message->send_buf, (rt_int32_t)message->length, SPITIMEOUT);
|
||||
if (message->cs_release)
|
||||
{
|
||||
rt_pin_write(cs->pin, 1);
|
||||
@@ -173,7 +174,7 @@ static rt_uint32_t spixfer(struct rt_spi_device *device, struct rt_spi_message *
|
||||
{
|
||||
rt_pin_write(cs->pin, 0);
|
||||
}
|
||||
res = spi_recv(hspi, (rt_uint8_t *)message->recv_buf, (rt_int32_t)message->length, SPITIMEOUT);
|
||||
res = ald_spi_recv(hspi, (rt_uint8_t *)message->recv_buf, (rt_int32_t)message->length, SPITIMEOUT);
|
||||
if (message->cs_release)
|
||||
{
|
||||
rt_pin_write(cs->pin, 1);
|
||||
@@ -189,8 +190,8 @@ static rt_uint32_t spixfer(struct rt_spi_device *device, struct rt_spi_message *
|
||||
{
|
||||
rt_pin_write(cs->pin, 0);
|
||||
}
|
||||
res = spi_send_recv(hspi, (rt_uint8_t *)message->send_buf, (rt_uint8_t *)message->recv_buf,
|
||||
(rt_int32_t)message->length, SPITIMEOUT);
|
||||
res = ald_spi_send_recv(hspi, (rt_uint8_t *)message->send_buf, (rt_uint8_t *)message->recv_buf,
|
||||
(rt_int32_t)message->length, SPITIMEOUT);
|
||||
if (message->cs_release)
|
||||
{
|
||||
rt_pin_write(cs->pin, 1);
|
||||
@@ -230,11 +231,11 @@ int es32f0_spi_register_bus(SPI_TypeDef *SPIx, const char *name)
|
||||
gpio_instruct.flt = GPIO_FILTER_DISABLE;
|
||||
|
||||
/* PB3->SPI0_SCK, PB5->SPI0_MOSI */
|
||||
gpio_init(GPIOB, GPIO_PIN_3 | GPIO_PIN_5, &gpio_instruct);
|
||||
ald_gpio_init(GPIOB, GPIO_PIN_3 | GPIO_PIN_5, &gpio_instruct);
|
||||
|
||||
/* PB4->SPI0_MISO */
|
||||
gpio_instruct.mode = GPIO_MODE_INPUT;
|
||||
gpio_init(GPIOB, GPIO_PIN_4, &gpio_instruct);
|
||||
ald_gpio_init(GPIOB, GPIO_PIN_4, &gpio_instruct);
|
||||
}
|
||||
else if (SPIx == SPI1)
|
||||
{
|
||||
@@ -250,11 +251,11 @@ int es32f0_spi_register_bus(SPI_TypeDef *SPIx, const char *name)
|
||||
gpio_instruct.flt = GPIO_FILTER_DISABLE;
|
||||
|
||||
/* PB13->SPI1_SCK, PB15->SPI1_MOSI */
|
||||
gpio_init(GPIOB, GPIO_PIN_13 | GPIO_PIN_15, &gpio_instruct);
|
||||
ald_gpio_init(GPIOB, GPIO_PIN_13 | GPIO_PIN_15, &gpio_instruct);
|
||||
|
||||
/* PB14->SPI1_MISO */
|
||||
gpio_instruct.mode = GPIO_MODE_INPUT;
|
||||
gpio_init(GPIOB, GPIO_PIN_14, &gpio_instruct);
|
||||
ald_gpio_init(GPIOB, GPIO_PIN_14, &gpio_instruct);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -6,6 +6,7 @@
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2019-03-19 wangyq the first version
|
||||
* 2019-11-01 wangyq update libraries
|
||||
*/
|
||||
|
||||
#include <rtthread.h>
|
||||
@@ -6,6 +6,7 @@
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2019-03-01 wangyq the first version
|
||||
* 2019-11-01 wangyq update libraries
|
||||
*/
|
||||
|
||||
#include <rthw.h>
|
||||
@@ -43,21 +44,21 @@ static rt_err_t es32f0x_configure(struct rt_serial_device *serial, struct serial
|
||||
|
||||
#ifdef BSP_USING_UART0
|
||||
gpio_init_initstructure.func = GPIO_FUNC_3;
|
||||
gpio_init(GPIOB, GPIO_PIN_10, &gpio_init_initstructure);
|
||||
ald_gpio_init(GPIOB, GPIO_PIN_10, &gpio_init_initstructure);
|
||||
|
||||
/* Initialize rx pin ,the same as txpin except mode */
|
||||
gpio_init_initstructure.mode = GPIO_MODE_INPUT;
|
||||
gpio_init(GPIOB, GPIO_PIN_11, &gpio_init_initstructure);
|
||||
ald_gpio_init(GPIOB, GPIO_PIN_11, &gpio_init_initstructure);
|
||||
#endif
|
||||
|
||||
#ifdef BSP_USING_UART1
|
||||
/* Initialize tx pin */
|
||||
gpio_init_initstructure.func = GPIO_FUNC_3;
|
||||
gpio_init(GPIOC, GPIO_PIN_10, &gpio_init_initstructure);
|
||||
ald_gpio_init(GPIOC, GPIO_PIN_10, &gpio_init_initstructure);
|
||||
|
||||
/* Initialize rx pin ,the same as txpin except mode*/
|
||||
gpio_init_initstructure.mode = GPIO_MODE_INPUT;
|
||||
gpio_init(GPIOC, GPIO_PIN_11, &gpio_init_initstructure);
|
||||
ald_gpio_init(GPIOC, GPIO_PIN_11, &gpio_init_initstructure);
|
||||
#endif
|
||||
|
||||
uart->huart.init.mode = UART_MODE_UART;
|
||||
@@ -65,7 +66,7 @@ static rt_err_t es32f0x_configure(struct rt_serial_device *serial, struct serial
|
||||
uart->huart.init.word_length = (uart_word_length_t)(cfg->data_bits - 5);
|
||||
uart->huart.init.parity = (uart_parity_t)(cfg->parity == PARITY_EVEN ? UART_PARITY_EVEN : cfg->parity);
|
||||
uart->huart.init.fctl = UART_HW_FLOW_CTL_DISABLE;
|
||||
uart_init(&uart->huart);
|
||||
ald_uart_init(&uart->huart);
|
||||
|
||||
if (cfg->bit_order == BIT_ORDER_MSB)
|
||||
{
|
||||
@@ -86,7 +87,7 @@ static rt_err_t es32f0x_configure(struct rt_serial_device *serial, struct serial
|
||||
}
|
||||
|
||||
/* enable rx int */
|
||||
uart_interrupt_config(&uart->huart, UART_IT_RXRD, ENABLE);
|
||||
ald_uart_interrupt_config(&uart->huart, UART_IT_RXRD, ENABLE);
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
@@ -103,14 +104,14 @@ static rt_err_t es32f0x_control(struct rt_serial_device *serial, int cmd, void *
|
||||
/* disable rx irq */
|
||||
NVIC_DisableIRQ(uart->irq);
|
||||
/* disable interrupt */
|
||||
uart_interrupt_config(&uart->huart, UART_IT_RXRD, DISABLE);
|
||||
ald_uart_interrupt_config(&uart->huart, UART_IT_RXRD, DISABLE);
|
||||
break;
|
||||
|
||||
case RT_DEVICE_CTRL_SET_INT:
|
||||
/* enable rx irq */
|
||||
NVIC_EnableIRQ(uart->irq);
|
||||
/* enable interrupt */
|
||||
uart_interrupt_config(&uart->huart, UART_IT_RXRD, ENABLE);
|
||||
ald_uart_interrupt_config(&uart->huart, UART_IT_RXRD, ENABLE);
|
||||
break;
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 3.2 MiB After Width: | Height: | Size: 3.2 MiB |
|
Before Width: | Height: | Size: 2.6 MiB After Width: | Height: | Size: 2.6 MiB |
+181
-215
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user