diff --git a/.gitmodules b/.gitmodules
deleted file mode 100644
index b1fecda..0000000
--- a/.gitmodules
+++ /dev/null
@@ -1,3 +0,0 @@
-[submodule "BitFiles"]
- path = BitFiles
- url = https://60.248.80.176:28080/wlhsu/fpga_bit_file.git
diff --git a/Apps/app_demo_project/.cproject b/Apps/app_demo_project/.cproject
new file mode 100644
index 0000000..a42ccb9
--- /dev/null
+++ b/Apps/app_demo_project/.cproject
@@ -0,0 +1,298 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Apps/demo_project/.project b/Apps/app_demo_project/.project
similarity index 98%
rename from Apps/demo_project/.project
rename to Apps/app_demo_project/.project
index 83b30c3..123d8c1 100644
--- a/Apps/demo_project/.project
+++ b/Apps/app_demo_project/.project
@@ -42,7 +42,7 @@
- 0
+ 1762843010815
6
diff --git a/Apps/demo_project/Project.nuproject b/Apps/app_demo_project/Project.nuproject
similarity index 100%
rename from Apps/demo_project/Project.nuproject
rename to Apps/app_demo_project/Project.nuproject
diff --git a/Apps/demo_project/component.mk b/Apps/app_demo_project/component.mk
similarity index 100%
rename from Apps/demo_project/component.mk
rename to Apps/app_demo_project/component.mk
diff --git a/Apps/demo_project/inc/isr.h b/Apps/app_demo_project/inc/isr.h
similarity index 100%
rename from Apps/demo_project/inc/isr.h
rename to Apps/app_demo_project/inc/isr.h
diff --git a/Apps/demo_project/inc/main.h b/Apps/app_demo_project/inc/main.h
similarity index 100%
rename from Apps/demo_project/inc/main.h
rename to Apps/app_demo_project/inc/main.h
diff --git a/Examples/I2C/I2C_Master_EEPROM/readme.md b/Apps/app_demo_project/readme.md
similarity index 56%
rename from Examples/I2C/I2C_Master_EEPROM/readme.md
rename to Apps/app_demo_project/readme.md
index b4f1dcd..a718da5 100644
--- a/Examples/I2C/I2C_Master_EEPROM/readme.md
+++ b/Apps/app_demo_project/readme.md
@@ -1,10 +1,8 @@
demo_project
---
-This example is a demo project to descript
-> + How to log message
+This example is a demo project to descript `how to log message`
## Log
Use serial port with baudrate 115200, 8bit, no parity check.
-
diff --git a/Apps/demo_project/src/isr.c b/Apps/app_demo_project/src/isr.c
similarity index 100%
rename from Apps/demo_project/src/isr.c
rename to Apps/app_demo_project/src/isr.c
diff --git a/Apps/demo_project/src/main.c b/Apps/app_demo_project/src/main.c
similarity index 97%
rename from Apps/demo_project/src/main.c
rename to Apps/app_demo_project/src/main.c
index d84273f..5e1b4a5 100644
--- a/Apps/demo_project/src/main.c
+++ b/Apps/app_demo_project/src/main.c
@@ -52,7 +52,7 @@ int main(void)
syslog_init();
- info("This is a demo project\n");
+ info("This is a app demo project\n");
msg("log debug message: $pc= x%08X\n", __get_pc());
log_color(SLOG_GREEN, "color green\n");
log_color(SLOG_YELLOW, "color yellow\n");
diff --git a/Apps/demo_project/readme.md b/Apps/demo_project/readme.md
deleted file mode 100644
index b4f1dcd..0000000
--- a/Apps/demo_project/readme.md
+++ /dev/null
@@ -1,10 +0,0 @@
-demo_project
----
-
-This example is a demo project to descript
-> + How to log message
-
-## Log
-
-Use serial port with baudrate 115200, 8bit, no parity check.
-
diff --git a/Common/syslog.c b/Common/syslog.c
index e93c49a..8a21e23 100644
--- a/Common/syslog.c
+++ b/Common/syslog.c
@@ -16,7 +16,11 @@
//=============================================================================
// Constant Definition
//=============================================================================
-#define CONFIG_LOG_MSG_DEVICE UART0
+#define CONFIG_LOG_MSG_DEVICE UART0
+#define CONFIG_LOG_DEVICE_TX_IO_PORTx GPIOA
+#define CONFIG_LOG_DEVICE_TX_IO_PINx GPIO_Pin_15
+#define CONFIG_LOG_DEVICE_TX_IO_AF GPIO_AF_1
+#define CONFIG_LOG_DEVICE_RESET() __HAL_SYSCFG_RESET_UART0()
//=============================================================================
// Macro Definition
//=============================================================================
@@ -47,11 +51,11 @@ void syslog_init(void)
GPIO_InitTypeDef gpio_init = {0};
UART_InitTypeDef uart_init = {0};
- /* configure GPIO Pin mux of UART (Tx through PA15) */
- gpio_init.GPIO_Pin = GPIO_Pin_15;
+ /* configure GPIO Pin mux of UART Tx */
+ gpio_init.GPIO_Pin = CONFIG_LOG_DEVICE_TX_IO_PINx;
+ gpio_init.GPIO_AF_Mode = CONFIG_LOG_DEVICE_TX_IO_AF;
gpio_init.GPIO_Mode = GPIO_Mode_AF;
- gpio_init.GPIO_AF_Mode = GPIO_AF_1;
- GPIO_Init(GPIOA, &gpio_init);
+ GPIO_Init(CONFIG_LOG_DEVICE_TX_IO_PORTx, &gpio_init);
uart_init.BaudRate = SLOG_SERIAL_BPS;
uart_init.WordLength = UART_WordLength_8b;
@@ -64,6 +68,13 @@ void syslog_init(void)
return;
}
+void syslog_deinit(void)
+{
+ GPIO_DeInit(CONFIG_LOG_DEVICE_TX_IO_PORTx, CONFIG_LOG_DEVICE_TX_IO_PINx);
+ CONFIG_LOG_DEVICE_RESET();
+ return;
+}
+
void
syslog_dump_mem(
char *prefix,
diff --git a/Common/syslog.h b/Common/syslog.h
index e292755..53b8eac 100644
--- a/Common/syslog.h
+++ b/Common/syslog.h
@@ -82,6 +82,7 @@ extern "C" {
// Public Function Definition
//=============================================================================
void syslog_init(void);
+void syslog_deinit(void);
/**
* \brief Dump memory data through system log
diff --git a/Docs/Schematic/DAC_ADC_Simple_BOARD_010(20250730)_2.pdf b/Docs/Schematic/DAC_ADC_Simple_BOARD_010(20250730)_2.pdf
deleted file mode 100644
index c306ba8..0000000
Binary files a/Docs/Schematic/DAC_ADC_Simple_BOARD_010(20250730)_2.pdf and /dev/null differ
diff --git a/Docs/Schematic/PB5700_EV_BOARD_SOP24(010)_20250305_M.pdf b/Docs/Schematic/PB5700_EV_BOARD_SOP24(010)_20250305_M.pdf
deleted file mode 100644
index 70fc485..0000000
Binary files a/Docs/Schematic/PB5700_EV_BOARD_SOP24(010)_20250305_M.pdf and /dev/null differ
diff --git a/Docs/Schematic/PB5700_EV_BOARD_SSOP24(010)_20250327.pdf b/Docs/Schematic/PB5700_EV_BOARD_SSOP24(010)_20250327.pdf
deleted file mode 100644
index 69b3716..0000000
Binary files a/Docs/Schematic/PB5700_EV_BOARD_SSOP24(010)_20250327.pdf and /dev/null differ
diff --git a/Docs/Schematic/PEC930_EV_BOARD_SSOP24(010).pdf b/Docs/Schematic/PEC930_EV_BOARD_SSOP24(010).pdf
new file mode 100644
index 0000000..da8974c
Binary files /dev/null and b/Docs/Schematic/PEC930_EV_BOARD_SSOP24(010).pdf differ
diff --git a/Docs/commit_rule.md b/Docs/commit_rule.md
deleted file mode 100644
index 0bef65f..0000000
--- a/Docs/commit_rule.md
+++ /dev/null
@@ -1,161 +0,0 @@
-# Commit Rule
----
-
-當共同合作開發時, 能藉由瀏覽 Commit Message 內容快速進入狀況, 瞭解程式異動的原因, 如此也利於後續的維護.
-
-良好的 Commit Message 在 release 時, 可大幅減少整理 Change Log 的時間.
-
-+ 何謂好的 Commit Message ?
- > 一個好的 Commit Message 必須兼具 What & Why & How, 能幫助開發者瞭解這個提交版本:
-
- - 這個提交版本做了什麼事情(What)
- > 這個版本修正了什麼 bug, 新增了什麼 feature, 或是優化了什麼效能, 也可能只是簡單的文字修正.
- 這是一個 GCM 最重要的一部分, 必須要簡潔明瞭地告訴開發者這個提交版本的目的
-
- - 為什麼要做這件事情(Why)
- > 說明更動的`動機`與`原因`是什麼, 並補充說明 `What` 所描述的項目
-
- - 用什麼方法做到的(How)
- > 用什麼方法做到提交版本的目的.
- 在大部分簡單的提交版本中, 是不需要特別詳註的.
- > 建議是有需要特別補充的才紀錄在訊息中, 並且應該是提供 High-level 的方法與概念的敘述, 例如用了什麼演算法, 設計模式等, 而不是方法的實際細節.
- >> 方法細節應當透過更動的程式碼本身, 以及程式碼註解來自行解釋.
-
-
-# 設定 Git
-
-
-```
-$ git config --global user.name "your-name"
-$ git config --global user.email "your-email"
-```
-
-+ Name
- > 在公司中使用的名字 (不要用暱稱, 要明確知道是誰)
-
-+ E-mail
- > 限制使用公司的 e-mail
-
-# Message Format
-
-
-一個 Commit Message 主要由 `Header (what)` + `Body(why)` + `Footer` 組成
-> 各部分以空行區隔, 為了讓 `git log` 顯示乾淨
-
-```
-Message Header
- ---> 空行
-Message Body
- ---> 空行
-Message Footer
-```
-
-### Message Header
-
-```
-(scope):
-```
-
-+ type(必要): commit 的類別
- > 用來告訴進行 Code Review 的人應該以什麼態度來檢視 Commit 內容.
- > 利用不同的 Type 來決定進行 Code Review 檢視的角度, 可以提升 Code Review 的速度
- > + 看到 Type 為 `fix`, 進行 Code Review 的人就可以用**觀察 Commit 如何解決錯誤**的角度來閱讀程式碼
- > + 若是 `refactor`, 則可以放輕鬆閱讀程式碼如何被重構, 因為重構的本質是不會影響既有的功能
-
- - `feat`: 新功能、新特性
- - `fix`: 修改 bug
- > 如果修復的這個BUG只影響當前修改的文件, 可不加範圍.
- 如果影響的範圍比較大, 要加上範圍描述.
- 例如這次 BUG 修復影響到全局, 可以加個 global. 如果影響的是某個目錄或某個功能, 可以加上該目錄的路徑, 或者對應的功能名稱.
-
- ```js
- fix(global): 修復checkbox不能復選的問題
- ```
-
- ```
- # 下面圓括號裡的 common 為通用管理的名稱
- fix(common): 修復字體過小的BUG, 將通用管理下所有頁面的默認字體大小修改為 14px
- ```
-
- ```
- fix: value.length -> values.length
- ```
-
- - `perf`: 更改代碼, 以提高性能(在不影響代碼內部行為的前提下, 對程序性能進行優化)
- - `refactor`: 代碼重構 (重構, 在不影響代碼內部行為, 功能下的代碼修改)
- - `docs`: 文檔修改
- - `style`: 代碼格式修改 (例如分號修改)
- - `test`: 測試用例新增, 修改
- - `build`: 影響項目構建或依賴項修改
- - `revert`: 恢復上一次提交
- - `ci`: 持續集成相關文件修改
- - `chore`: 其他修改(不在上述類型中的修改)
- > chore 的中文翻譯為日常事務、例行工作, 顧名思義, 即不在其他 commit 類型中的修改, 都可以用 chore 表示.
- - `release`: 發佈新版本
-
-+ Chip ID(必要)
- > 註明 target ID, e.g. `F103`, `F100/F103`, `All`
-
-+ Module
- > 註明目標的 module, e.g. peripheral name (I2C, Uart), Tool, ...等
-
-+ subject(必要): commit 的簡短描述
-
- - **不超過 50 個字元**
- > describe issue
- - 結尾不加句號
- - 儘量讓 Commit 單一化, 一次只更動一個主題
-
-### Message Body
-
-+ 對本次 Commit 的詳細描述
-+ 可以分成多行, **每一行不超過 72 個字元**
- > display issue
-+ 說明程式碼變動的項目與原因, 必要時與先前行為做對比
-
-### Message Footer
-
-如果有 Bug tracer, 紀錄 Issue ID
-
-
-### Example
-
-```
-fix: [F103][I2C] Fix an error handling path in mtk_i2c_probe()
-
-The clsk are prepared, enabled, then disabled. So if an error occurs after
-the disable step, they are still prepared.
-
-Add an error handling path to unprepare the clks in such a case, as already
-done in the .remove function.
-
-bug1234
-```
-
-## Change Log
-
-+ [Basic example](https://github.com/Mokkapps/changelog-generator-demo/blob/master/CHANGELOG.md)
-
-+ [Angular- CHANGELOG](https://github.com/angular/angular/blob/22b96b96902e1a42ee8c5e807720424abad3082a/CHANGELOG.md)
-
-
-## Reference
-+ [約定式提交](https://www.conventionalcommits.org/zh-hans/v1.0.0-beta.4/)
-
-
-# Setup environment
----
-
-+ Install [Official Git](https://git-scm.com/downloads)
-
-+ Verify git configuration
-
- - [Right key] -> [Git Bash Here]
- > System MUST be installed official git tool.
-
- - Execute `z_git_config.sh`
- > verify git configuration
-
- ```bash
- $ z_git_config.sh
- ```
diff --git a/Docs/image/IDE_close_proj.jpg b/Docs/image/IDE_close_proj.jpg
new file mode 100644
index 0000000..e4ad850
Binary files /dev/null and b/Docs/image/IDE_close_proj.jpg differ
diff --git a/Docs/image/IDE_delet_recent_proj.jpg b/Docs/image/IDE_delet_recent_proj.jpg
new file mode 100644
index 0000000..c88038d
Binary files /dev/null and b/Docs/image/IDE_delet_recent_proj.jpg differ
diff --git a/Docs/image/TortoiseGit_clone.jpg b/Docs/image/TortoiseGit_clone.jpg
deleted file mode 100644
index c550936..0000000
Binary files a/Docs/image/TortoiseGit_clone.jpg and /dev/null differ
diff --git a/Docs/image/gitlab_login.jpg b/Docs/image/gitlab_login.jpg
deleted file mode 100644
index d2449ab..0000000
Binary files a/Docs/image/gitlab_login.jpg and /dev/null differ
diff --git a/Drivers/PB5700/Flash/readme.md b/Drivers/PB5700/Flash/readme.md
deleted file mode 100644
index e473025..0000000
--- a/Drivers/PB5700/Flash/readme.md
+++ /dev/null
@@ -1,10 +0,0 @@
-flash-loader
----
-
-## flash-loader for eFlash
-
-`loader.bin` is used to download data (on Host) to DUT eFlash
-> OpenOCD should use `pb5700.cfg` to setup environment
-
-+ flash-loader will be put at `0x2000_0A00` of DUT
- > It uses 1.5KB (?) as executing area
diff --git a/Drivers/PB5700/HAL_Lib/inc/hal_comp.h b/Drivers/PB5700/HAL_Lib/inc/hal_comp.h
deleted file mode 100644
index 6d04df2..0000000
--- a/Drivers/PB5700/HAL_Lib/inc/hal_comp.h
+++ /dev/null
@@ -1,204 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file hal_comp.h
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/10/17
- * @license
- * @description
- */
-
-#ifndef __hal_comp_H_wqqzibVO_lvKI_HWdK_sROD_uhjcZz7SHMtL__
-#define __hal_comp_H_wqqzibVO_lvKI_HWdK_sROD_uhjcZz7SHMtL__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-#include "hal_def.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-/**
- * the voltige input_n of Comparer
- */
-typedef enum COMP_Vin
-{
- COMP_Vin_IO = (COMP_CTRL_VIN_SEL_IO << COMP_CTRL_VIN_SEL_Pos),
- COMP_Vin_DAC = (COMP_CTRL_VIN_SEL_DAC << COMP_CTRL_VIN_SEL_Pos),
-
-} COMP_VinTypeDef;
-
-typedef enum COMP_Filter
-{
- COMP_Filter_Bypass = (COMP_CTRL_FIL_CTRL_BYPASS << COMP_CTRL_FIL_CTRL_Pos),
- COMP_Filter_Sample_2 = (COMP_CTRL_FIL_CTRL_SAMPLE_2 << COMP_CTRL_FIL_CTRL_Pos),
- COMP_Filter_Sample_4 = (COMP_CTRL_FIL_CTRL_SAMPLE_4 << COMP_CTRL_FIL_CTRL_Pos),
- COMP_Filter_Sample_8 = (COMP_CTRL_FIL_CTRL_SAMPLE_8 << COMP_CTRL_FIL_CTRL_Pos),
- COMP_Filter_Sample_16 = (COMP_CTRL_FIL_CTRL_SAMPLE_16 << COMP_CTRL_FIL_CTRL_Pos),
- COMP_Filter_Sample_32 = (COMP_CTRL_FIL_CTRL_SAMPLE_32 << COMP_CTRL_FIL_CTRL_Pos),
- COMP_Filter_Sample_64 = (COMP_CTRL_FIL_CTRL_SAMPLE_64 << COMP_CTRL_FIL_CTRL_Pos),
- COMP_Filter_Sample_128 = (COMP_CTRL_FIL_CTRL_SAMPLE_128 << COMP_CTRL_FIL_CTRL_Pos),
- COMP_Filter_Sample_256 = (COMP_CTRL_FIL_CTRL_SAMPLE_256 << COMP_CTRL_FIL_CTRL_Pos),
-
-} COMP_FilterTypeDef;
-
-/**
- * the voltige input_p of Comparer
- */
-typedef enum COMP_Vip
-{
- COMP_Vip_PGA = (COMP_VIPSEL_VIP_SEL_PGA << COMP_VIPSEL_VIP_SEL_Pos),
- COMP_Vip_IO0 = (COMP_VIPSEL_VIP_SEL_IO0 << COMP_VIPSEL_VIP_SEL_Pos),
- COMP_Vip_IO1 = (COMP_VIPSEL_VIP_SEL_IO1 << COMP_VIPSEL_VIP_SEL_Pos),
- COMP_Vip_IO2 = (COMP_VIPSEL_VIP_SEL_IO2 << COMP_VIPSEL_VIP_SEL_Pos),
- COMP_Vip_IO3 = (COMP_VIPSEL_VIP_SEL_IO3 << COMP_VIPSEL_VIP_SEL_Pos),
-
-} COMP_VipTypeDef;
-
-
-typedef enum COMP_Polarity
-{
- COMP_Polarity_Normal = (COMP_CTRL_POL_SEL_NORMAL << COMP_CTRL_POL_SEL_Pos),
- COMP_Polarity_Invert = (COMP_CTRL_POL_SEL_INVERT << COMP_CTRL_POL_SEL_Pos),
-
-} COMP_PolarityTypeDef;
-
-/**
- * Interrupt type of Comparer
- */
-typedef enum COMP_IE
-{
- COMP_IE_Rising = COMP_IR_RIE_Msk,
- COMP_IE_Falling = COMP_IR_FIE_Msk,
- COMP_IE_ALL = (COMP_IR_RIE_Msk | COMP_IR_FIE_Msk),
-
-} COMP_IETypeDef;
-
-/**
- * Out type of Comparer
- */
-
-typedef enum COMP_Out
-{
- COMP_Out_Disable = 0x0,
- COMP_Out_Enable = COMP_CTRL_OUT_EN_Msk,
-
-} COMP_OutTypeDef;
-
-typedef enum COMP_Hsy
-{
- COMP_Hsy_Disable = 0x0,
- COMP_Hsy_Enable = COMP_CTRL_HYS_EN_Msk,
-
-} COMP_HsyTypeDef;
-
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-/**
- * \brief COMP enable/disable
- *
- * \param [in] pHComp pointer to a COMP instance
- * \return
- * None
- */
-__STATIC_INLINE void COMP_Enable(COMP_Type *pHComp)
-{
-
- REG_SET_BITS(pHComp->CTRL, COMP_CTRL_EN_Msk);
- return;
-}
-
-__STATIC_INLINE void COMP_Disable(COMP_Type *pHComp)
-{
-
- REG_CLR_BITS(pHComp->CTRL, COMP_CTRL_EN_Msk);
- return;
-}
-
-/**
- * \brief COMP get output level
- *
- * \param [in] pHComp pointer to a COMP instance
- * \return
- * 0 : COMP OUT Low
- * others: COMP OUT High
- */
-__STATIC_INLINE uint32_t COMP_GetOutputLevel(COMP_Type *pHComp)
-{
- return REG_READ_MASK(pHComp->CTRL, COMP_CTRL_COUT_Msk);
-}
-
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-typedef struct
-{
- COMP_VinTypeDef COMP_NegativeSel; /*!CTRL,
- COMP_CTRL_VIN_SEL_Msk | COMP_CTRL_FIL_CTRL_Msk | COMP_CTRL_POL_SEL_Msk |
- COMP_CTRL_OUT_EN_Msk | COMP_CTRL_HYS_EN_Msk ,
- pInit->COMP_NegativeSel | pInit->COMP_Filter | pInit->COMP_Polarity |
- pInit->COMP_Out | pInit->COMP_Hsy);
-
- REG_WRITE_MASK(pHComp->VIPSEL, COMP_VIPSEL_VIP_SEL_Msk, pInit->COMP_PositiveSel);
-
- REG_WRITE_MASK(pHComp->IR,
- COMP_IR_RIE_Msk | COMP_IR_FIE_Msk,
- pInit->COMP_Interrupt);
-
- REG_WRITE_MASK(pHComp->INITCNT,
- COMP_INITCNT_INIT_DELAY_Msk,
- pInit->COMP_InitDelay);
-
- return;
-}
-
-void COMP_DeInit(COMP_Type *pHComp)
-{
- if( pHComp == COMP0 )
- {
- __HAL_SYSCFG_COMP0_CLK_DISABLE();
- }
- else if( pHComp == COMP1 )
- {
- __HAL_SYSCFG_COMP1_CLK_DISABLE();
- }
- return;
-}
-
-#endif /* CONFIG_ENABLE_HAL_VCMP */
diff --git a/Drivers/PB5700/HAL_Lib/src/hal_i2c.c b/Drivers/PB5700/HAL_Lib/src/hal_i2c.c
deleted file mode 100644
index b67d1d9..0000000
--- a/Drivers/PB5700/HAL_Lib/src/hal_i2c.c
+++ /dev/null
@@ -1,288 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file hal_i2c.c
-*
-* @author Wei-Lun Hsu
-* @version 0.1
-* @date 2024/09/10
-* @license
-* @description
-*/
-
-
-#include "hal_device.h"
-
-#if defined(CONFIG_ENABLE_HAL_I2C)
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-
-/**
- * @brief Deinitializes the i2c peripheral registers to their default
- * reset values.
- * @param i2c1.
- * @retval None.
- */
-void I2C_DeInit(I2C_Type *i2c)
-{
- __HAL_SYSCFG_RESET_I2C();
-}
-
-/**
- * @brief Initializes the i2c peripheral according to the specified
- * parameters in the init_struct.
- * @param i2c: select the I2C peripheral.
- * @param init_struct: pointer to a I2C_InitTypeDef structure that
- * contains the configuration information for the specified
- * I2C peripheral.
- * @retval None.
- */
-void I2C_Init(I2C_Type *i2c, I2C_InitTypeDef *init_struct)
-{
- __HAL_SYSCFG_I2C_CLK_ENABLE() ;
- REG_WRITE_MASK(i2c->ADDR, I2C_ADDR_ADDR_Msk, init_struct->I2C_OwnAddress);
- switch(init_struct->I2C_ClockDiv)
- {
- case (I2C_CLK_Div60):
- I2C_ClkDivConfig(i2c,0,1,1);
- break;
- case (I2C_CLK_Div120):
- I2C_ClkDivConfig(i2c,1,0,1);
- break;
- case (I2C_CLK_Div160):
- I2C_ClkDivConfig(i2c,1,1,0);
- break;
- case (I2C_CLK_Div192):
- I2C_ClkDivConfig(i2c,0,1,0);
- break;
- case (I2C_CLK_Div244):
- I2C_ClkDivConfig(i2c,1,0,0);
- break;
- case (I2C_CLK_Div256):
- I2C_ClkDivConfig(i2c,0,0,0);
- break;
- case (I2C_CLK_Div960):
- I2C_ClkDivConfig(i2c,0,0,1);
- break;
- default:
- break;
- }
-
-}
-void I2C_ClkDivConfig(I2C_Type *i2c, uint32_t I2C_ClockDivCr0,uint32_t I2C_ClockDivCr1,uint32_t I2C_ClockDivCr2)
-{
- (I2C_ClockDivCr0) ? \
- (REG_WRITE_MASK(i2c->CTLSET, I2C_CTLSET_CR0_Msk, 1 << I2C_CTLSET_CR0_Pos)) : \
- (REG_WRITE_MASK(i2c->CTLCLR, I2C_CTLCLR_CR0_Msk, 1 << I2C_CTLCLR_CR0_Pos));
- (I2C_ClockDivCr1) ? \
- (REG_WRITE_MASK(i2c->CTLSET, I2C_CTLSET_CR1_Msk, 1 << I2C_CTLSET_CR1_Pos)) : \
- (REG_WRITE_MASK(i2c->CTLCLR, I2C_CTLCLR_CR1_Msk, 1 << I2C_CTLCLR_CR1_Pos));
- (I2C_ClockDivCr2) ? \
- (REG_WRITE_MASK(i2c->CTLSET, I2C_CTLSET_CR2_Msk, 1 << I2C_CTLSET_CR2_Pos)) : \
- (REG_WRITE_MASK(i2c->CTLCLR, I2C_CTLCLR_CR2_Msk, 1 << I2C_CTLCLR_CR2_Pos));
-}
-/**
- * @brief Fills each init_struct member with its default value.
- * @param init_struct: pointer to an I2C_InitTypeDef structure
- * which will be initialized.
- * @retval None.
- */
-void I2C_StructInit(I2C_InitTypeDef *init_struct)
-{
- init_struct->I2C_Mode = I2C_Mode_Master;
- init_struct->I2C_OwnAddress = I2C_Own_Address;
- init_struct->I2C_ClockDiv = I2C_CLK_Div256;
-}
-
-/**
- * @brief Enables or disables the specified I2C peripheral.
- * @param i2c: select the I2C peripheral.
- * @param state: new state of the i2c peripheral. This parameter
- * can be: ENABLE or DISABLE.
- * @retval None.
- */
-void I2C_Cmd(I2C_Type *i2c, FunctionalState state)
-{
- (state) ? \
- (i2c->CTLSET |= (0x01U << I2C_CTLSET_EN_Pos)) : \
- (i2c->CTLCLR |= (0x01U << I2C_CTLCLR_EN_Pos)) ;
-}
-
-/**
- * @brief Generates i2c communication START condition.
- * @param i2c: select the I2C peripheral.
- * @param state: new state of the I2C START condition generation.
- * This parameter can be: ENABLE or DISABLE.
- * @retval None.
- */
-void I2C_GenerateSTART(I2C_Type *i2c, FunctionalState state)
-{
- (state) ? \
- (i2c->CTLSET |= (0x01U << I2C_CTLSET_STA_Pos)) : \
- (i2c->CTLCLR |= (0x01U << I2C_CTLCLR_STA_Pos));
-}
-
-void I2C_GenerateRESTART(I2C_Type *i2c, FunctionalState state)
-{
- (state) ? \
- (i2c->CTLSET |= (0x01U << I2C_CTLSET_STA_Pos)) : \
- (i2c->CTLCLR |= (0x01U << I2C_CTLCLR_STA_Pos));
-}
-/**
- * @brief Generates i2c communication STOP condition.
- * @param i2c: select the I2C peripheral.
- * @param state: new state of the I2C STOP condition generation.
- * This parameter can be: ENABLE or DISABLE.
- * @retval None.
- */
-void I2C_GenerateSTOP(I2C_Type *i2c, FunctionalState state)
-{
- (state) ? \
- (i2c->CTLSET |= (0x01U << I2C_CTLSET_STO_Pos)) : \
- (i2c->CTLCLR |= (0x01U << I2C_CTLCLR_STO_Pos));
-}
-
-/**
- * @brief Configures the specified I2C Target Address.
- * @param i2c: select the I2C peripheral.
- * @param addr: specifies the 7bit I2C Target Address.
- * @retval None.
- */
-void I2C_TargetAddressConfig(I2C_Type *i2c, uint8_t addr)
-{
- REG_WRITE_MASK(i2c->ADDR, I2C_ADDR_ADDR_Msk, addr << 1);
-}
-
-
-/**
- * @brief Enables or disables the specified I2C interrupts.
- * @param i2c: select the I2C peripheral.
- * @param it: specifies the I2C interrupts sources to be enabled or disabled.
- * This parameter can be any combination of the following values:
- * @arg :
- * @param state: new state of the specified I2C interrupts.
- * This parameter can be: ENABLE or DISABLE.
- * @retval None.
- */
-void I2C_ITConfig(I2C_Type *i2c, FunctionalState state)
-{
- (state) ? \
- (i2c->CTLSET |= (0x01U << I2C_CTLSET_SI_Pos)) : \
- (i2c->CTLCLR |= (0x01U << I2C_CTLCLR_SI_Pos));
-}
-
-/**
- * @brief Sends a data byte through the i2c peripheral.
- * @param i2c: select the I2C peripheral.
- * @param dat: Byte to be transmitted..
- * @retval None.
- */
-void I2C_SendData(I2C_Type *i2c, uint8_t dat)
-{
- i2c->DATA_b.DATA = dat;
-}
-
-
-/**
- * @brief Returns the most recent received data by the i2c peripheral.
- * @param i2c: select the I2C peripheral.
- * @retval The value of the received data.
- */
-uint8_t I2C_ReceiveData(I2C_Type *i2c)
-{
- return ((uint8_t)i2c->DATA_b.DATA );
-}
-
-/**
- * @brief Checks whether the specified I2C flag is set or not.
- * @param i2c: select the I2C peripheral.
- * @param flag: specifies the flag to check.
- * This parameter can be one of the following values:
- * @arg :
- * @retval The new state of I2C_FLAG (SET or RESET).
- */
-FlagStatus I2C_GetFlagStatus(I2C_Type *i2c, uint32_t flag)
-{
- return ((i2c->STAT_b.STAT == flag) ? SET : RESET);
-}
-
-/**
- * @brief Clears the i2c's pending flags.
- * @param i2c: select the I2C peripheral.
- * @param flag: specifies the flag to clear.
- * This parameter can be any combination of the following values:
- * @arg I2C_START_RESET : Rx Buffer is empty flag
- * @arg I2C_START_SET : RX Buffer Overrun flag
- * @arg I2C_STO_RESET : Rx buffer full flag
- * @arg I2C_STO_SET : TX Buffer Overrun flag
- * @arg I2C_SI_RESET : TX_FIFO empty flag
- * @arg I2C_SI_SET : I2C work as slave or master flag
- * @arg I2C_AA_RESET : TX error flag(Master mode)
- * @arg I2C_AA_SET : Master not ack flag(slave mode)
- * @retval None.
- */
-void I2C_ClearFlag(I2C_Type *i2c, uint32_t flag)
-{
-
-}
-/**
- * @brief Config the i2c's flags.
- * @param i2c: select the I2C peripheral.
- * @param flag: specifies the flag to clear.
- * This parameter can be any combination of the following values:
- * @arg :
- * @retval None.
- */
-void I2C_StaFlagConfig(I2C_Type *i2c, I2C_StartFlagTypeDef sta,I2C_StopStaTypeDef sto,I2C_SiStaTypeDef si,I2C_AckStaTypeDef aa)
-{
- (sta) ? \
- (REG_WRITE_MASK(i2c->CTLSET, I2C_CTLSET_STA_Msk, 1 << I2C_CTLSET_STA_Pos)) : \
- (REG_WRITE_MASK(i2c->CTLCLR, I2C_CTLCLR_STA_Msk, 1 << I2C_CTLCLR_STA_Pos));
- (sto) ? \
- (REG_WRITE_MASK(i2c->CTLSET, I2C_CTLSET_STO_Msk, 1 << I2C_CTLSET_STO_Pos)) : \
- (REG_WRITE_MASK(i2c->CTLCLR, I2C_CTLCLR_STO_Msk, 1 << I2C_CTLCLR_STO_Pos));
- (aa) ? \
- (REG_WRITE_MASK(i2c->CTLSET, I2C_CTLSET_AA_Msk, 1 << I2C_CTLSET_AA_Pos)) : \
- (REG_WRITE_MASK(i2c->CTLCLR, I2C_CTLCLR_AA_Msk, 1 << I2C_CTLCLR_AA_Pos));
- (si) ? \
- (REG_WRITE_MASK(i2c->CTLSET, I2C_CTLSET_SI_Msk, 1 << I2C_CTLSET_SI_Pos)) : \
- (REG_WRITE_MASK(i2c->CTLCLR, I2C_CTLCLR_SI_Msk, 1 << I2C_CTLCLR_SI_Pos));
-}
-
-/**
- * @brief Returns the last i2c Event.
- * @param i2c: select the I2C peripheral.
- * @retval The last event
- */
-uint32_t I2C_GetSlaveReceivedAddr(I2C_Type *i2c)
-{
- return ((uint32_t)i2c->ADDR);
-}
-
-uint32_t I2C_GetSta(I2C_Type *i2c)
-{
- return ((uint32_t)i2c->STAT_b.STAT);
-}
-
-#endif /* CONFIG_ENABLE_HAL_I2C */
diff --git a/Drivers/PB5700/component.mk b/Drivers/PB5700/component.mk
deleted file mode 100644
index 252384c..0000000
--- a/Drivers/PB5700/component.mk
+++ /dev/null
@@ -1,92 +0,0 @@
-#
-# component Makefile
-#
-
-
-#=======================================
-# Configurations
-#=======================================
-
-#
-# Drivers of MCU
-#
-
-SOC_CPU_NAME = n203e
-
-#=======================================
-# system
-#=======================================
-ifeq ("$(SOC)","pb5700")
- C_DEFS += -DCONFIG_USE_PB5700
-else
-$(error "Unknown SoC !!!")
-endif
-
-#
-# cpu
-#
-C_DEFS += -DCONFIG_CPU_N203E -DCONFIG_HAS_BPU
-
-CPU_FLAGS = -mabi=ilp32e -mcmodel=medlow
-CPU_FLAGS += -march=rv32emc_zba_zbb_zbs_zca_zcb_zcmp_zcmt_zicond
-
-
-#
-# Source
-#
-ASM_SOURCES := \
- $(srctree)/Drivers/PB5700/Device/src/Startup/startup.S \
- $(srctree)/Drivers/PB5700/Device/src/Startup/trap.S
-
-C_SOURCES += \
- $(srctree)/Drivers/PB5700/Device/src/interrupt.c \
- $(srctree)/Drivers/PB5700/Device/src/syscalls.c \
- $(srctree)/Drivers/PB5700/Device/src/system_dev.c
-
-C_INCLUDES += \
- -I$(srctree)/Drivers/PB5700/Device/inc \
- -I$(srctree)/Drivers/PB5700/NMSIS/Core/Include \
- -I$(srctree)/Drivers/PB5700/
-
-
-
-#=======================================
-# peripheral hal driver
-#=======================================
-C_SOURCES += \
- $(srctree)/Drivers/PB5700/HAL_Lib/src/hal_adc.c \
- $(srctree)/Drivers/PB5700/HAL_Lib/src/hal_amisc.c \
- $(srctree)/Drivers/PB5700/HAL_Lib/src/hal_comp.c \
- $(srctree)/Drivers/PB5700/HAL_Lib/src/hal_opamp.c \
- $(srctree)/Drivers/PB5700/HAL_Lib/src/hal_crc.c \
- $(srctree)/Drivers/PB5700/HAL_Lib/src/hal_dsp.c \
- $(srctree)/Drivers/PB5700/HAL_Lib/src/hal_flash.c \
- $(srctree)/Drivers/PB5700/HAL_Lib/src/hal_gpio.c \
- $(srctree)/Drivers/PB5700/HAL_Lib/src/hal_i2c.c \
- $(srctree)/Drivers/PB5700/HAL_Lib/src/hal_lptim.c \
- $(srctree)/Drivers/PB5700/HAL_Lib/src/hal_pwr.c \
- $(srctree)/Drivers/PB5700/HAL_Lib/src/hal_spi.c \
- $(srctree)/Drivers/PB5700/HAL_Lib/src/hal_syscfg.c \
- $(srctree)/Drivers/PB5700/HAL_Lib/src/hal_tim.c \
- $(srctree)/Drivers/PB5700/HAL_Lib/src/hal_uart.c \
- $(srctree)/Drivers/PB5700/HAL_Lib/src/hal_wdg.c \
- $(srctree)/Drivers/PB5700/HAL_Lib/src/hal_device.c
-
-C_INCLUDES += \
- -I$(srctree)/Drivers/PB5700/HAL_Lib/inc
-
-#=======================================
-# BSP
-#=======================================
-C_SOURCES += $(srctree)/Drivers/PB5700/BSP/StarterKit/starterkit.c
-
-C_INCLUDES += \
- -I$(srctree)/Drivers/PB5700/BSP/StarterKit
-
-#=======================================
-# Flags
-#=======================================
-CFLAGS += $(CPU_FLAGS)
-CXXFLAGS +=
-LDFLAGS += $(CPU_FLAGS)
-LIBDIR +=
diff --git a/Drivers/PB5700/BSP/StarterKit/starterkit.c b/Drivers/PEC930/BSP/StarterKit/starterkit.c
similarity index 100%
rename from Drivers/PB5700/BSP/StarterKit/starterkit.c
rename to Drivers/PEC930/BSP/StarterKit/starterkit.c
diff --git a/Drivers/PB5700/BSP/StarterKit/starterkit.h b/Drivers/PEC930/BSP/StarterKit/starterkit.h
similarity index 100%
rename from Drivers/PB5700/BSP/StarterKit/starterkit.h
rename to Drivers/PEC930/BSP/StarterKit/starterkit.h
diff --git a/Drivers/PB5700/Device/inc/SVD/PB5700.svd b/Drivers/PEC930/Device/inc/SVD/PEC930.svd
similarity index 97%
rename from Drivers/PB5700/Device/inc/SVD/PB5700.svd
rename to Drivers/PEC930/Device/inc/SVD/PEC930.svd
index 7d8d6ac..33afe1c 100644
--- a/Drivers/PB5700/Device/inc/SVD/PB5700.svd
+++ b/Drivers/PEC930/Device/inc/SVD/PEC930.svd
@@ -1,9 +1,9 @@
Padauk-tech
- PB5700
+ PEC930
1.0
- PB5700 uses 32-bits RISC-V CPU
+ RISC-V 32-bits CPU
8
32
32
@@ -139,7 +139,7 @@
UID
Universally Unique Identifier
- 0x00201EB0
+ 0x00201F00
0
0xC
@@ -7993,6 +7993,25 @@
0xFFFFFFFF
read-write
+
+ LDO_SEL
+ HSI power source selection
+ 0
+ 16
+ read-write
+
+
+ LDO
+ ldo_oschf Disable abd vddl_oschf from ldo
+ 0x8080
+
+
+ Normal
+ do_oschf Enable and vddl_oschf from ldo_oschf
+ 0x0101
+
+
+
HSI_EN
HSI enable, set 0x80(disable), set 0x1(enable)
@@ -8040,6 +8059,163 @@
+
+ HWTRIM
+ H/w configure trim values
+ 0x40005860
+
+ 0
+ 0x20
+ registers
+
+
+
+
+ LDO_TRIM
+ LDO trim value
+ 0x00
+ 32
+ 0x0
+ 0xFFFFFFFF
+ read-only
+
+
+ LDO_TRIM
+ LDO trim value
+ 0
+ 5
+ read-only
+
+
+ LDO_LP_TRIM
+ LDO lower power trim value
+ 5
+ 5
+ read-only
+
+
+ LDO_TUNE
+ Ldo high temp leakage current compensation
+ 10
+ 2
+ read-only
+
+
+ STRENGTH
+ strength
+ 0x0
+
+
+ WEAK
+ weak
+ 0x1
+
+
+ MIDDLEddle
+ middle
+ 0x2
+
+
+ OFF
+ off
+ 0x3
+
+
+
+
+
+
+
+ VBUF_TRIM
+ Vbuf trim value
+ 0x04
+ 32
+ 0
+ 0xFFFFFFFF
+ read-only
+
+
+ VBUF_TRIM
+ VBUF voltage trim value
+ 0
+ 7
+ read-only
+
+
+
+
+ HSI_TRIM
+ High Speed Internal clock (OSCHF) trim value
+ 0x08
+ 32
+ 0
+ 0xFFFFFFFF
+ read-only
+
+
+ HSI_D_CFG
+ HSI low trim config
+ 0
+ 9
+ read-only
+
+
+ HSI_FSEL_CFG
+ HSI high trim config
+ 9
+ 7
+ read-only
+
+
+ HSI_TC
+ The TC of HSI trim value
+ 16
+ 2
+ read-only
+
+
+
+
+
+ LSI_TRIM
+ Low Speed Internal clock (OSCLF) trim value
+ 0x0C
+ 32
+ 0
+ 0xFFFFFFFF
+ read-only
+
+
+ LSI_TRIM
+ The LSI trim value, 0xB3= 32KHz
+ 0
+ 8
+ read-only
+
+
+
+
+ MISC_CFG
+ The miscellaneous configuration
+ 0x10
+ 32
+ 0
+ 0xFFFFFFFF
+ read-only
+
+
+ EXT_nRST_EN
+ External reset pin enable
+ 0
+ 1
+ read-only
+
+
+
+
+
+
+
CRC
Cyclic redundancy check
@@ -9161,6 +9337,42 @@
7
1
+
+ CCD1IE
+ Capture/Compare 1 interrupt enable
+ 8
+ 1
+
+
+ CCD2IE
+ Capture/Compare 2 interrupt enable
+ 9
+ 1
+
+
+ CCD3IE
+ Capture/Compare 3 interrupt enable
+ 10
+ 1
+
+
+ OVIE
+ Overflow interrupt enable
+ 11
+ 1
+
+
+ UDIE
+ Underflow interrupt enable
+ 12
+ 1
+
+
+ CCD4IE
+ Capture/Compare 4 interrupt enable
+ 13
+ 1
+
@@ -9247,6 +9459,42 @@
1
read-write
+
+ CCD1IF
+ Capture/Compare 1 interrupt flag
+ 13
+ 1
+
+
+ CCD2IF
+ Capture/Compare 2 interrupt flag
+ 14
+ 1
+
+
+ CCD3IF
+ Capture/Compare 3 interrupt flag
+ 15
+ 1
+
+
+ OVIF
+ Overflow interrupt flag
+ 16
+ 1
+
+
+ UDIF
+ Underflow interrupt flag
+ 17
+ 1
+
+
+ CCD4IF
+ Break interrupt flag
+ 18
+ 1
+
@@ -9854,7 +10102,7 @@
0xFFFFFFFF
- CCR1
+ CCDR1
Down Capture/Compare 1 value
0
20
@@ -9870,7 +10118,7 @@
0xFFFFFFFF
- CCR2
+ CCDR2
Down Capture/Compare 2 value
0
20
@@ -9886,13 +10134,29 @@
0xFFFFFFFF
- CCR3
+ CCDR3
Down Capture/Compare 3 value
0
20
+
+ CCDR4
+ CR4 down capture or compare value
+ 0X5C
+ 32
+ 0x0
+ 0xFFFFFFFF
+
+
+ CCDR4
+ Down Capture/Compare 4 value
+ 0
+ 20
+
+
+
diff --git a/Drivers/PB5700/Device/inc/pb57xx.h b/Drivers/PEC930/Device/inc/device.h
similarity index 89%
rename from Drivers/PB5700/Device/inc/pb57xx.h
rename to Drivers/PEC930/Device/inc/device.h
index d8a65a3..37ae097 100644
--- a/Drivers/PB5700/Device/inc/pb57xx.h
+++ b/Drivers/PEC930/Device/inc/device.h
@@ -1,7 +1,7 @@
/**
* Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
*/
-/** @file pb57xx.h
+/** @file device.h
*
* @author Wei-Lun Hsu
* @version 0.1
@@ -10,15 +10,15 @@
* @description
*/
-#ifndef __pb57xx_H_wqIH3HdS_l3C8_Hgh6_syur_ubmEVDiPX8aR__
-#define __pb57xx_H_wqIH3HdS_l3C8_Hgh6_syur_ubmEVDiPX8aR__
+#ifndef __device_H_wqIH3HdS_l3C8_Hgh6_syur_ubmEVDiPX8aR__
+#define __device_H_wqIH3HdS_l3C8_Hgh6_syur_ubmEVDiPX8aR__
#ifdef __cplusplus
extern "C" {
#endif
-#if defined(CONFIG_USE_PB5700)
- #include "pb5700.h"
+#if defined(CONFIG_USE_PEC930)
+ #include "pec930.h"
#else
#error "Please select first the target device !"
#endif
diff --git a/Drivers/PB5700/Device/inc/pb5700.h b/Drivers/PEC930/Device/inc/pec930.h
similarity index 97%
rename from Drivers/PB5700/Device/inc/pb5700.h
rename to Drivers/PEC930/Device/inc/pec930.h
index efe341a..446a644 100644
--- a/Drivers/PB5700/Device/inc/pb5700.h
+++ b/Drivers/PEC930/Device/inc/pec930.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009-2019 Paduak-Tech. All rights reserved.
+ * Copyright (c) 2024-2025 Paduak-Tech. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
@@ -15,13 +15,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
- * @file PB5700.h
+ * @file PEC930.h
* @brief CMSIS HeaderFile
* @version 1.0
- * @date 23. September 2025
- * @note Generated by SVDConv V3.3.38 on Tuesday, 23.09.2025 12:30:25
- * from File './PB5700.svd',
- * last modified on Tuesday, 23.09.2025 04:19:56
+ * @date 27. November 2025
+ * @note Generated by SVDConv V3.3.38 on Thursday, 27.11.2025 08:40:32
+ * from File './PEC930.svd',
+ * last modified on Wednesday, 26.11.2025 09:47:40
*/
@@ -31,13 +31,13 @@
*/
-/** @addtogroup PB5700
+/** @addtogroup PEC930
* @{
*/
-#ifndef PB5700_H
-#define PB5700_H
+#ifndef PEC930_H
+#define PEC930_H
#ifdef __cplusplus
extern "C" {
@@ -55,7 +55,7 @@ extern "C" {
/* =========================================================================================================================== */
typedef enum {
-/* =========================================== PB5700 Specific Interrupt Numbers =========================================== */
+/* =========================================== PEC930 Specific Interrupt Numbers =========================================== */
SysSW_IRQn = 3, /*!< 3 System Software interrupt */
SysTimer_IRQn = 7, /*!< 7 System Timer interrupt */
BusError_IRQn = 17, /*!< 17 Bus error interrupt */
@@ -302,7 +302,7 @@ typedef struct { /*!< (@ 0x18000000) CORET Struct
* @brief Universally Unique Identifier (UID)
*/
-typedef struct { /*!< (@ 0x00201EB0) UID Structure */
+typedef struct { /*!< (@ 0x00201F00) UID Structure */
__IM uint32_t UID1; /*!< (@ 0x00000000) Unique Identifier 1 */
__IM uint32_t UID2; /*!< (@ 0x00000004) Unique Identifier 2 */
__IM uint32_t UID3; /*!< (@ 0x00000008) Unique Identifier 3 */
@@ -2065,7 +2065,8 @@ typedef struct { /*!< (@ 0x40005800) AMISC Struct
__IOM uint32_t HSI_CR; /*!< (@ 0x00000020) HSI (OSCHF) Control Register */
struct {
- uint32_t : 24;
+ __IOM uint32_t LDO_SEL : 16; /*!< [15..0] HSI power source selection */
+ uint32_t : 8;
__IOM uint32_t HSI_EN : 8; /*!< [31..24] HSI enable, set 0x80(disable), set 0x1(enable) */
} HSI_CR_b;
} ;
@@ -2092,6 +2093,69 @@ typedef struct { /*!< (@ 0x40005800) AMISC Struct
+/* =========================================================================================================================== */
+/* ================ HWTRIM ================ */
+/* =========================================================================================================================== */
+
+
+/**
+ * @brief H/w configure trim values (HWTRIM)
+ */
+
+typedef struct { /*!< (@ 0x40005860) HWTRIM Structure */
+
+ union {
+ __IM uint32_t LDO_TRIM; /*!< (@ 0x00000000) LDO trim value */
+
+ struct {
+ __IM uint32_t LDO_TRIM : 5; /*!< [4..0] LDO trim value */
+ __IM uint32_t LDO_LP_TRIM : 5; /*!< [9..5] LDO lower power trim value */
+ __IM uint32_t LDO_TUNE : 2; /*!< [11..10] Ldo high temp leakage current compensation */
+ uint32_t : 20;
+ } LDO_TRIM_b;
+ } ;
+
+ union {
+ __IM uint32_t VBUF_TRIM; /*!< (@ 0x00000004) Vbuf trim value */
+
+ struct {
+ __IM uint32_t VBUF_TRIM : 7; /*!< [6..0] VBUF voltage trim value */
+ uint32_t : 25;
+ } VBUF_TRIM_b;
+ } ;
+
+ union {
+ __IM uint32_t HSI_TRIM; /*!< (@ 0x00000008) High Speed Internal clock (OSCHF) trim value */
+
+ struct {
+ __IM uint32_t HSI_D_CFG : 9; /*!< [8..0] HSI low trim config */
+ __IM uint32_t HSI_FSEL_CFG : 7; /*!< [15..9] HSI high trim config */
+ __IM uint32_t HSI_TC : 2; /*!< [17..16] The TC of HSI trim value */
+ uint32_t : 14;
+ } HSI_TRIM_b;
+ } ;
+
+ union {
+ __IM uint32_t LSI_TRIM; /*!< (@ 0x0000000C) Low Speed Internal clock (OSCLF) trim value */
+
+ struct {
+ __IM uint32_t LSI_TRIM : 8; /*!< [7..0] The LSI trim value, 0xB3= 32KHz */
+ uint32_t : 24;
+ } LSI_TRIM_b;
+ } ;
+
+ union {
+ __IM uint32_t MISC_CFG; /*!< (@ 0x00000010) The miscellaneous configuration */
+
+ struct {
+ __IM uint32_t EXT_nRST_EN : 1; /*!< [0..0] External reset pin enable */
+ uint32_t : 31;
+ } MISC_CFG_b;
+ } ;
+} HWTRIM_Type; /*!< Size = 20 (0x14) */
+
+
+
/* =========================================================================================================================== */
/* ================ CRC ================ */
/* =========================================================================================================================== */
@@ -2344,7 +2408,13 @@ typedef struct { /*!< (@ 0x4000C000) TIM Structur
__IOM uint32_t COMIE : 1; /*!< [5..5] COM interrupt enable */
__IOM uint32_t TIE : 1; /*!< [6..6] Trigger interrupt enable */
__IOM uint32_t BIE : 1; /*!< [7..7] Break interrupt enable */
- uint32_t : 24;
+ __IOM uint32_t CCD1IE : 1; /*!< [8..8] Capture/Compare 1 interrupt enable */
+ __IOM uint32_t CCD2IE : 1; /*!< [9..9] Capture/Compare 2 interrupt enable */
+ __IOM uint32_t CCD3IE : 1; /*!< [10..10] Capture/Compare 3 interrupt enable */
+ __IOM uint32_t OVIE : 1; /*!< [11..11] Overflow interrupt enable */
+ __IOM uint32_t UDIE : 1; /*!< [12..12] Underflow interrupt enable */
+ __IOM uint32_t CCD4IE : 1; /*!< [13..13] Capture/Compare 4 interrupt enable */
+ uint32_t : 18;
} DIER_b;
} ;
@@ -2365,7 +2435,13 @@ typedef struct { /*!< (@ 0x4000C000) TIM Structur
__IOM uint32_t CC2OF : 1; /*!< [10..10] CC2OF */
__IOM uint32_t CC3OF : 1; /*!< [11..11] CC3OF */
__IOM uint32_t CC4OF : 1; /*!< [12..12] CC4OF */
- uint32_t : 19;
+ __IOM uint32_t CCD1IF : 1; /*!< [13..13] Capture/Compare 1 interrupt flag */
+ __IOM uint32_t CCD2IF : 1; /*!< [14..14] Capture/Compare 2 interrupt flag */
+ __IOM uint32_t CCD3IF : 1; /*!< [15..15] Capture/Compare 3 interrupt flag */
+ __IOM uint32_t OVIF : 1; /*!< [16..16] Overflow interrupt flag */
+ __IOM uint32_t UDIF : 1; /*!< [17..17] Underflow interrupt flag */
+ __IOM uint32_t CCD4IF : 1; /*!< [18..18] Break interrupt flag */
+ uint32_t : 13;
} SR_b;
} ;
@@ -2570,7 +2646,7 @@ typedef struct { /*!< (@ 0x4000C000) TIM Structur
__IOM uint32_t CCDR1; /*!< (@ 0x00000050) CR1 down capture or compare value */
struct {
- __IOM uint32_t CCR1 : 20; /*!< [19..0] Down Capture/Compare 1 value */
+ __IOM uint32_t CCDR1 : 20; /*!< [19..0] Down Capture/Compare 1 value */
uint32_t : 12;
} CCDR1_b;
} ;
@@ -2579,7 +2655,7 @@ typedef struct { /*!< (@ 0x4000C000) TIM Structur
__IOM uint32_t CCDR2; /*!< (@ 0x00000054) CR2 down capture or compare value */
struct {
- __IOM uint32_t CCR2 : 20; /*!< [19..0] Down Capture/Compare 2 value */
+ __IOM uint32_t CCDR2 : 20; /*!< [19..0] Down Capture/Compare 2 value */
uint32_t : 12;
} CCDR2_b;
} ;
@@ -2588,11 +2664,20 @@ typedef struct { /*!< (@ 0x4000C000) TIM Structur
__IOM uint32_t CCDR3; /*!< (@ 0x00000058) CR3 down capture or compare value */
struct {
- __IOM uint32_t CCR3 : 20; /*!< [19..0] Down Capture/Compare 3 value */
+ __IOM uint32_t CCDR3 : 20; /*!< [19..0] Down Capture/Compare 3 value */
uint32_t : 12;
} CCDR3_b;
} ;
-} TIM_Type; /*!< Size = 92 (0x5c) */
+
+ union {
+ __IOM uint32_t CCDR4; /*!< (@ 0x0000005C) CR4 down capture or compare value */
+
+ struct {
+ __IOM uint32_t CCDR4 : 20; /*!< [19..0] Down Capture/Compare 4 value */
+ uint32_t : 12;
+ } CCDR4_b;
+ } ;
+} TIM_Type; /*!< Size = 96 (0x60) */
@@ -2693,7 +2778,7 @@ typedef struct { /*!< (@ 0x4000C800) LPTIM Struct
#define SRAM_MEM_BASE 0x20000000UL
#define NVR_MEM_BASE 0x00200000UL
#define CORET_BASE 0x18000000UL
-#define UID_BASE 0x00201EB0UL
+#define UID_BASE 0x00201F00UL
#define FLASH_BASE 0x4000F800UL
#define GPIO_BASE 0x40011000UL
#define GPIOA_BASE 0x40011000UL
@@ -2710,6 +2795,7 @@ typedef struct { /*!< (@ 0x4000C800) LPTIM Struct
#define ADC_BASE 0x40004800UL
#define ADC0_BASE 0x40004800UL
#define AMISC_BASE 0x40005800UL
+#define HWTRIM_BASE 0x40005860UL
#define CRC_BASE 0x4001E000UL
#define DSP_BASE 0x40008000UL
#define OPAMP_BASE 0x40005880UL
@@ -2758,6 +2844,7 @@ typedef struct { /*!< (@ 0x4000C800) LPTIM Struct
#define ADC ((ADC_Type*) ADC_BASE)
#define ADC0 ((ADC_Type*) ADC0_BASE)
#define AMISC ((AMISC_Type*) AMISC_BASE)
+#define HWTRIM ((HWTRIM_Type*) HWTRIM_BASE)
#define CRC ((CRC_Type*) CRC_BASE)
#define DSP ((DSP_Type*) DSP_BASE)
#define OPAMP ((OPAMP_Type*) OPAMP_BASE)
@@ -4515,6 +4602,8 @@ typedef struct { /*!< (@ 0x4000C800) LPTIM Struct
#define AMISC_DAC_CR_DAC1_EN_Pos (21UL) /*!< DAC1_EN (Bit 21) */
#define AMISC_DAC_CR_DAC1_EN_Msk (0x200000UL) /*!< DAC1_EN (Bitfield-Mask: 0x01) */
/* ======================================================== HSI_CR ========================================================= */
+#define AMISC_HSI_CR_LDO_SEL_Pos (0UL) /*!< LDO_SEL (Bit 0) */
+#define AMISC_HSI_CR_LDO_SEL_Msk (0xffffUL) /*!< LDO_SEL (Bitfield-Mask: 0xffff) */
#define AMISC_HSI_CR_HSI_EN_Pos (24UL) /*!< HSI_EN (Bit 24) */
#define AMISC_HSI_CR_HSI_EN_Msk (0xff000000UL) /*!< HSI_EN (Bitfield-Mask: 0xff) */
/* ======================================================== LSI_CR ========================================================= */
@@ -4525,6 +4614,35 @@ typedef struct { /*!< (@ 0x4000C800) LPTIM Struct
#define AMISC_ADC_AIN_CR_ANA2ADC_EN_Msk (0x1UL) /*!< ANA2ADC_EN (Bitfield-Mask: 0x01) */
+/* =========================================================================================================================== */
+/* ================ HWTRIM ================ */
+/* =========================================================================================================================== */
+
+/* ======================================================= LDO_TRIM ======================================================== */
+#define HWTRIM_LDO_TRIM_LDO_TRIM_Pos (0UL) /*!< LDO_TRIM (Bit 0) */
+#define HWTRIM_LDO_TRIM_LDO_TRIM_Msk (0x1fUL) /*!< LDO_TRIM (Bitfield-Mask: 0x1f) */
+#define HWTRIM_LDO_TRIM_LDO_LP_TRIM_Pos (5UL) /*!< LDO_LP_TRIM (Bit 5) */
+#define HWTRIM_LDO_TRIM_LDO_LP_TRIM_Msk (0x3e0UL) /*!< LDO_LP_TRIM (Bitfield-Mask: 0x1f) */
+#define HWTRIM_LDO_TRIM_LDO_TUNE_Pos (10UL) /*!< LDO_TUNE (Bit 10) */
+#define HWTRIM_LDO_TRIM_LDO_TUNE_Msk (0xc00UL) /*!< LDO_TUNE (Bitfield-Mask: 0x03) */
+/* ======================================================= VBUF_TRIM ======================================================= */
+#define HWTRIM_VBUF_TRIM_VBUF_TRIM_Pos (0UL) /*!< VBUF_TRIM (Bit 0) */
+#define HWTRIM_VBUF_TRIM_VBUF_TRIM_Msk (0x7fUL) /*!< VBUF_TRIM (Bitfield-Mask: 0x7f) */
+/* ======================================================= HSI_TRIM ======================================================== */
+#define HWTRIM_HSI_TRIM_HSI_D_CFG_Pos (0UL) /*!< HSI_D_CFG (Bit 0) */
+#define HWTRIM_HSI_TRIM_HSI_D_CFG_Msk (0x1ffUL) /*!< HSI_D_CFG (Bitfield-Mask: 0x1ff) */
+#define HWTRIM_HSI_TRIM_HSI_FSEL_CFG_Pos (9UL) /*!< HSI_FSEL_CFG (Bit 9) */
+#define HWTRIM_HSI_TRIM_HSI_FSEL_CFG_Msk (0xfe00UL) /*!< HSI_FSEL_CFG (Bitfield-Mask: 0x7f) */
+#define HWTRIM_HSI_TRIM_HSI_TC_Pos (16UL) /*!< HSI_TC (Bit 16) */
+#define HWTRIM_HSI_TRIM_HSI_TC_Msk (0x30000UL) /*!< HSI_TC (Bitfield-Mask: 0x03) */
+/* ======================================================= LSI_TRIM ======================================================== */
+#define HWTRIM_LSI_TRIM_LSI_TRIM_Pos (0UL) /*!< LSI_TRIM (Bit 0) */
+#define HWTRIM_LSI_TRIM_LSI_TRIM_Msk (0xffUL) /*!< LSI_TRIM (Bitfield-Mask: 0xff) */
+/* ======================================================= MISC_CFG ======================================================== */
+#define HWTRIM_MISC_CFG_EXT_nRST_EN_Pos (0UL) /*!< EXT_nRST_EN (Bit 0) */
+#define HWTRIM_MISC_CFG_EXT_nRST_EN_Msk (0x1UL) /*!< EXT_nRST_EN (Bitfield-Mask: 0x01) */
+
+
/* =========================================================================================================================== */
/* ================ CRC ================ */
/* =========================================================================================================================== */
@@ -4690,6 +4808,18 @@ typedef struct { /*!< (@ 0x4000C800) LPTIM Struct
#define TIM_DIER_TIE_Msk (0x40UL) /*!< TIE (Bitfield-Mask: 0x01) */
#define TIM_DIER_BIE_Pos (7UL) /*!< BIE (Bit 7) */
#define TIM_DIER_BIE_Msk (0x80UL) /*!< BIE (Bitfield-Mask: 0x01) */
+#define TIM_DIER_CCD1IE_Pos (8UL) /*!< CCD1IE (Bit 8) */
+#define TIM_DIER_CCD1IE_Msk (0x100UL) /*!< CCD1IE (Bitfield-Mask: 0x01) */
+#define TIM_DIER_CCD2IE_Pos (9UL) /*!< CCD2IE (Bit 9) */
+#define TIM_DIER_CCD2IE_Msk (0x200UL) /*!< CCD2IE (Bitfield-Mask: 0x01) */
+#define TIM_DIER_CCD3IE_Pos (10UL) /*!< CCD3IE (Bit 10) */
+#define TIM_DIER_CCD3IE_Msk (0x400UL) /*!< CCD3IE (Bitfield-Mask: 0x01) */
+#define TIM_DIER_OVIE_Pos (11UL) /*!< OVIE (Bit 11) */
+#define TIM_DIER_OVIE_Msk (0x800UL) /*!< OVIE (Bitfield-Mask: 0x01) */
+#define TIM_DIER_UDIE_Pos (12UL) /*!< UDIE (Bit 12) */
+#define TIM_DIER_UDIE_Msk (0x1000UL) /*!< UDIE (Bitfield-Mask: 0x01) */
+#define TIM_DIER_CCD4IE_Pos (13UL) /*!< CCD4IE (Bit 13) */
+#define TIM_DIER_CCD4IE_Msk (0x2000UL) /*!< CCD4IE (Bitfield-Mask: 0x01) */
/* ========================================================== SR =========================================================== */
#define TIM_SR_UIF_Pos (0UL) /*!< UIF (Bit 0) */
#define TIM_SR_UIF_Msk (0x1UL) /*!< UIF (Bitfield-Mask: 0x01) */
@@ -4715,6 +4845,18 @@ typedef struct { /*!< (@ 0x4000C800) LPTIM Struct
#define TIM_SR_CC3OF_Msk (0x800UL) /*!< CC3OF (Bitfield-Mask: 0x01) */
#define TIM_SR_CC4OF_Pos (12UL) /*!< CC4OF (Bit 12) */
#define TIM_SR_CC4OF_Msk (0x1000UL) /*!< CC4OF (Bitfield-Mask: 0x01) */
+#define TIM_SR_CCD1IF_Pos (13UL) /*!< CCD1IF (Bit 13) */
+#define TIM_SR_CCD1IF_Msk (0x2000UL) /*!< CCD1IF (Bitfield-Mask: 0x01) */
+#define TIM_SR_CCD2IF_Pos (14UL) /*!< CCD2IF (Bit 14) */
+#define TIM_SR_CCD2IF_Msk (0x4000UL) /*!< CCD2IF (Bitfield-Mask: 0x01) */
+#define TIM_SR_CCD3IF_Pos (15UL) /*!< CCD3IF (Bit 15) */
+#define TIM_SR_CCD3IF_Msk (0x8000UL) /*!< CCD3IF (Bitfield-Mask: 0x01) */
+#define TIM_SR_OVIF_Pos (16UL) /*!< OVIF (Bit 16) */
+#define TIM_SR_OVIF_Msk (0x10000UL) /*!< OVIF (Bitfield-Mask: 0x01) */
+#define TIM_SR_UDIF_Pos (17UL) /*!< UDIF (Bit 17) */
+#define TIM_SR_UDIF_Msk (0x20000UL) /*!< UDIF (Bitfield-Mask: 0x01) */
+#define TIM_SR_CCD4IF_Pos (18UL) /*!< CCD4IF (Bit 18) */
+#define TIM_SR_CCD4IF_Msk (0x40000UL) /*!< CCD4IF (Bitfield-Mask: 0x01) */
/* ========================================================== EGR ========================================================== */
#define TIM_EGR_UG_Pos (0UL) /*!< UG (Bit 0) */
#define TIM_EGR_UG_Msk (0x1UL) /*!< UG (Bitfield-Mask: 0x01) */
@@ -4875,14 +5017,17 @@ typedef struct { /*!< (@ 0x4000C800) LPTIM Struct
#define TIM_BDTR_DTAE_Pos (24UL) /*!< DTAE (Bit 24) */
#define TIM_BDTR_DTAE_Msk (0x1000000UL) /*!< DTAE (Bitfield-Mask: 0x01) */
/* ========================================================= CCDR1 ========================================================= */
-#define TIM_CCDR1_CCR1_Pos (0UL) /*!< CCR1 (Bit 0) */
-#define TIM_CCDR1_CCR1_Msk (0xfffffUL) /*!< CCR1 (Bitfield-Mask: 0xfffff) */
+#define TIM_CCDR1_CCDR1_Pos (0UL) /*!< CCDR1 (Bit 0) */
+#define TIM_CCDR1_CCDR1_Msk (0xfffffUL) /*!< CCDR1 (Bitfield-Mask: 0xfffff) */
/* ========================================================= CCDR2 ========================================================= */
-#define TIM_CCDR2_CCR2_Pos (0UL) /*!< CCR2 (Bit 0) */
-#define TIM_CCDR2_CCR2_Msk (0xfffffUL) /*!< CCR2 (Bitfield-Mask: 0xfffff) */
+#define TIM_CCDR2_CCDR2_Pos (0UL) /*!< CCDR2 (Bit 0) */
+#define TIM_CCDR2_CCDR2_Msk (0xfffffUL) /*!< CCDR2 (Bitfield-Mask: 0xfffff) */
/* ========================================================= CCDR3 ========================================================= */
-#define TIM_CCDR3_CCR3_Pos (0UL) /*!< CCR3 (Bit 0) */
-#define TIM_CCDR3_CCR3_Msk (0xfffffUL) /*!< CCR3 (Bitfield-Mask: 0xfffff) */
+#define TIM_CCDR3_CCDR3_Pos (0UL) /*!< CCDR3 (Bit 0) */
+#define TIM_CCDR3_CCDR3_Msk (0xfffffUL) /*!< CCDR3 (Bitfield-Mask: 0xfffff) */
+/* ========================================================= CCDR4 ========================================================= */
+#define TIM_CCDR4_CCDR4_Pos (0UL) /*!< CCDR4 (Bit 0) */
+#define TIM_CCDR4_CCDR4_Msk (0xfffffUL) /*!< CCDR4 (Bitfield-Mask: 0xfffff) */
/* =========================================================================================================================== */
@@ -5642,10 +5787,35 @@ typedef enum { /*!< AMISC_VBUF_CR_ANA_SEL
/* ======================================================== DAC_CR ========================================================= */
/* ======================================================== HSI_CR ========================================================= */
+/* ============================================= AMISC HSI_CR LDO_SEL [0..15] ============================================== */
+typedef enum { /*!< AMISC_HSI_CR_LDO_SEL */
+ AMISC_HSI_CR_LDO_SEL_LDO = 32896, /*!< LDO : ldo_oschf Disable abd vddl_oschf from ldo */
+ AMISC_HSI_CR_LDO_SEL_Normal = 257, /*!< Normal : do_oschf Enable and vddl_oschf from ldo_oschf */
+} AMISC_HSI_CR_LDO_SEL_Enum;
+
/* ======================================================== LSI_CR ========================================================= */
/* ====================================================== ADC_AIN_CR ======================================================= */
+/* =========================================================================================================================== */
+/* ================ HWTRIM ================ */
+/* =========================================================================================================================== */
+
+/* ======================================================= LDO_TRIM ======================================================== */
+/* =========================================== HWTRIM LDO_TRIM LDO_TUNE [10..11] =========================================== */
+typedef enum { /*!< HWTRIM_LDO_TRIM_LDO_TUNE */
+ HWTRIM_LDO_TRIM_LDO_TUNE_STRENGTH = 0, /*!< STRENGTH : strength */
+ HWTRIM_LDO_TRIM_LDO_TUNE_WEAK = 1, /*!< WEAK : weak */
+ HWTRIM_LDO_TRIM_LDO_TUNE_MIDDLEddle = 2, /*!< MIDDLEddle : middle */
+ HWTRIM_LDO_TRIM_LDO_TUNE_OFF = 3, /*!< OFF : off */
+} HWTRIM_LDO_TRIM_LDO_TUNE_Enum;
+
+/* ======================================================= VBUF_TRIM ======================================================= */
+/* ======================================================= HSI_TRIM ======================================================== */
+/* ======================================================= LSI_TRIM ======================================================== */
+/* ======================================================= MISC_CFG ======================================================== */
+
+
/* =========================================================================================================================== */
/* ================ CRC ================ */
/* =========================================================================================================================== */
@@ -5858,6 +6028,7 @@ typedef enum { /*!< TIM_SMCR_ETF
/* ========================================================= CCDR1 ========================================================= */
/* ========================================================= CCDR2 ========================================================= */
/* ========================================================= CCDR3 ========================================================= */
+/* ========================================================= CCDR4 ========================================================= */
/* =========================================================================================================================== */
@@ -5896,9 +6067,9 @@ typedef enum { /*!< LPTIM_TCR_TRIGSEL
}
#endif
-#endif /* PB5700_H */
+#endif /* PEC930_H */
-/** @} */ /* End of group PB5700 */
+/** @} */ /* End of group PEC930 */
/** @} */ /* End of group Padauk-tech */
diff --git a/Drivers/PB5700/Device/inc/system_dev.h b/Drivers/PEC930/Device/inc/system_dev.h
similarity index 96%
rename from Drivers/PB5700/Device/inc/system_dev.h
rename to Drivers/PEC930/Device/inc/system_dev.h
index 4ad3baf..cd3367e 100644
--- a/Drivers/PB5700/Device/inc/system_dev.h
+++ b/Drivers/PEC930/Device/inc/system_dev.h
@@ -154,14 +154,6 @@ typedef struct excp_frame
uint32_t cause; /* cause: machine cause csr register */
uint32_t epc; /* epc: machine exception program counter csr register */
uint32_t msubm; /* msubm: machine sub-mode csr register, nuclei customized */
-#ifndef __riscv_32e
- uint32_t a6; /* a6: x16, function argument 6 */
- uint32_t a7; /* a7: x17, function argument 7 */
- uint32_t t3; /* t3: x28, temporary register 3 */
- uint32_t t4; /* t4: x29, temporary register 4 */
- uint32_t t5; /* t5: x30, temporary register 5 */
- uint32_t t6; /* t6: x31, temporary register 6 */
-#endif
} excp_frame_t;
typedef struct sys_irq_attr
diff --git a/Drivers/PB5700/Device/src/Startup/startup.S b/Drivers/PEC930/Device/src/Startup/startup.S
similarity index 95%
rename from Drivers/PB5700/Device/src/Startup/startup.S
rename to Drivers/PEC930/Device/src/Startup/startup.S
index 1d59b32..18ad77a 100644
--- a/Drivers/PB5700/Device/src/Startup/startup.S
+++ b/Drivers/PEC930/Device/src/Startup/startup.S
@@ -50,6 +50,7 @@ _start:
la sp, _sp
#if 0
+ /* Disable/Enable ICE I/O */
li a0, 0x00001C28
li a1, 0x4000F804
li a2, 0x80000000
@@ -69,11 +70,6 @@ _start:
2:
#endif
- /**
- * Set the the NMI base mnvec to share
- * with mtvec by setting CSR_MMISC_CTL
- * bit 9 NMI_CAUSE_FFF to 1
- */
li t0, MMISC_CTL_NMI_CAUSE_FFF
csrs CSR_MMISC_CTL, t0
diff --git a/Drivers/PB5700/Device/src/Startup/trap.S b/Drivers/PEC930/Device/src/Startup/trap.S
similarity index 100%
rename from Drivers/PB5700/Device/src/Startup/trap.S
rename to Drivers/PEC930/Device/src/Startup/trap.S
diff --git a/Drivers/PB5700/Device/src/interrupt.c b/Drivers/PEC930/Device/src/interrupt.c
similarity index 80%
rename from Drivers/PB5700/Device/src/interrupt.c
rename to Drivers/PEC930/Device/src/interrupt.c
index af9297e..de50440 100644
--- a/Drivers/PB5700/Device/src/interrupt.c
+++ b/Drivers/PEC930/Device/src/interrupt.c
@@ -11,7 +11,7 @@
*/
-#include "pb57xx.h"
+#include "device.h"
//=============================================================================
// Constant Definition
//=============================================================================
@@ -116,22 +116,4 @@ const fp_isr_t __Vectors[__ECLIC_INTNUM] __USED __attribute__((section (".mintve
default_handler, /* 31: ext_irq Reserved */
default_handler, /* 32: ext_irq Reserved */
default_handler, /* 33: ext_irq Reserved */
-#if 0
- default_handler, /* 34: ext_irq Reserved */
- default_handler, /* 35: ext_irq Reserved */
- default_handler, /* 36: ext_irq Reserved */
- default_handler, /* 37: ext_irq Reserved */
- default_handler, /* 38: ext_irq Reserved */
- default_handler, /* 39: ext_irq Reserved */
- default_handler, /* 40: ext_irq Reserved */
- default_handler, /* 41: ext_irq Reserved */
- default_handler, /* 42: ext_irq Reserved */
- default_handler, /* 43: ext_irq Reserved */
- default_handler, /* 44: ext_irq Reserved */
- default_handler, /* 45: ext_irq Reserved */
- default_handler, /* 46: ext_irq Reserved */
- default_handler, /* 47: ext_irq Reserved */
- default_handler, /* 48: ext_irq Reserved */
- default_handler, /* 49: ext_irq Reserved */
-#endif
};
diff --git a/Drivers/PB5700/Device/src/syscalls.c b/Drivers/PEC930/Device/src/syscalls.c
similarity index 94%
rename from Drivers/PB5700/Device/src/syscalls.c
rename to Drivers/PEC930/Device/src/syscalls.c
index 92edc9f..5c9d0e9 100644
--- a/Drivers/PB5700/Device/src/syscalls.c
+++ b/Drivers/PEC930/Device/src/syscalls.c
@@ -197,18 +197,5 @@ __WEAK clock_t _times(struct tms *buf)
__WEAK void *_sbrk(ptrdiff_t incr)
{
-#if 0
- extern char _end[];
- extern char _heap_end[];
- static char *curbrk = _end;
-
- if ((curbrk + incr < _end) || (curbrk + incr > _heap_end)) {
- return (void *)(-1);
- }
-
- curbrk += incr;
- return (void *)(curbrk - incr);
-#else
return 0;
-#endif
}
diff --git a/Drivers/PB5700/Device/src/system_dev.c b/Drivers/PEC930/Device/src/system_dev.c
similarity index 99%
rename from Drivers/PB5700/Device/src/system_dev.c
rename to Drivers/PEC930/Device/src/system_dev.c
index caae90c..a9615e7 100644
--- a/Drivers/PB5700/Device/src/system_dev.c
+++ b/Drivers/PEC930/Device/src/system_dev.c
@@ -10,7 +10,7 @@
* @description
*/
-#include "pb57xx.h"
+#include "device.h"
//=============================================================================
// Constant Definition
//=============================================================================
diff --git a/Drivers/PB5700/HAL_Lib/inc/hal_adc.h b/Drivers/PEC930/HAL_Lib/inc/hal_adc.h
similarity index 90%
rename from Drivers/PB5700/HAL_Lib/inc/hal_adc.h
rename to Drivers/PEC930/HAL_Lib/inc/hal_adc.h
index c9a6953..0fec7fb 100644
--- a/Drivers/PB5700/HAL_Lib/inc/hal_adc.h
+++ b/Drivers/PEC930/HAL_Lib/inc/hal_adc.h
@@ -60,14 +60,14 @@ typedef enum ADC_Channels
*/
typedef enum ADC_SubChannel
{
- ADC_SubChannel_NONE = AMISC_VBUF_CR_ANA_SEL_NONE,
- ADC_SubChannel_TEMP = AMISC_VBUF_CR_ANA_SEL_TEMP,
- ADC_SubChannel_DAC0 = AMISC_VBUF_CR_ANA_SEL_DAC0,
- ADC_SubChannel_DAC1 = AMISC_VBUF_CR_ANA_SEL_DAC1,
- ADC_SubChannel_VBuf_1_5 = AMISC_VBUF_CR_ANA_SEL_VBuf_1p5v,
- ADC_SubChannel_VDDL = AMISC_VBUF_CR_ANA_SEL_VDDL,
- ADC_SubChannel_VSS = AMISC_VBUF_CR_ANA_SEL_VSS,
- ADC_SubChannel_VDD = AMISC_VBUF_CR_ANA_SEL_VDD,
+ ADC_SubChannel_NONE = (AMISC_VBUF_CR_ANA_SEL_NONE << AMISC_VBUF_CR_ANA_SEL_Pos),
+ ADC_SubChannel_TEMP = (AMISC_VBUF_CR_ANA_SEL_TEMP << AMISC_VBUF_CR_ANA_SEL_Pos),
+ ADC_SubChannel_DAC0 = (AMISC_VBUF_CR_ANA_SEL_DAC0 << AMISC_VBUF_CR_ANA_SEL_Pos),
+ ADC_SubChannel_DAC1 = (AMISC_VBUF_CR_ANA_SEL_DAC1 << AMISC_VBUF_CR_ANA_SEL_Pos),
+ ADC_SubChannel_VBuf_1_5 = (AMISC_VBUF_CR_ANA_SEL_VBuf_1p5v << AMISC_VBUF_CR_ANA_SEL_Pos),
+ ADC_SubChannel_VDDL = (AMISC_VBUF_CR_ANA_SEL_VDDL << AMISC_VBUF_CR_ANA_SEL_Pos),
+ ADC_SubChannel_VSS = (AMISC_VBUF_CR_ANA_SEL_VSS << AMISC_VBUF_CR_ANA_SEL_Pos),
+ ADC_SubChannel_VDD = (AMISC_VBUF_CR_ANA_SEL_VDD << AMISC_VBUF_CR_ANA_SEL_Pos),
} ADC_SubChannelTypeDef;
/**
@@ -132,8 +132,8 @@ typedef enum ADC_ExtTrigSource
ADC_ExtTrigSource_EPWM_CH2F = ADC_ExtTrigSource_04, /*!< ADC external source trigger from EPWM CH2 Falling */
ADC_ExtTrigSource_EPWM_CH3F = ADC_ExtTrigSource_05, /*!< ADC external source trigger from EPWM CH3 Falling */
ADC_ExtTrigSource_COMP0_Rise = ADC_ExtTrigSource_06, /*!< ADC external source trigger from COMP0 Rising */
- ADC_ExtTrigSource_COMP1_Rise = ADC_ExtTrigSource_07, /*!< ADC external source trigger from COMP1 Rising */
- ADC_ExtTrigSource_COMP0_Fall = ADC_ExtTrigSource_08, /*!< ADC external source trigger from COMP0 Falling */
+ ADC_ExtTrigSource_COMP1_Rise = ADC_ExtTrigSource_08, /*!< ADC external source trigger from COMP1 Rising */
+ ADC_ExtTrigSource_COMP0_Fall = ADC_ExtTrigSource_07, /*!< ADC external source trigger from COMP0 Falling */
ADC_ExtTrigSource_COMP1_Fall = ADC_ExtTrigSource_09, /*!< ADC external source trigger from COMP1 Falling */
ADC_ExtTrigSource_EPWM_UDF = ADC_ExtTrigSource_10, /*!< ADC external source trigger from EPWM Counter UDF */
ADC_ExtTrigSource_EPWM_OVF = ADC_ExtTrigSource_11, /*!< ADC external source trigger from EPWM Counter OVF */
@@ -182,6 +182,7 @@ typedef enum ADC_IT
*/
typedef enum ADC_ITStatus
{
+ ADC_ITStatus_None = (ADC_STAT_COMP_RESULT_NONE << ADC_STAT_COMP_RESULT_Pos),
ADC_ITStatus_LowerThreshold = (ADC_STAT_COMP_RESULT_LT_THR << ADC_STAT_COMP_RESULT_Pos),
ADC_ITStatus_HigherThreshold = (ADC_STAT_COMP_RESULT_GT_THR << ADC_STAT_COMP_RESULT_Pos),
ADC_ITStatus_EqualThreshold = (ADC_STAT_COMP_RESULT_EQ_THR << ADC_STAT_COMP_RESULT_Pos),
@@ -247,7 +248,7 @@ __STATIC_FORCEINLINE void ADC_Start(ADC_Type *pHADC)
*/
__STATIC_FORCEINLINE uint32_t ADC_IsIdle(ADC_Type *pHADC)
{
- return REG_READ_MASK(pHADC->CON0, ADC_STAT_DONE_Msk);
+ return REG_READ_MASK(pHADC->STAT, ADC_STAT_DONE_Msk);
}
/**
@@ -286,7 +287,7 @@ __STATIC_FORCEINLINE void ADC_ClearITFlag(ADC_Type *pHADC)
*/
__STATIC_FORCEINLINE void ADC_DiscMode_SetGroupSubsetNum(ADC_Type *pHADC, uint8_t subset_ch_num)
{
- REG_WRITE_MASK(pHADC->CHSEL, ADC_CHSEL_DISCNUM_Msk, subset_ch_num - 1);
+ REG_WRITE_MASK(pHADC->CHSEL, ADC_CHSEL_DISCNUM_Msk, (subset_ch_num - 1) << ADC_CHSEL_DISCNUM_Pos);
return;
}
@@ -333,19 +334,22 @@ __STATIC_FORCEINLINE uint16_t ADC_GetBakcupValue(ADC_Type *pHADC)
return (uint16_t)pHADC->BAKDAT_b.BAKDAT;
}
+
/**
- * \brief Select the sub-channel of the ADC Channel-15
+ * \brief Set the sample-period of an ADC
*
- * \param [in] subchannel The selected sub-channel of ADC channel-15, @ref ADC_SubChannelTypeDef
+ * \param [in] pHADC Pointer to an ADC handler
+ * \param [in] cycles extern cycles (range: 0 ~ 31, default: 3)
* \return
* None
*/
-__STATIC_FORCEINLINE void ADC_SelSubChannel(ADC_SubChannelTypeDef subchannel)
+__STATIC_FORCEINLINE void ADC_SetSampleCycles(ADC_Type *pHADC, uint8_t cycles)
{
- REG_WRITE_MASK(AMISC->VBUF_CR, AMISC_VBUF_CR_ANA_SEL_Msk, subchannel);
+ pHADC->STAT_b.TS_SET = cycles;
return;
}
+
/**
* \brief Get the conversion value of the ADC in ISR
*
@@ -364,6 +368,19 @@ __STATIC_FORCEINLINE uint16_t ADC_ITGetConvValue(ADC_Type *pHADC, ADC_ChannelsTy
return (uint16_t)((*pData) & 0xFFFFul);
}
+/**
+ * \brief Disable interrupt of ADC
+ *
+ * \param [in] pHADC Pointer to an ADC handler
+ * \return
+ * None
+ */
+__STATIC_FORCEINLINE void ADC_ITDisable(ADC_Type *pHADC)
+{
+ REG_WRITE_MASK(pHADC->CON0, ADC_CON0_INT_EN_Msk, ADC_IT_DISABLE);
+ return;
+}
+
//=============================================================================
// Structure Definition
//=============================================================================
@@ -442,6 +459,15 @@ void ADC_StructInit(ADC_InitTypeDef *pInit);
*/
void ADC_ExtTrigConfig(ADC_Type *pHADC, ADC_ExtTrigSourceTypeDef ext_src, ADC_ExtTrigModeTypeDef trig_mode);
+/**
+ * \brief Select the sub-channel of the ADC Channel-15
+ *
+ * \param [in] subchannel The selected sub-channel of ADC channel-15, @ref ADC_SubChannelTypeDef
+ * \return
+ * None
+ */
+void ADC_SelSubChannel(ADC_SubChannelTypeDef subchannel);
+
/**
* \brief Get the conversion value of an ADC channel
*
diff --git a/Drivers/PB5700/HAL_Lib/inc/hal_amisc.h b/Drivers/PEC930/HAL_Lib/inc/hal_amisc.h
similarity index 79%
rename from Drivers/PB5700/HAL_Lib/inc/hal_amisc.h
rename to Drivers/PEC930/HAL_Lib/inc/hal_amisc.h
index ac68d1b..8f336de 100644
--- a/Drivers/PB5700/HAL_Lib/inc/hal_amisc.h
+++ b/Drivers/PEC930/HAL_Lib/inc/hal_amisc.h
@@ -65,31 +65,22 @@ typedef enum
typedef enum
{
- AMISC_Ana2IO_Disable = 0x0, //AMISC_Ana2IO_En
- AMISC_Ana2IO_En = AMISC_VBUF_CR_ANA2IO_EN_Msk,
-
-} AMISC_Ana2IOTypeDef;
+ AMISC_InternalSrc_NONE = (AMISC_VBUF_CR_ANA_SEL_NONE << AMISC_VBUF_CR_ANA_SEL_Pos),
+ AMISC_InternalSrc_TEMP = (AMISC_VBUF_CR_ANA_SEL_TEMP << AMISC_VBUF_CR_ANA_SEL_Pos),
+ AMISC_InternalSrc_DAC0 = (AMISC_VBUF_CR_ANA_SEL_DAC0 << AMISC_VBUF_CR_ANA_SEL_Pos),
+ AMISC_InternalSrc_DAC1 = (AMISC_VBUF_CR_ANA_SEL_DAC1 << AMISC_VBUF_CR_ANA_SEL_Pos),
+ AMISC_InternalSrc_VBuf_1P5V = (AMISC_VBUF_CR_ANA_SEL_VBuf_1p5v << AMISC_VBUF_CR_ANA_SEL_Pos),
+ AMISC_InternalSrc_VDDL = (AMISC_VBUF_CR_ANA_SEL_VDDL << AMISC_VBUF_CR_ANA_SEL_Pos),
+ AMISC_InternalSrc_VSS = (AMISC_VBUF_CR_ANA_SEL_VSS << AMISC_VBUF_CR_ANA_SEL_Pos),
+ AMISC_InternalSrc_VDD = (AMISC_VBUF_CR_ANA_SEL_VDD << AMISC_VBUF_CR_ANA_SEL_Pos),
+} AMISC_InternalSrcTypeDef;
typedef enum
{
- AMISC_Ana2PGA_Disable = 0x0, // AMISC_Ana2PGA_En
- AMISC_Ana2PGA_Ene = AMISC_VBUF_CR_ANA2PGA_EN_Msk ,
-
-} AMISC_Ana2PGATypeDef ;
-
-typedef enum
-{
- AMISC_AnaSel_temp = 0x1 << AMISC_VBUF_CR_ANA_SEL_Pos,
- AMISC_AnaSel_dac0 = 0x2 << AMISC_VBUF_CR_ANA_SEL_Pos,
- AMISC_AnaSel_dac1 = 0x4 << AMISC_VBUF_CR_ANA_SEL_Pos,
- AMISC_AnaSel_1p5v = 0x8 << AMISC_VBUF_CR_ANA_SEL_Pos,
- AMISC_AnaSel_vddl = 0x10 << AMISC_VBUF_CR_ANA_SEL_Pos,
- AMISC_AnaSel_vss = 0x20 << AMISC_VBUF_CR_ANA_SEL_Pos,
- AMISC_AnaSel_v = 0x40 << AMISC_VBUF_CR_ANA_SEL_Pos,
-
-} AMISC_AnaSelTypeDef ;
-
+ AMISC_HSIPwrSrc_Normal = (AMISC_HSI_CR_LDO_SEL_Normal << AMISC_HSI_CR_LDO_SEL_Pos),
+ AMISC_HSIPwrSrc_LowPower = (AMISC_HSI_CR_LDO_SEL_LDO << AMISC_HSI_CR_LDO_SEL_Pos),
+} AMISC_HSIPwrSrcTypeDef;
//=============================================================================
// Macro Definition
//=============================================================================
@@ -244,6 +235,17 @@ __STATIC_FORCEINLINE void AMISC_LVD_ITDisable(void)
return;
}
+/**
+ * \brief Get the status of LVD
+ *
+ * \return
+ * The new state of flags (SET or RESET)
+ */
+__STATIC_FORCEINLINE FlagStatus AMISC_LVD_GetFlagStatus(void)
+{
+ return REG_READ_MASK(AMISC->LVD_LVR_CR, AMISC_LVD_LVR_CR_LVD_STATE_Msk) ? SET : RESET;
+}
+
/**
* \brief Enable VBUF
*
@@ -270,8 +272,18 @@ __STATIC_FORCEINLINE void AMISC_Vbuf_Disable(void)
}
-
-
+/**
+ * \brief Set the power source of HSI
+ *
+ * \param [in] pwr_src The target power source, @ref AMISC_HSIPwrSrcTypeDef
+ * \return
+ * None
+ */
+__STATIC_FORCEINLINE void AMISC_SetHSIPwrSrc(AMISC_HSIPwrSrcTypeDef pwr_src)
+{
+ REG_WRITE_MASK(AMISC->HSI_CR, AMISC_HSI_CR_LDO_SEL_Msk, pwr_src);
+ return;
+}
//=============================================================================
// Structure Definition
@@ -283,16 +295,6 @@ typedef struct
AMISC_LVDFuncTypeDef LVD_FuncModes;
} AMISC_LVDRInitTypeDef;
-
-typedef struct
-{
- AMISC_Ana2IOTypeDef Ana2IOT;
- AMISC_Ana2PGATypeDef Ana2PGA;
- AMISC_AnaSelTypeDef AnaSel;
-
-} AMISC_VBUFConfigTypeDef;
-
-
//=============================================================================
// Global Data Definition
//=============================================================================
@@ -373,12 +375,25 @@ void AMISC_LSI_Disable(void);
*/
void AMISC_LSI_Enable(void);
-
-void AMISC_VBUF_Config(AMISC_VBUFConfigTypeDef *pInit);
-
-
+/**
+ * \brief Select the VinP internal source of PGA
+ *
+ * \param [in] src_type the target VinP internal source
+ * \return
+ * None
+ */
+void AMISC_Sel_PGA_VinP_Src(AMISC_InternalSrcTypeDef src_type);
+/**
+ * \brief Output the internal signals to I/O Pin
+ *
+ * \param [in] src_type The target internal signal, @ref AMISC_InternalSrcTypeDef
+ * \param [in] has_output Enable output or not
+ * \return
+ * None
+ */
+void AMISC_OutInternalSignalToIO(AMISC_InternalSrcTypeDef src_type, int has_output);
#ifdef __cplusplus
}
diff --git a/Examples/pga/pga_test/inc/isr.h b/Drivers/PEC930/HAL_Lib/inc/hal_comp.h
similarity index 88%
rename from Examples/pga/pga_test/inc/isr.h
rename to Drivers/PEC930/HAL_Lib/inc/hal_comp.h
index b77f364..5ad8c21 100644
--- a/Examples/pga/pga_test/inc/isr.h
+++ b/Drivers/PEC930/HAL_Lib/inc/hal_comp.h
@@ -1,27 +1,29 @@
/**
* Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
*/
-/** @file isr.h
+/** @file hal_comp.h
*
* @author Wei-Lun Hsu
* @version 0.1
- * @date 2024/09/16
+ * @date 2024/10/17
* @license
* @description
*/
-#ifndef __isr_H_wuraIpBA_lTJm_HvJw_sNDo_uEd5JnucTReY__
-#define __isr_H_wuraIpBA_lTJm_HvJw_sNDo_uEd5JnucTReY__
+#ifndef __hal_comp_H_wqqzibVO_lvKI_HWdK_sROD_uhjcZz7SHMtL__
+#define __hal_comp_H_wqqzibVO_lvKI_HWdK_sROD_uhjcZz7SHMtL__
#ifdef __cplusplus
extern "C" {
#endif
-#include "main.h"
+
+#include "hal_def.h"
//=============================================================================
// Constant Definition
//=============================================================================
+
//=============================================================================
// Macro Definition
//=============================================================================
@@ -43,7 +45,6 @@ extern "C" {
//=============================================================================
-
#ifdef __cplusplus
}
#endif
diff --git a/Drivers/PB5700/HAL_Lib/inc/hal_crc.h b/Drivers/PEC930/HAL_Lib/inc/hal_crc.h
similarity index 100%
rename from Drivers/PB5700/HAL_Lib/inc/hal_crc.h
rename to Drivers/PEC930/HAL_Lib/inc/hal_crc.h
diff --git a/Drivers/PB5700/HAL_Lib/inc/hal_def.h b/Drivers/PEC930/HAL_Lib/inc/hal_def.h
similarity index 99%
rename from Drivers/PB5700/HAL_Lib/inc/hal_def.h
rename to Drivers/PEC930/HAL_Lib/inc/hal_def.h
index 9b91d2b..8841194 100644
--- a/Drivers/PB5700/HAL_Lib/inc/hal_def.h
+++ b/Drivers/PEC930/HAL_Lib/inc/hal_def.h
@@ -18,7 +18,7 @@ extern "C" {
#endif
-#include "pb57xx.h"
+#include "device.h"
//=============================================================================
// Constant Definition
//=============================================================================
diff --git a/Drivers/PB5700/HAL_Lib/inc/hal_device.h b/Drivers/PEC930/HAL_Lib/inc/hal_device.h
similarity index 86%
rename from Drivers/PB5700/HAL_Lib/inc/hal_device.h
rename to Drivers/PEC930/HAL_Lib/inc/hal_device.h
index 87a3a8e..6712ff6 100644
--- a/Drivers/PB5700/HAL_Lib/inc/hal_device.h
+++ b/Drivers/PEC930/HAL_Lib/inc/hal_device.h
@@ -80,6 +80,24 @@ __STATIC_FORCEINLINE uint32_t HAL_GetUID3(void)
{
return REG_READ(UID->UID3);
}
+
+/**
+ * \brief Initialize the peripherals of this device
+ *
+ * \return
+ * None
+ */
+__STATIC_FORCEINLINE void HAL_DeviceInit(void)
+{
+ REG_WRITE(SYSCFG->PRSTEN1, 0xFFFFFFFFul);
+ REG_WRITE(SYSCFG->PRSTEN, 0xFFFFFFFFul);
+ REG_WRITE(SYSCFG->PRSTEN1, 0x0ul);
+ REG_WRITE(SYSCFG->PRSTEN, 0x0ul);
+ return;
+}
+
+#define HAL_SetBits(_val_, _bit_mak_) REG_SET_BITS(_val_, _bit_mak_)
+#define HAL_ClearBits(_val_, _bit_mak_) REG_CLR_BITS(_val_, _bit_mak_)
//=============================================================================
// Structure Definition
//=============================================================================
@@ -112,6 +130,7 @@ void HAL_SRand(uint32_t seed);
*/
uint32_t HAL_Rand(void);
+
#ifdef __cplusplus
}
#endif
diff --git a/Drivers/PB5700/HAL_Lib/inc/hal_dsp.h b/Drivers/PEC930/HAL_Lib/inc/hal_dsp.h
similarity index 100%
rename from Drivers/PB5700/HAL_Lib/inc/hal_dsp.h
rename to Drivers/PEC930/HAL_Lib/inc/hal_dsp.h
diff --git a/Drivers/PB5700/HAL_Lib/inc/hal_flash.h b/Drivers/PEC930/HAL_Lib/inc/hal_flash.h
similarity index 100%
rename from Drivers/PB5700/HAL_Lib/inc/hal_flash.h
rename to Drivers/PEC930/HAL_Lib/inc/hal_flash.h
diff --git a/Drivers/PB5700/HAL_Lib/inc/hal_gpio.h b/Drivers/PEC930/HAL_Lib/inc/hal_gpio.h
similarity index 94%
rename from Drivers/PB5700/HAL_Lib/inc/hal_gpio.h
rename to Drivers/PEC930/HAL_Lib/inc/hal_gpio.h
index 6934ae0..ca0ac8a 100644
--- a/Drivers/PB5700/HAL_Lib/inc/hal_gpio.h
+++ b/Drivers/PEC930/HAL_Lib/inc/hal_gpio.h
@@ -33,10 +33,11 @@ typedef enum
typedef enum
{
- GPIO_Mode_IN = 0x00, /*!< GPIO Input Mode */
- GPIO_Mode_OUT, /*!< GPIO Output Mode */
- GPIO_Mode_ANAL, /*!< GPIO Analog In/Out Mode */
- GPIO_Mode_AF, /*!< GPIO Alternate function Mode */
+ GPIO_Mode_IN = 0x00, /*!< GPIO Input Mode */
+ GPIO_Mode_OUT, /*!< GPIO Output Mode */
+ GPIO_Mode_ANAL, /*!< GPIO Analog In/Out Mode */
+ GPIO_Mode_AF, /*!< GPIO Alternate function Mode */
+ GPIO_Mode_PWR_Saving, /*!< GPIO Power-Saving Mode */
} GPIO_ModeTypeDef;
@@ -377,6 +378,17 @@ typedef struct GPIO_Init
*/
int GPIO_Init(GPIO_Type *pHGpio, GPIO_InitTypeDef *pInit);
+/**
+ * \brief De-initializes the gpio peripheral according to the specified parameters.
+ *
+ * \param [in] pHGpio Pointer to a GPIO handler
+ * \param [in] pins The target pin, @ref GPIO_PinTypeDef
+ * \return
+ * None
+ */
+void GPIO_DeInit(GPIO_Type *pHGpio, uint32_t pins);
+
+
/**
* \brief Set Pin configuration of Peripheral IP with the specific Alternate Function
*
diff --git a/Drivers/PEC930/HAL_Lib/inc/hal_i2c.h b/Drivers/PEC930/HAL_Lib/inc/hal_i2c.h
new file mode 100644
index 0000000..4cfea54
--- /dev/null
+++ b/Drivers/PEC930/HAL_Lib/inc/hal_i2c.h
@@ -0,0 +1,333 @@
+/**
+ * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
+ */
+/** @file hal_i2c.h
+ *
+ * @author Wei-Lun Hsu
+ * @version 0.1
+ * @date 2024/09/10
+ * @license
+ * @description
+ */
+
+#ifndef __hal_i2c_H_wiTQLukR_lyWI_H9X1_s634_uL7YYZQ9qyOX__
+#define __hal_i2c_H_wiTQLukR_lyWI_H9X1_s634_uL7YYZQ9qyOX__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#include "hal_def.h"
+//=============================================================================
+// Constant Definition
+//=============================================================================
+#define I2C_BLOCKING 0xFFFF
+
+typedef enum
+{
+ I2C_Err_OK = 0,
+ I2C_Err_Fail,
+ I2C_Err_WrongParams,
+ I2C_Err_TimeOut,
+
+} I2C_ErrTypeDef;
+
+typedef enum
+{
+ /* Misc */
+ I2C_State_ERROR = 0x00u,
+ I2C_State_BUS_IDLE = 0xF8u,
+ I2C_State_SLAVE_STOP_RESTART = 0xA0u,
+
+ /* Master Transmit */
+ I2C_State_MASTER_TX_START = 0x08u,
+ I2C_State_MASTER_TX_RESTART = 0x10u,
+ I2C_State_MASTER_TX_SLAW_ACK = 0x18u, // Master sent (SlaveAddress + W-bit) and received ACK
+ I2C_State_MASTER_TX_SLAW_NOACK = 0x20u,
+ I2C_State_MASTER_TX_DATA_ACK = 0x28u, // Master sent data and received ACK
+ I2C_State_MASTER_TX_DATA_NOACK = 0x30u,
+ I2C_State_MASTER_TX_LOST_BUS = 0x38u,
+
+ /* Master Receive */
+ I2C_State_MASTER_RX_START = I2C_State_MASTER_TX_START,
+ I2C_State_MASTER_RX_RESTART = I2C_State_MASTER_TX_RESTART,
+ I2C_State_MASTER_RX_SLAR_ACK = 0x40u, // Master sent (SlaveAddress + R-bit) and received ACK
+ I2C_State_MASTER_RX_SLAR_NOACK = 0x48u,
+ I2C_State_MASTER_RX_DATA_ACK = 0x50u, // Master received data and received ACK
+ I2C_State_MASTER_RX_DATA_NOACK = 0x58u,
+ I2C_State_MASTER_RX_LOST_BUS = I2C_State_MASTER_TX_LOST_BUS,
+
+ /* Slave Receive */
+ I2C_State_SLAVE_RX_SLAW_ACK = 0x60u,
+ I2C_State_SLAVE_RX_SLAW_LOST_BUS = 0x68u,
+ I2C_State_SLAVE_RX_BROAD_ACK = 0x70u, // received broad address and sent ACK
+ I2C_State_SLAVE_RX_BADDR_LOST_BUS = 0x78u,
+ I2C_State_SLAVE_RX_DATA_ACK = 0x80u, // received data and sent ACK
+ I2C_State_SLAVE_RX_DATA_NOACK = 0x88u,
+ I2C_State_SLAVE_RX_BDATA_ACK = 0x90u, // received data (with broad address) and sent ACK
+ I2C_State_SLAVE_RX_BDATA_NOACK = 0x98u,
+
+ /* Slave Transmit */
+ I2C_State_SLAVE_RX_SLAR_ACK = 0xA8u,
+ I2C_State_SLAVE_TX_LOST_BUS = 0xB0u,
+ I2C_State_SLAVE_TX_DATA_ACK = 0xB8u,
+ I2C_State_SLAVE_TX_DATA_NOACK = 0xC0u,
+ I2C_State_SLAVE_TX_LAST_DATA = 0xC8u,
+
+} I2C_StateTypeDef;
+
+/**
+ * I2C role mode
+ */
+typedef enum
+{
+ I2C_Mode_NONE = 0x00U, /*!< No I2C communication on going */
+ I2C_Mode_MASTER = 0x10U, /*!< I2C communication is in Master Mode */
+ I2C_Mode_SLAVE = 0x20U, /*!< I2C communication is in Slave Mode */
+} I2C_ModeTypeDef;
+
+/**
+ * The divide of I2C Clock
+ */
+typedef enum
+{
+ I2C_CLK_Div60 = 60,
+ I2C_CLK_Div120 = 120,
+ I2C_CLK_Div160 = 160,
+ I2C_CLK_Div192 = 192,
+ I2C_CLK_Div244 = 244,
+ I2C_CLK_Div256 = 256,
+ I2C_CLK_Div960 = 960,
+
+} I2C_Clk_DivTypeDef;
+
+typedef enum
+{
+ I2C_BroadAck_Disable = 0x0ul,
+ I2C_BroadAck_Enable = I2C_ADDR_GC_Msk,
+} I2C_BroadAckTypeDef;
+
+typedef enum
+{
+ I2C_XferMode_Idle = 0,
+ I2C_XferMode_Transmite,
+ I2C_XferMode_Recevie,
+} I2C_XferModeTypeDef;
+//=============================================================================
+// Macro Definition
+//=============================================================================
+/**
+ * \brief Get the Hardware state of an I2C
+ *
+ * \param [in] pHI2C The handle of I2C
+ * \return
+ * Hardware state
+ */
+__STATIC_FORCEINLINE uint32_t I2C_GetHwState(I2C_Type *pHI2C)
+{
+ return pHI2C->STAT_b.STAT;
+}
+//=============================================================================
+// Structure Definition
+//=============================================================================
+/**
+ * I2C Initial Configuration
+ */
+typedef struct I2C_Init
+{
+ I2C_Clk_DivTypeDef ClockDiv;
+ I2C_ModeTypeDef Mode; /*!< Specifies the I2C mode. This parameter can be a value of I2C_mode. */
+ uint8_t OwnAddress; /*!< Specifies the first device own address. This parameter can be a 7-bit address. */
+ I2C_BroadAckTypeDef BroadAck; /*!< ACK enable or disable when as slave.
+ This parameter can be a value of @ref I2C_BroadAckTypeDef */
+} I2C_InitTypeDef;
+
+typedef struct I2C_IT_Handle
+{
+ I2C_Type *pHI2C;
+
+ uint8_t *pTxBuffPtr; /*!< Pointer to I2C Tx transfer Buffer */
+ __IO uint16_t TxXferCount; /*!< I2C Tx Transfer Counter */
+
+ uint8_t *pRxBuffPtr; /*!< Pointer to I2C Rx transfer Buffer */
+ __IO uint16_t RxXferCount; /*!< I2C Rx Transfer Counter */
+
+ I2C_XferModeTypeDef XferMode;
+ __IO uint16_t DevAddress; /*!< I2C Target device address */
+
+} I2C_IT_HandleTypeDef;
+//=============================================================================
+// Global Data Definition
+//=============================================================================
+
+//=============================================================================
+// Private Function Definition
+//=============================================================================
+
+//=============================================================================
+// Public Function Definition
+//=============================================================================
+/**
+ * \brief Fills each init_struct member with its default value.
+ *
+ * \param [in] pInit Pointer to an I2C_InitTypeDef structure
+ * which will be initialized.
+ * \return
+ * None
+ */
+void I2C_StructInit(I2C_InitTypeDef *pInit);
+
+/**
+ * \brief Initializes the I2C module
+ *
+ * \param [in] pHI2C Pointer to an I2C handler
+ * \param [in] pInit Pointer to an I2C_InitTypeDef structure that
+ * contains the configuration information for the specified
+ * I2C peripheral
+ * \return
+ * error code, @ref I2C_ErrTypeDef
+ */
+I2C_ErrTypeDef I2C_Init(I2C_Type *pHI2C, I2C_InitTypeDef *pInit);
+
+/**
+ * \brief De-Initializes the I2C peripheral registers to their default values.
+ *
+ * \param [in] pHI2C Pointer to an I2C handler
+ * \return
+ * None
+ */
+void I2C_DeInit(I2C_Type *pHI2C);
+
+/**
+ * \brief I2C-Master transmits an amount of data in blocking mode.
+ *
+ * \param [in] pHI2C Pointer to an I2C handler
+ * \param [in] DevAddr Target device address: The device 7 bits address value
+ * in datasheet must be shift at right before call interface
+ * \param [in] pData Pointer to data buffer
+ * \param [in] Size Amount of data to be sent
+ * \return
+ * error code, @ref I2C_ErrTypeDef
+ */
+I2C_ErrTypeDef I2C_Master_Transmit(I2C_Type *pHI2C, uint16_t DevAddr, uint8_t *pData, uint16_t Size);
+
+/**
+ * \brief I2C-Master receives an amount of data in blocking mode.
+ *
+ * \param [in] pHI2C Pointer to an I2C handler
+ * \param [in] DevAddr Target device address: The device 7 bits address value
+ * in datasheet must be shift at right before call interface
+ * \param [in] pData Pointer to data buffer
+ * \param [in] pSize Amount of data to be received
+ * \param [in] Timeout_ms Timeout with mseconds. If Timeout_ms == I2C_BLOCKING, slave transmit with blocking mode
+ * \return
+ * error code, @ref I2C_ErrTypeDef
+ */
+I2C_ErrTypeDef I2C_Master_Receive(I2C_Type *pHI2C, uint8_t DevAddr, uint8_t *pData, uint16_t *pSize, uint16_t Timeout_ms);
+
+
+/**
+ * \brief I2C-Slave Transmit data in blocking mode
+ *
+ * \param [in] pHI2C Pointer to an I2C handler
+ * \param [in] pData Pointer to data buffer
+ * \param [in] Size Amount of data to be sent
+ * \param [in] Timeout_ms Timeout with mseconds. If Timeout_ms == I2C_BLOCKING, slave transmit with blocking mode
+ * \return
+ * error code, @ref I2C_ErrTypeDef
+ */
+I2C_ErrTypeDef I2C_Slave_Transmit(I2C_Type *pHI2C, uint8_t *pData, uint16_t Size, uint16_t Timeout_ms);
+
+/**
+ * \brief I2C-Slave Receive data in blocking mode
+ *
+ * \param [in] pHI2C Pointer to an I2C handler
+ * \param [in] pData Pointer to data buffer
+ * \param [in] pSize Amount of data to be received
+ * \param [in] Timeout_ms Timeout with mseconds. If Timeout_ms == I2C_BLOCKING, slave transmit with blocking mode
+ * \return
+ * error code, @ref I2C_ErrTypeDef
+ */
+I2C_ErrTypeDef I2C_Slave_Receive(I2C_Type *pHI2C, uint8_t *pData, uint16_t *pSize, uint16_t Timeout_ms);
+
+/**
+ * \brief I2C-Master transmits an amount of data in interrupt mode.
+ *
+ * \param [in] pHITI2C Pointer to an I2C IT handler, @ref I2C_IT_HandleTypeDef
+ * \param [in] DevAddr Target device address: The device 7 bits address value
+ * in datasheet must be shift at right before call interface
+ * \param [in] pData Pointer to data buffer
+ * \param [in] Size Amount of data to be sent
+ * \return
+ * error code, @ref I2C_ErrTypeDef
+ */
+I2C_ErrTypeDef I2C_Master_Transmit_IT(I2C_IT_HandleTypeDef *pHITI2C, uint16_t DevAddr, uint8_t *pData, uint16_t Size);
+
+/**
+ * \brief I2C-Master receives an amount of data in interrupt mode.
+ *
+ * \param [in] pHITI2C Pointer to an I2C IT handler, @ref I2C_IT_HandleTypeDef
+ * \param [in] DevAddr Target device address: The device 7 bits address value
+ * in datasheet must be shift at right before call interface
+ * \param [in] pData Pointer to data buffer
+ * \param [in] Size Amount of data to be received
+ * \return
+ * error code, @ref I2C_ErrTypeDef
+ */
+I2C_ErrTypeDef I2C_Master_Receive_IT(I2C_IT_HandleTypeDef *pHITI2C, uint8_t DevAddr, uint8_t *pData, uint16_t Size);
+
+/**
+ * \brief I2C-Slave Transmit data in interrupt mode
+ *
+ * \param [in] pHITI2C Pointer to an I2C IT handler, @ref I2C_IT_HandleTypeDef
+ * \param [in] pData Pointer to data buffer
+ * \param [in] Size Amount of data to be sent
+ * \return
+ * error code, @ref I2C_ErrTypeDef
+ */
+I2C_ErrTypeDef I2C_Slave_Transmit_IT(I2C_IT_HandleTypeDef *pHITI2C, uint8_t *pData, uint16_t Size);
+
+/**
+ * \brief I2C-Slave Receive data in interrupt mode
+ *
+ * \param [in] pHITI2C Pointer to an I2C IT handler, @ref I2C_IT_HandleTypeDef
+ * \param [in] pData Pointer to data buffer
+ * \param [in] Size Amount of data to be received
+ * \return
+ * error code, @ref I2C_ErrTypeDef
+ */
+I2C_ErrTypeDef I2C_Slave_Receive_IT(I2C_IT_HandleTypeDef *pHITI2C, uint8_t *pData, uint16_t Size);
+
+/**
+ * \brief This function handles I2C-Master interrupt request.
+ *
+ * \param [in] pHITI2C Pointer to an I2C IT Handler, @ref I2C_IT_HandleTypeDef
+ * \return
+ * None
+ */
+void I2C_Master_IRQHandler(I2C_IT_HandleTypeDef *pHITI2C);
+
+/**
+ * \brief This function handles I2C-Slave interrupt request.
+ *
+ * \param [in] pHITI2C Pointer to an I2C IT Handler, @ref I2C_IT_HandleTypeDef
+ * \return
+ * None
+ */
+void I2C_Slave_IRQHandler(I2C_IT_HandleTypeDef *pHITI2C);
+
+#if 0
+/* Callback when xfer completion with interrupt */
+void I2C_MasterTxCmpltCallback(I2C_IT_HandleTypeDef *pHITI2C);
+void I2C_SlaveTxCmpltCallback(I2C_IT_HandleTypeDef *pHITI2C);
+void I2C_MasterRxCmpltCallback(I2C_IT_HandleTypeDef *pHITI2C);
+void I2C_SlaveRxCmpltCallback(I2C_IT_HandleTypeDef *pHITI2C);
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/Drivers/PB5700/HAL_Lib/inc/hal_lptim.h b/Drivers/PEC930/HAL_Lib/inc/hal_lptim.h
similarity index 100%
rename from Drivers/PB5700/HAL_Lib/inc/hal_lptim.h
rename to Drivers/PEC930/HAL_Lib/inc/hal_lptim.h
diff --git a/Drivers/PB5700/HAL_Lib/inc/hal_opamp.h b/Drivers/PEC930/HAL_Lib/inc/hal_opamp.h
similarity index 98%
rename from Drivers/PB5700/HAL_Lib/inc/hal_opamp.h
rename to Drivers/PEC930/HAL_Lib/inc/hal_opamp.h
index efa35b0..36909dd 100644
--- a/Drivers/PB5700/HAL_Lib/inc/hal_opamp.h
+++ b/Drivers/PEC930/HAL_Lib/inc/hal_opamp.h
@@ -27,6 +27,7 @@ extern "C" {
*/
typedef enum
{
+ OPAMP_PGAGain_Ext = (0x00 << OPAMP_PGA_CR_PGA_GAIN_Pos),
OPAMP_PGAGain_1 = (OPAMP_PGA_CR_PGA_GAIN_x1 << OPAMP_PGA_CR_PGA_GAIN_Pos),
OPAMP_PGAGain_2 = (OPAMP_PGA_CR_PGA_GAIN_x2 << OPAMP_PGA_CR_PGA_GAIN_Pos),
OPAMP_PGAGain_3 = (OPAMP_PGA_CR_PGA_GAIN_x3 << OPAMP_PGA_CR_PGA_GAIN_Pos),
diff --git a/Drivers/PB5700/HAL_Lib/inc/hal_pwr.h b/Drivers/PEC930/HAL_Lib/inc/hal_pwr.h
similarity index 66%
rename from Drivers/PB5700/HAL_Lib/inc/hal_pwr.h
rename to Drivers/PEC930/HAL_Lib/inc/hal_pwr.h
index a48e263..3a1aa6e 100644
--- a/Drivers/PB5700/HAL_Lib/inc/hal_pwr.h
+++ b/Drivers/PEC930/HAL_Lib/inc/hal_pwr.h
@@ -22,6 +22,9 @@ extern "C" {
//=============================================================================
// Constant Definition
//=============================================================================
+/**
+ * Power mode type
+ */
typedef enum PWR_Mode
{
PWR_Mode_Sleep = 0,
@@ -29,18 +32,36 @@ typedef enum PWR_Mode
} PWR_ModeTypeDef;
+/**
+ * The wake-up type of power mode
+ */
+typedef enum PWR_Wakeup
+{
+ PWR_Wakeup_IO_PORT_A = (0x1ul << 0),
+ PWR_Wakeup_IO_PORT_B = (0x1ul << 1),
+ PWR_Wakeup_LpTIM = (0x1ul << 2),
+ PWR_Wakeup_WDG = (0x1ul << 3),
+
+} PWR_WakeupTypeDef;
/**
- * \brief Set a peripheral before entering deep-sleep
+ * \brief Set the peripheral before entering power mode
*
+ * \param [in] pwr_mode the target power mode, @ref PWR_ModeTypeDef
+ * \param [in] pWakeup_type provide the target wake-up module from App level
+ * \return
+ * None
*/
-typedef void (*CallbaskPreDeepsleepTypeDef)(void);
+typedef void (*CallbaskPreSleepTypeDef)(PWR_ModeTypeDef pwr_mode, PWR_WakeupTypeDef *pWakeup_type);
/**
- * \brief Set a peripheral after deep-sleep wake-up
- * ps. This callback function ONLY supports to set ONE peripheral
+ * \brief Set the peripheral after power mode wake-up
+ *
+ * \param [in] pwr_mode the target power mode, @ref PWR_ModeTypeDef
+ * \return
+ * None
*/
-typedef void (*CallbaskPostDeepsleepTypeDef)(void);
+typedef void (*CallbaskPostSleepTypeDef)(PWR_ModeTypeDef pwr_mode);
//=============================================================================
// Macro Definition
@@ -61,25 +82,16 @@ typedef void (*CallbaskPostDeepsleepTypeDef)(void);
//=============================================================================
// Public Function Definition
//=============================================================================
-/**
- * @brief Set duration of auto wake-up
- *
- * @param [in] msec the duration of auto wakeup from sleep/deepsleep mode
- * @return
- * None
- */
-void PWR_SetAutoWakeUp(uint32_t msec);
-
/**
* \brief Enters Sleep mode
*
- * @param [in] cb_pre_set_clk Set peripheral BEFORE entering deepsleep
- * @param [in] cb_post_set_clk Set peripheral AFTER wake-up from deepsleep
+ * @param [in] cb_pre_set_clk Set peripheral BEFORE entering sleep
+ * @param [in] cb_post_set_clk Set peripheral AFTER wake-up from sleep
* \return
* None
*/
-void PWR_EnterSleepMode(CallbaskPreDeepsleepTypeDef cb_pre_set,
- CallbaskPostDeepsleepTypeDef cb_post_set);
+void PWR_EnterSleepMode(CallbaskPreSleepTypeDef cb_pre_set,
+ CallbaskPostSleepTypeDef cb_post_set);
/**
@@ -90,8 +102,8 @@ void PWR_EnterSleepMode(CallbaskPreDeepsleepTypeDef cb_pre_set,
* @return
* None
*/
-void PWR_EnterDeepSleepMode(CallbaskPreDeepsleepTypeDef cb_pre_set,
- CallbaskPostDeepsleepTypeDef cb_post_set);
+void PWR_EnterDeepSleepMode(CallbaskPreSleepTypeDef cb_pre_set,
+ CallbaskPostSleepTypeDef cb_post_set);
#ifdef __cplusplus
}
diff --git a/Drivers/PB5700/HAL_Lib/inc/hal_spi.h b/Drivers/PEC930/HAL_Lib/inc/hal_spi.h
similarity index 100%
rename from Drivers/PB5700/HAL_Lib/inc/hal_spi.h
rename to Drivers/PEC930/HAL_Lib/inc/hal_spi.h
diff --git a/Drivers/PB5700/HAL_Lib/inc/hal_syscfg.h b/Drivers/PEC930/HAL_Lib/inc/hal_syscfg.h
similarity index 98%
rename from Drivers/PB5700/HAL_Lib/inc/hal_syscfg.h
rename to Drivers/PEC930/HAL_Lib/inc/hal_syscfg.h
index 539f293..89a9014 100644
--- a/Drivers/PB5700/HAL_Lib/inc/hal_syscfg.h
+++ b/Drivers/PEC930/HAL_Lib/inc/hal_syscfg.h
@@ -364,17 +364,17 @@ __STATIC_FORCEINLINE uint32_t SYSCFG_GetChipID(void)
}
/**
- * \brief Configure the Alternate Function mode of Reset-Pin
+ * \brief Configure Reset-Pin to normal I/O or not
*
- * \param [in] has_rst_pin Enable Reset-Pin function or not
+ * \param [in] is_enable Set Reset-Pin to normal I/O or not
* \return
* None
*/
-__STATIC_FORCEINLINE void SYSCFG_SetRstPinAF(int has_rst_pin)
+__STATIC_FORCEINLINE void SYSCFG_SetRstPin2NormalIO(int is_enable)
{
- (has_rst_pin)
- ? REG_WRITE_MASK(SYSCFG->RSTPINCR, SYSCFG_RSTPINCR_RSTPINAF_Msk, SYSCFG_RSTPINCR_RSTPINAF_ON << SYSCFG_RSTPINCR_RSTPINAF_Pos)
- : REG_WRITE_MASK(SYSCFG->RSTPINCR, SYSCFG_RSTPINCR_RSTPINAF_Msk, SYSCFG_RSTPINCR_RSTPINAF_OFF << SYSCFG_RSTPINCR_RSTPINAF_Pos);
+ (is_enable)
+ ? REG_WRITE_MASK(SYSCFG->RSTPINCR, SYSCFG_RSTPINCR_RSTPINAF_Msk, SYSCFG_RSTPINCR_RSTPINAF_OFF << SYSCFG_RSTPINCR_RSTPINAF_Pos)
+ : REG_WRITE_MASK(SYSCFG->RSTPINCR, SYSCFG_RSTPINCR_RSTPINAF_Msk, SYSCFG_RSTPINCR_RSTPINAF_ON << SYSCFG_RSTPINCR_RSTPINAF_Pos);
return;
}
diff --git a/Drivers/PB5700/HAL_Lib/inc/hal_tim.h b/Drivers/PEC930/HAL_Lib/inc/hal_tim.h
similarity index 91%
rename from Drivers/PB5700/HAL_Lib/inc/hal_tim.h
rename to Drivers/PEC930/HAL_Lib/inc/hal_tim.h
index 5204c8e..ee4cccc 100644
--- a/Drivers/PB5700/HAL_Lib/inc/hal_tim.h
+++ b/Drivers/PEC930/HAL_Lib/inc/hal_tim.h
@@ -73,6 +73,8 @@ typedef struct
uint16_t TIM_Break; /*!< Specifies whether the TIM Break input is enabled or not. */
uint16_t TIM_BreakPolarity; /*!< Specifies the TIM Break Input pin polarity. */
uint16_t TIM_AutomaticOutput; /*!< Specifies whether the TIM Automatic Output feature is enabled or not. */
+ uint16_t TIM_DTGFTime; /*!< Specifies the delay time between the switching-off and */
+ uint32_t TIM_DTAEState; /*!< Specifies the delay time between the switching-off and */
} TIM_BDTRInitTypeDef;
/**
* @}
@@ -227,6 +229,11 @@ typedef struct
#define TIM_DirectOutput_Disable (0x00U << TIM_BDTR_DOE_Pos) /*!< Direct output disable, output waiting for dead time */
#define TIM_DirectOutput_Enable (0x01U << TIM_BDTR_DOE_Pos) /*!< Direct output enable, no longer waiting for output after dead time */
+/**
+ * @brief DATE_State_Selection_for_Idle_mode_state
+ */
+#define TIM_DTAEState_Disable (0x00U << TIM_BDTR_DTAE_Pos)
+#define TIM_DTAEState_Enable (0x01U << TIM_BDTR_DTAE_Pos)
/**
* @brief TIM_interrupt_sources
*/
@@ -238,6 +245,12 @@ typedef struct
#define TIM_IT_COM (0x01U << TIM_DIER_COMIE_Pos) /*!< TIM Commutation Interrupt source */
#define TIM_IT_Trigger (0x01U << TIM_DIER_TIE_Pos) /*!< TIM Trigger Interrupt source */
#define TIM_IT_Break (0x01U << TIM_DIER_BIE_Pos) /*!< TIM Break Interrupt source */
+#define TIM_IT_CCD1 (0x01U << TIM_DIER_CCD1IE_Pos) /*!< TIM Capture Compare 1 Interrupt source */
+#define TIM_IT_CCD2 (0x01U << TIM_DIER_CCD2IE_Pos) /*!< TIM Capture Compare 2 Interrupt source */
+#define TIM_IT_CCD3 (0x01U << TIM_DIER_CCD3IE_Pos) /*!< TIM Capture Compare 3 Interrupt source */
+#define TIM_IT_OV (0x01U << TIM_DIER_OVIE_Pos) /*!< TIM Trigger Interrupt source */
+#define TIM_IT_UD (0x01U << TIM_DIER_UDIE_Pos) /*!< TIM Break Interrupt source */
+#define TIM_IT_CCD4 (0x01U << TIM_DIER_CCD4IE_Pos) /*!< TIM Capture Compare 4 Interrupt source */
/**
@@ -291,13 +304,13 @@ typedef struct
/**
* @brief TIM_Output_Compare_Clear_State
*/
-#define TIM_OCClear_Disable (0x01U << TIM_CCMR1_OUTPUT_OC1CE_Pos) /*!< TIM Output clear disable */
+#define TIM_OCClear_Disable (0x00U << TIM_CCMR1_OUTPUT_OC1CE_Pos) /*!< TIM Output clear disable */
#define TIM_OCClear_Enable (0x01U << TIM_CCMR1_OUTPUT_OC1CE_Pos) /*!< TIM Output clear enable */
/**
* @brief TIM_Output_Compare_Fast_State
*/
-#define TIM_OCFast_Disable (0x01U << TIM_CCMR1_OUTPUT_OC1FE_Pos) /*!< TIM output compare fast disable */
+#define TIM_OCFast_Disable (0x00U << TIM_CCMR1_OUTPUT_OC1FE_Pos) /*!< TIM output compare fast disable */
#define TIM_OCFast_Enable (0x01U << TIM_CCMR1_OUTPUT_OC1FE_Pos) /*!< TIM output compare fast enable */
/**
@@ -388,16 +401,16 @@ typedef struct
* @{
*/
-#define TIM_ExtTRGPSC_OFF ((uint16_t)0x0000)
-#define TIM_ExtTRGPSC_DIV2 ((uint16_t)0x1000)
-#define TIM_ExtTRGPSC_DIV4 ((uint16_t)0x2000)
-#define TIM_ExtTRGPSC_DIV8 ((uint16_t)0x3000)
+#define TIM_ExtTRGPSC_OFF (0x00U << TIM_SMCR_ETPS_Pos)
+#define TIM_ExtTRGPSC_DIV2 (0x01U << TIM_SMCR_ETPS_Pos)
+#define TIM_ExtTRGPSC_DIV4 (0x02U << TIM_SMCR_ETPS_Pos)
+#define TIM_ExtTRGPSC_DIV8 (0x03U << TIM_SMCR_ETPS_Pos)
/** @defgroup TIM_External_Trigger_Polarity
* @{
*/
-#define TIM_ExtTRGPolarity_Inverted ((uint16_t)0x8000)
-#define TIM_ExtTRGPolarity_NonInverted ((uint16_t)0x0000)
+#define TIM_ExtTRGPolarity_Inverted (0x01U << TIM_SMCR_ETP_Pos)
+#define TIM_ExtTRGPolarity_NonInverted (0x00U << TIM_SMCR_ETP_Pos)
//=============================================================================
// Macro Definition
@@ -459,6 +472,11 @@ void TIM_ForcedOC2Config(TIM_Type *tim, uint32_t forced_action);
void TIM_ForcedOC3Config(TIM_Type *tim, uint32_t forced_action);
void TIM_ForcedOC4Config(TIM_Type *tim, uint32_t forced_action);
+void TIM_ClearOC1Ref(TIM_Type *tim, uint16_t TIM_OCClear);
+void TIM_ClearOC2Ref(TIM_Type *tim, uint16_t TIM_OCClear);
+void TIM_ClearOC3Ref(TIM_Type *tim, uint16_t TIM_OCClear);
+void TIM_ClearOC4Ref(TIM_Type *tim, uint16_t TIM_OCClear);
+
void TIM_ARRPreloadConfig(TIM_Type *tim, FunctionalState state);
void TIM_SelectCOM(TIM_Type *tim, FunctionalState state);
void TIM_SelectCCDMA(TIM_Type *tim, FunctionalState state);
@@ -468,11 +486,12 @@ void TIM_OC1PreloadConfig(TIM_Type *tim, uint32_t preload);
void TIM_OC2PreloadConfig(TIM_Type *tim, uint32_t preload);
void TIM_OC3PreloadConfig(TIM_Type *tim, uint32_t preload);
void TIM_OC4PreloadConfig(TIM_Type *tim, uint32_t preload);
-void TIM_OC5PreloadConfig(TIM_Type *tim, uint32_t preload);
+
void TIM_OC1FastConfig(TIM_Type *tim, uint32_t fast);
void TIM_OC2FastConfig(TIM_Type *tim, uint32_t fast);
void TIM_OC3FastConfig(TIM_Type *tim, uint32_t fast);
void TIM_OC4FastConfig(TIM_Type *tim, uint32_t fast);
+
void TIM_OC1PolarityConfig(TIM_Type *tim, uint32_t polarity);
void TIM_OC1NPolarityConfig(TIM_Type *tim, uint32_t polarity);
void TIM_OC2PolarityConfig(TIM_Type *tim, uint32_t polarity);
@@ -481,6 +500,7 @@ void TIM_OC3PolarityConfig(TIM_Type *tim, uint32_t polarity);
void TIM_OC3NPolarityConfig(TIM_Type *tim, uint32_t polarity);
void TIM_OC4PolarityConfig(TIM_Type *tim, uint32_t polarity);
void TIM_OC4NPolarityConfig(TIM_Type *tim, uint32_t polarity);
+
void TIM_CCxCmd(TIM_Type *tim, uint16_t channel, uint32_t ccx_en);
void TIM_CCxNCmd(TIM_Type *tim, uint16_t channel, uint32_t ccxn_en);
@@ -489,7 +509,12 @@ void TIM_SetCompare1(TIM_Type *tim, uint32_t compare);
void TIM_SetCompare2(TIM_Type *tim, uint32_t compare);
void TIM_SetCompare3(TIM_Type *tim, uint32_t compare);
void TIM_SetCompare4(TIM_Type *tim, uint32_t compare);
-void TIM_SetCompare5(TIM_Type *tim, uint32_t compare);
+
+void TIM_ASYMEN_Cmd(TIM_Type *tim, FunctionalState state);
+void TIM_SetDownCompare1(TIM_Type *tim, uint32_t compare);
+void TIM_SetDownCompare2(TIM_Type *tim, uint32_t compare);
+void TIM_SetDownCompare3(TIM_Type *tim, uint32_t compare);
+void TIM_SetDownCompare4(TIM_Type *tim, uint32_t compare);
void TIM_UpdateDisableConfig(TIM_Type *tim, FunctionalState state);
void TIM_UpdateRequestConfig(TIM_Type *tim, uint32_t source);
@@ -509,7 +534,6 @@ uint32_t TIM_GetCapture1(TIM_Type *tim);
uint32_t TIM_GetCapture2(TIM_Type *tim);
uint32_t TIM_GetCapture3(TIM_Type *tim);
uint32_t TIM_GetCapture4(TIM_Type *tim);
-uint32_t TIM_GetCapture5(TIM_Type *tim);
uint32_t TIM_GetCounter(TIM_Type *tim);
uint16_t TIM_GetPrescaler(TIM_Type *tim);
@@ -524,12 +548,14 @@ void TIM_SetCCR1FALL(TIM_Type *tim, uint32_t shift);
void TIM_SetCCR2FALL(TIM_Type *tim, uint32_t shift);
void TIM_SetCCR3FALL(TIM_Type *tim, uint32_t shift);
void TIM_SetCCR4FALL(TIM_Type *tim, uint32_t shift);
-void TIM_SetCCR5FALL(TIM_Type *tim, uint32_t shift);
-FlagStatus TIM_GetCountDirection(TIM_Type *tim);
+FlagStatus TIM_GetCountDirection(TIM_Type *tim);
uint32_t TIM_GetTIMxClock(TIM_Type *tim);
+void TIM_ETRClockMode1Config(TIM_Type *tim, uint16_t TIM_ExtTRGPrescaler, uint16_t TIM_ExtTRGPolarity, uint16_t ExtTRGFilter);
void TIM_ETRClockMode2Config(TIM_Type* TIMx, uint16_t TIM_ExtTRGPrescaler,uint16_t TIM_ExtTRGPolarity, uint16_t ExtTRGFilter);
+void TIM_TIxExternalClockConfig(TIM_Type *TIMx, uint16_t TIM_TIxExternalCLKSource, uint16_t TIM_ICPolarity, uint16_t ICFilter);
+void TIM_ETRConfig(TIM_Type *tim, uint16_t TIM_ExtTRGPrescaler, uint16_t TIM_ExtTRGPolarity,uint16_t ExtTRGFilter);
#ifdef __cplusplus
}
diff --git a/Drivers/PB5700/HAL_Lib/inc/hal_uart.h b/Drivers/PEC930/HAL_Lib/inc/hal_uart.h
similarity index 86%
rename from Drivers/PB5700/HAL_Lib/inc/hal_uart.h
rename to Drivers/PEC930/HAL_Lib/inc/hal_uart.h
index c329035..60cf653 100644
--- a/Drivers/PB5700/HAL_Lib/inc/hal_uart.h
+++ b/Drivers/PEC930/HAL_Lib/inc/hal_uart.h
@@ -131,7 +131,7 @@ typedef enum
*/
__STATIC_FORCEINLINE void UART_ResetRxFIFO(UART_Type *pHUart)
{
- REG_WRITE(pHUart->RXFR, 0x5700);
+ REG_WRITE(pHUart->RXFR, 0xe930);
return;
}
@@ -144,7 +144,7 @@ __STATIC_FORCEINLINE void UART_ResetRxFIFO(UART_Type *pHUart)
*/
__STATIC_FORCEINLINE void UART_ResetTxFIFO(UART_Type *pHUart)
{
- REG_WRITE(pHUart->TXFR, 0x5700);
+ REG_WRITE(pHUart->TXFR, 0xe930);
return;
}
@@ -277,21 +277,6 @@ uint16_t UART_ReceiveData(UART_Type *pHUart);
UART_ErrTypeDef UART_ITConfig(UART_Type *pHUart, uint32_t flags, uint32_t is_enable);
-/**
- * @brief UART_Interrupt_definition
- */
-#define UART_IT_RXNE (0x01U << UART_IE_RXNEE_Pos) /*!< RXNE interrupt enable */
-#define UART_IT_TXE (0x01U << UART_IE_TXEE_Pos) /*!< TXE interrupt enable */
-#define UART_IT_TXHE (0x01U << UART_IE_TXHEE_Pos) /*!< TXHE interrupt enable */
-#define UART_IT_PERR (0x01U << UART_IE_PERRE_Pos) /*!< PERR interrupt enable */
-#define UART_IT_FERR (0x01U << UART_IE_FERRE_Pos) /*!< FERR interrupt enable */
-#define UART_IT_OVERR (0x01U << UART_IE_OVERRE_Pos) /*!< OVERR interrupt enable */
-#define UART_IT_TONE (0x01U << UART_IE_TONEE_Pos) /*!< TONE Interrupt enable */
-#define UART_IT_TOIDLE (0x01U << UART_IE_TOIDLEE_Pos) /*!< TOIDLE interrupt enable */
-#define UART_IT_RXHF (0x01U << UART_IE_RXHFE_Pos) /*!< RXHF interrupt enable */
-#define UART_IT_RXF (0x01U << UART_IE_RXFE_Pos) /*!< RXF interrupt enable */
-#define UART_IT_TXEND (0x01U << UART_IE_TXENDE_Pos) /*!< TXEND interrupt enable */
-#define UART_IT_TXF (0x01U << UART_IE_TXFE_Pos) /*!< TXF interrupt enable */
#ifdef __cplusplus
diff --git a/Drivers/PB5700/HAL_Lib/inc/hal_wdg.h b/Drivers/PEC930/HAL_Lib/inc/hal_wdg.h
similarity index 87%
rename from Drivers/PB5700/HAL_Lib/inc/hal_wdg.h
rename to Drivers/PEC930/HAL_Lib/inc/hal_wdg.h
index 44bbe12..45ce57e 100644
--- a/Drivers/PB5700/HAL_Lib/inc/hal_wdg.h
+++ b/Drivers/PEC930/HAL_Lib/inc/hal_wdg.h
@@ -44,17 +44,17 @@ extern "C" {
//=============================================================================
typedef struct
{
- uint32_t Relaod;
- uint32_t Reset;
- uint32_t Debug;
+ uint32_t Relaod;
+ uint32_t Reset;
+ uint32_t Debug;
} WDG_BaseInitTypeDef;
-#define WDG_Reset_En (0x1U << WDG_CR_RSTE_Pos)
-#define WDG_Reset_Dis (0x0U << WDG_CR_RSTE_Pos)
+#define WDG_Reset_En (0x1U << WDG_CR_RSTE_Pos)
+#define WDG_Reset_Dis (0x0U << WDG_CR_RSTE_Pos)
-#define WDG_Debug_En (0x1U << WDG_CR_DBGE_Pos)
-#define WDG_Debug_Dis (0x0U << WDG_CR_DBGE_Pos)
+#define WDG_Debug_En (0x1U << WDG_CR_DBGE_Pos)
+#define WDG_Debug_Dis (0x0U << WDG_CR_DBGE_Pos)
diff --git a/Drivers/PB5700/HAL_Lib/src/hal_adc.c b/Drivers/PEC930/HAL_Lib/src/hal_adc.c
similarity index 87%
rename from Drivers/PB5700/HAL_Lib/src/hal_adc.c
rename to Drivers/PEC930/HAL_Lib/src/hal_adc.c
index fcbf644..dd99a06 100644
--- a/Drivers/PB5700/HAL_Lib/src/hal_adc.c
+++ b/Drivers/PEC930/HAL_Lib/src/hal_adc.c
@@ -17,7 +17,7 @@
//=============================================================================
// Constant Definition
//=============================================================================
-#define ADC_TIMEOUT_CNT 1000
+#define ADC_TIMEOUT_CNT (60*1000*10)
#define ADC_ALL_CHANNELS_Msk (0xFFFF)
@@ -133,6 +133,7 @@ void ADC_Init(ADC_Type *pHADC, ADC_InitTypeDef *pInit)
pInit->DataAlign);
REG_SET_BITS(pHADC->STAT, ADC_STAT_EOC_CHECK_DIS_Msk);
+ REG_WRITE_MASK(pHADC->CHSEL, ADC_CHSEL_CH_SEL_Msk, pInit->SelChannels);
break;
case ADC_Mode_Scan:
@@ -181,7 +182,7 @@ void ADC_Init(ADC_Type *pHADC, ADC_InitTypeDef *pInit)
void ADC_StructInit(ADC_InitTypeDef *pInit)
{
- pInit->SelChannels = ADC_Channel_15;
+ pInit->SelChannels = ADC_Channel_AVSS;
pInit->ClkPrescaler = ADC_ClkDiv_Auto;
pInit->DataAlign = ADC_DataAlign_Right;
pInit->Mode = ADC_Mode_SingleConv;
@@ -204,7 +205,6 @@ void ADC_ExtTrigConfig(ADC_Type *pHADC, ADC_ExtTrigSourceTypeDef ext_src, ADC_Ex
if( ext_src & 0x10 )
{
-
uint32_t pin_sel = 0;
/* TRIG_SEL17 rising/falling configuraion */
@@ -222,20 +222,44 @@ void ADC_ExtTrigConfig(ADC_Type *pHADC, ADC_ExtTrigSourceTypeDef ext_src, ADC_Ex
return;
}
+/**
+ * \brief Select the sub-channel of the ADC Channel-15
+ *
+ * \param [in] subchannel The selected sub-channel of ADC channel-15, @ref ADC_SubChannelTypeDef
+ * \return
+ * None
+ */
+void ADC_SelSubChannel(ADC_SubChannelTypeDef subchannel)
+{
+ AMISC_InternalSrcTypeDef src_type = AMISC_InternalSrc_NONE;
+
+ src_type = (subchannel == ADC_SubChannel_TEMP) ? AMISC_InternalSrc_TEMP :
+ (subchannel == ADC_SubChannel_DAC0) ? AMISC_InternalSrc_DAC0 :
+ (subchannel == ADC_SubChannel_DAC1) ? AMISC_InternalSrc_DAC1 :
+ (subchannel == ADC_SubChannel_VBuf_1_5) ? AMISC_InternalSrc_VBuf_1P5V :
+ (subchannel == ADC_SubChannel_VDDL) ? AMISC_InternalSrc_VDDL :
+ (subchannel == ADC_SubChannel_VSS) ? AMISC_InternalSrc_VSS :
+ (subchannel == ADC_SubChannel_VDD) ? AMISC_InternalSrc_VDD :
+ AMISC_InternalSrc_NONE;
+
+ AMISC_OutInternalSignalToIO(src_type, false);
+
+ REG_SET_BITS(AMISC->ADC_AIN_CR, AMISC_ADC_AIN_CR_ANA2ADC_EN_Msk);
+ return;
+}
+
uint16_t ADC_GetChannelConvValue(ADC_Type *pHADC, ADC_ChannelsTypeDef channel)
{
volatile uint32_t *pData = (volatile uint32_t*)&pHADC->DAT0;
int timeout = 0;
uint32_t chnnl_id = (31ul - HAL_CLZ(channel));
-#if 0
while( REG_READ_MASK(pHADC->CON0, ADC_CON0_ENCONT_Msk) == 0 &&
REG_READ_MASK(pHADC->STAT, ADC_STAT_DONE_Msk) == 0 )
{
if( timeout++ > ADC_TIMEOUT_CNT )
return 0;
}
-#endif
pData += (chnnl_id & 0xFul);
return (uint16_t)((*pData) & 0xFFFFul);
diff --git a/Drivers/PB5700/HAL_Lib/src/hal_amisc.c b/Drivers/PEC930/HAL_Lib/src/hal_amisc.c
similarity index 64%
rename from Drivers/PB5700/HAL_Lib/src/hal_amisc.c
rename to Drivers/PEC930/HAL_Lib/src/hal_amisc.c
index 9db059a..9cbde01 100644
--- a/Drivers/PB5700/HAL_Lib/src/hal_amisc.c
+++ b/Drivers/PEC930/HAL_Lib/src/hal_amisc.c
@@ -85,15 +85,6 @@ AMISC_StatusTypeDef AMISC_LVD_LVR_Config(AMISC_LVDRInitTypeDef *pInit)
return AMISC_Status_OK;
}
-
-void AMISC_VBUF_Config(AMISC_VBUFConfigTypeDef *pInit)
-{
- REG_WRITE_MASK(AMISC->VBUF_CR,
- AMISC_VBUF_CR_ANA2IO_EN_Msk | AMISC_VBUF_CR_ANA2PGA_EN_Msk | \
- AMISC_VBUF_CR_ANA_SEL_Msk ,
- pInit->Ana2IOT | pInit->Ana2PGA | pInit->AnaSel);
-}
-
void AMISC_HSI_Disable(void)
{
if( SYSCFG_GetSysClkType() == SYSCFG_ClkSrc_LSI )
@@ -124,6 +115,85 @@ void AMISC_LSI_Enable(void)
return;
}
+void AMISC_Sel_PGA_VinP_Src(AMISC_InternalSrcTypeDef src_type)
+{
+ AMISC_InternalSrcTypeDef VinP_Src = AMISC_InternalSrc_NONE;
+
+ /* AMISC clock enable */
+ __HAL_SYSCFG_AMISC_CLK_ENABLE();
+
+ VinP_Src = (src_type == AMISC_InternalSrc_NONE)
+ ? src_type : (AMISC_VBUF_CR_ANA2PGA_EN_Msk | src_type);
+
+ switch( src_type )
+ {
+ default:
+ break;
+
+ case AMISC_InternalSrc_NONE:
+ break;
+
+ case AMISC_InternalSrc_TEMP:
+ REG_SET_BITS(AMISC->LVD_LVR_CR, AMISC_LVD_LVR_CR_TEMP_EN_Msk);
+ break;
+
+ case AMISC_InternalSrc_DAC0:
+ AMISC_DAC0_Enable();
+ break;
+ case AMISC_InternalSrc_DAC1:
+ AMISC_DAC1_Enable();
+ break;
+ case AMISC_InternalSrc_VBuf_1P5V:
+ REG_SET_BITS(VinP_Src, AMISC_VBUF_CR_VBUF_EN_Msk);
+ break;
+ }
+
+ REG_WRITE_MASK(AMISC->VBUF_CR,
+ AMISC_VBUF_CR_ANA_SEL_Msk | AMISC_VBUF_CR_ANA2PGA_EN_Msk,
+ VinP_Src);
+
+ sys_busy_wait(60*1000);
+ return;
+}
+
+void AMISC_OutInternalSignalToIO(AMISC_InternalSrcTypeDef src_type, int has_output)
+{
+ uint32_t value = (has_output)
+ ? (src_type | AMISC_VBUF_CR_ANA2IO_EN_Msk) : src_type;
+
+ /* AMISC clock enable */
+ __HAL_SYSCFG_AMISC_CLK_ENABLE();
+
+ switch( src_type )
+ {
+ default:
+ break;
+
+ case AMISC_InternalSrc_NONE:
+ break;
+
+ case AMISC_InternalSrc_TEMP:
+ REG_SET_BITS(AMISC->LVD_LVR_CR, AMISC_LVD_LVR_CR_TEMP_EN_Msk);
+ break;
+
+ case AMISC_InternalSrc_DAC0:
+ AMISC_DAC0_Enable();
+ break;
+ case AMISC_InternalSrc_DAC1:
+ AMISC_DAC1_Enable();
+ break;
+ case AMISC_InternalSrc_VBuf_1P5V:
+ REG_SET_BITS(value, AMISC_VBUF_CR_VBUF_EN_Msk);
+ break;
+ }
+
+ REG_WRITE_MASK(AMISC->VBUF_CR,
+ AMISC_VBUF_CR_ANA_SEL_Msk | AMISC_VBUF_CR_ANA2IO_EN_Msk | AMISC_VBUF_CR_VBUF_EN_Msk,
+ value);
+
+ sys_busy_wait(60*1000);
+ return;
+}
#endif /* CONFIG_ENABLE_HAL_AMISC */
diff --git a/Examples/pga/pga_test/src/isr.c b/Drivers/PEC930/HAL_Lib/src/hal_comp.c
similarity index 90%
rename from Examples/pga/pga_test/src/isr.c
rename to Drivers/PEC930/HAL_Lib/src/hal_comp.c
index d19995f..dc0aa9e 100644
--- a/Examples/pga/pga_test/src/isr.c
+++ b/Drivers/PEC930/HAL_Lib/src/hal_comp.c
@@ -1,17 +1,19 @@
/**
* Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
*/
-/** @file isr.c
+/** @file hal_vcmp.c
*
* @author Wei-Lun Hsu
* @version 0.1
- * @date 2024/09/16
+ * @date 2024/10/17
* @license
* @description
*/
-#include "isr.h"
+#include "hal_device.h"
+
+#if defined(CONFIG_ENABLE_HAL_COMP)
//=============================================================================
// Constant Definition
@@ -37,3 +39,5 @@
// Public Function Definition
//=============================================================================
+
+#endif /* CONFIG_ENABLE_HAL_VCMP */
diff --git a/Drivers/PB5700/HAL_Lib/src/hal_crc.c b/Drivers/PEC930/HAL_Lib/src/hal_crc.c
similarity index 100%
rename from Drivers/PB5700/HAL_Lib/src/hal_crc.c
rename to Drivers/PEC930/HAL_Lib/src/hal_crc.c
diff --git a/Drivers/PB5700/HAL_Lib/src/hal_device.c b/Drivers/PEC930/HAL_Lib/src/hal_device.c
similarity index 100%
rename from Drivers/PB5700/HAL_Lib/src/hal_device.c
rename to Drivers/PEC930/HAL_Lib/src/hal_device.c
diff --git a/Drivers/PB5700/HAL_Lib/src/hal_dsp.c b/Drivers/PEC930/HAL_Lib/src/hal_dsp.c
similarity index 100%
rename from Drivers/PB5700/HAL_Lib/src/hal_dsp.c
rename to Drivers/PEC930/HAL_Lib/src/hal_dsp.c
diff --git a/Drivers/PB5700/HAL_Lib/src/hal_flash.c b/Drivers/PEC930/HAL_Lib/src/hal_flash.c
similarity index 95%
rename from Drivers/PB5700/HAL_Lib/src/hal_flash.c
rename to Drivers/PEC930/HAL_Lib/src/hal_flash.c
index a7a53df..e4d7f23 100644
--- a/Drivers/PB5700/HAL_Lib/src/hal_flash.c
+++ b/Drivers/PEC930/HAL_Lib/src/hal_flash.c
@@ -18,6 +18,7 @@
// Constant Definition
//=============================================================================
#define CONFIG_FLASH_TIMEOUT 0xFFFFFFFFul
+#define FLASH_PE_CLK_MAX (1ul*1000*1000)
//=============================================================================
// Macro Definition
//=============================================================================
@@ -33,7 +34,15 @@
//=============================================================================
// Private Function Definition
//=============================================================================
+static void
+_FLASH_SetDivider(void)
+{
+ uint32_t div = 0;
+ div = sys_get_cpu_freq() / FLASH_PE_CLK_MAX;
+ REG_WRITE(FLASH->DIV, div | (0x1ul << 8));
+ return;
+}
//=============================================================================
// Public Function Definition
//=============================================================================
@@ -63,7 +72,7 @@ FLASH_ErasePage(uint32_t page_addr)
{
flash_state_t rval = FLASH_STATE_OK;
- REG_WRITE(FLASH->DIV, SYS_HIRC_MHZ | (0x1ul << 8)); // move to system init ???
+ _FLASH_SetDivider();
do {
REG_WRITE(FLASH->SR, 0xFFFFFFFFul); // clean interrutp flags
@@ -104,6 +113,8 @@ FLASH_ProgWord(uint32_t addr, uint32_t value)
break;
}
+ _FLASH_SetDivider();
+
REG_WRITE(FLASH->SR, 0xFFFFFFFFul); // clean interrutp flags
FLASH->AR = addr;
@@ -145,6 +156,7 @@ FLASH_ProgHWord(uint32_t addr, uint16_t value)
break;
}
+ _FLASH_SetDivider();
REG_WRITE(FLASH->SR, 0xFFFFFFFFul); // clean interrutp flags
#if 0
@@ -188,6 +200,7 @@ FLASH_ProgByte(uint32_t addr, uint8_t value)
uint32_t word;
} u;
+ _FLASH_SetDivider();
REG_WRITE(FLASH->SR, 0xFFFFFFFFul); // clean interrutp flags
#if 0
@@ -232,6 +245,7 @@ FLASH_ProgData(uint32_t addr, uint32_t *pData, int length)
break;
}
+ _FLASH_SetDivider();
REG_WRITE(FLASH->SR, 0xFFFFFFFFul); // clean interrutp flags
FLASH->AR = addr;
diff --git a/Drivers/PB5700/HAL_Lib/src/hal_gpio.c b/Drivers/PEC930/HAL_Lib/src/hal_gpio.c
similarity index 83%
rename from Drivers/PB5700/HAL_Lib/src/hal_gpio.c
rename to Drivers/PEC930/HAL_Lib/src/hal_gpio.c
index d1fdb99..765a06c 100644
--- a/Drivers/PB5700/HAL_Lib/src/hal_gpio.c
+++ b/Drivers/PEC930/HAL_Lib/src/hal_gpio.c
@@ -63,9 +63,12 @@ int GPIO_Init(GPIO_Type *pHGpio, GPIO_InitTypeDef *pInit)
continue;
// enable Schmitt-Trigger
- REG_CLR_BITS(pHGpio->CTC, pin_cur);
REG_SET_BITS(pHGpio->CTS, pin_cur);
+ (pInit->GPIO_OType == GPIO_OType_OD)
+ ? REG_SET_BITS(pHGpio->ODS, pin_cur)
+ : REG_SET_BITS(pHGpio->ODC, pin_cur);
+
switch( pInit->GPIO_Mode )
{
default:
@@ -95,36 +98,33 @@ int GPIO_Init(GPIO_Type *pHGpio, GPIO_InitTypeDef *pInit)
case GPIO_Mode_OUT: /* Output mode */
REG_SET_BITS(pHGpio->INEC, pin_cur);
REG_SET_BITS(pHGpio->OES, pin_cur);
- (pInit->GPIO_OType == GPIO_OType_OD)
- ? REG_SET_BITS(pHGpio->ODS, pin_cur)
- : REG_SET_BITS(pHGpio->ODC, pin_cur);
if( pInit->GPIO_PuPd == GPIO_PuPd_UP )
{
- REG_SET_BITS(pHGpio->PUS, pin_cur);
- REG_SET_BITS(pHGpio->PDC, pin_cur);
+ REG_SET_BITS(pHGpio->LAT, pin_cur);
}
else if( pInit->GPIO_PuPd == GPIO_PuPd_DOWN )
{
- REG_SET_BITS(pHGpio->PDS, pin_cur);
- REG_SET_BITS(pHGpio->PUC, pin_cur);
+ REG_CLR_BITS(pHGpio->LAT, pin_cur);
}
else
- { /* NOPULL */
- REG_SET_BITS(pHGpio->PDC, pin_cur);
- REG_SET_BITS(pHGpio->PUC, pin_cur);
+ {
+ /* NOPULL, H/w not support */
}
-
break;
case GPIO_Mode_ANAL: /* Analog mode */
REG_SET_BITS(pHGpio->INEC, pin_cur);
// disable Schmitt-Trigger
- REG_CLR_BITS(pHGpio->CTS, pin_cur);
REG_SET_BITS(pHGpio->CTC, pin_cur);
break;
+ case GPIO_Mode_PWR_Saving:
+ REG_SET_BITS(pHGpio->INEC, pin_cur);
+ REG_SET_BITS(pHGpio->OEC, pin_cur);
+ break;
+
case GPIO_Mode_AF: /* Alternate mode */
if( pHGpio == GPIOA && (pin_cur & GPIO_PORTA_AF_PINS) )
{
@@ -151,6 +151,44 @@ int GPIO_Init(GPIO_Type *pHGpio, GPIO_InitTypeDef *pInit)
return rval;
}
+void GPIO_DeInit(GPIO_Type *pHGpio, uint32_t pins)
+{
+ while( pins )
+ {
+ int shift = 31 - HAL_CLZ(pins);
+ uint32_t pin_cur = 0x0;
+
+ pin_cur = 0x1ul << shift;
+ REG_CLR_BITS(pins, pin_cur);
+
+ REG_SET_BITS(pHGpio->IEC, pin_cur); // disable interrupt
+
+ REG_SET_BITS(pHGpio->INEC, pin_cur);
+ REG_SET_BITS(pHGpio->OEC, pin_cur);
+
+ REG_SET_BITS(pHGpio->ODC, pin_cur);
+
+ REG_SET_BITS(pHGpio->ITC0, pin_cur);
+ REG_SET_BITS(pHGpio->ITC1, pin_cur);
+ REG_SET_BITS(pHGpio->PLC, pin_cur);
+ REG_SET_BITS(pHGpio->IST, pin_cur);
+
+ REG_SET_BITS(pHGpio->CTS, pin_cur);
+
+ if( pHGpio == GPIOA && (pin_cur & GPIO_PORTA_AF_PINS) )
+ {
+ shift = (shift > 5) ? (shift - 8) : shift;
+ REG_WRITE_MASK(AFIO->PAAFR, (AFIO_PAAFR_PA0_Msk << 3*shift), GPIO_AF_0 << 3*shift);
+ }
+ else if( pHGpio == GPIOB && (pin_cur & GPIO_PORTB_AF_PINS) )
+ {
+ REG_WRITE_MASK(AFIO->PBAFR, (AFIO_PBAFR_PB0_Msk << 3*shift), GPIO_AF_0 << 3*shift);
+ }
+ }
+
+ return;
+}
+
void GPIO_PeriAFConfig(GPIO_Type *pHGpio, GPIO_PeriTypeDef peri_type, GPIO_PeriAFTypeDef af_mode)
{
if( peri_type < GPIO_Peri_Fn2 )
diff --git a/Drivers/PEC930/HAL_Lib/src/hal_i2c.c b/Drivers/PEC930/HAL_Lib/src/hal_i2c.c
new file mode 100644
index 0000000..8edcea0
--- /dev/null
+++ b/Drivers/PEC930/HAL_Lib/src/hal_i2c.c
@@ -0,0 +1,870 @@
+/**
+ * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
+ */
+/** @file hal_i2c.c
+*
+* @author Wei-Lun Hsu
+* @version 0.1
+* @date 2024/09/10
+* @license
+* @description
+*/
+
+
+#include "hal_device.h"
+
+#if defined(CONFIG_ENABLE_HAL_I2C)
+//=============================================================================
+// Constant Definition
+//=============================================================================
+#define CONFIG_I2C_TIMEOUT 20U /*!< Timeout 20 ms */
+#define I2C_CLOCK_FREQ_MAX (400ul*1000)
+
+typedef enum
+{
+ I2C_SwState_SUCCESS = 0, /*!< Waited i2c status flag */
+ I2C_SwState_ERROR = 1, /*!< No i2c status flag */
+ I2C_SwState_WAITING = 2, /*!< Waiting i2c status flag */
+ I2C_SwState_HOLD_DATA = 3, /*!< I2C hold data flag */
+ I2C_SwState_FORCE_STOP = 4, /*!< I2C force stop flag */
+ I2C_SwState_RESTART = 5, /*!< I2C restart flag */
+} I2C_SwState;
+
+typedef enum
+{
+ I2C_TxStage_START_BIT = 0,
+ I2C_TxStage_ADDRESS,
+ I2C_TxStage_DATA,
+
+} I2C_TxStage;
+
+#define I2C_START_BIT_H I2C_CTLSET_STA_Msk
+#define I2C_START_BIT_L 0x0u
+
+#define I2C_STOP_BIT_H I2C_CTLSET_STO_Msk
+#define I2C_STOP_BIT_L 0x0u
+
+#define I2C_ACK_BIT_H I2C_CTLSET_AA_Msk
+#define I2C_ACK_BIT_L 0x0u
+
+
+#define I2C_CLK_DIVIDER_60 (I2C_CTLSET_CR1_Msk | I2C_CTLSET_CR2_Msk)
+#define I2C_CLK_DIVIDER_120 (I2C_CTLSET_CR0_Msk | I2C_CTLSET_CR2_Msk)
+#define I2C_CLK_DIVIDER_160 (I2C_CTLSET_CR0_Msk | I2C_CTLSET_CR1_Msk)
+#define I2C_CLK_DIVIDER_192 I2C_CTLSET_CR1_Msk
+#define I2C_CLK_DIVIDER_244 I2C_CTLSET_CR0_Msk
+#define I2C_CLK_DIVIDER_256 0x0ul
+#define I2C_CLK_DIVIDER_960 I2C_CTLSET_CR2_Msk
+#define I2C_CLK_DIVIDER_Msk (I2C_CTLSET_CR0_Msk | I2C_CTLSET_CR1_Msk | I2C_CTLSET_CR2_Msk)
+//=============================================================================
+// Macro Definition
+//=============================================================================
+/**
+ * \brief Set/Clear Ack bit
+ *
+ * \param [in] pHI2C The handle of I2C
+ * \return None
+ */
+__STATIC_FORCEINLINE void _I2C_SET_ACK_FLAG(I2C_Type *pHI2C)
+{
+ REG_SET_BITS(pHI2C->CTLSET, I2C_CTLSET_AA_Msk);
+ return;
+}
+
+__STATIC_FORCEINLINE void _I2C_CLR_ACK_FLAG(I2C_Type *pHI2C)
+{
+ REG_SET_BITS(pHI2C->CTLCLR, I2C_CTLCLR_AA_Msk);
+ return;
+}
+
+/**
+ * \brief Set/Clear Start bit
+ *
+ * \param [in] pHI2C The handle of I2C
+ * \return None
+ */
+__STATIC_FORCEINLINE void _I2C_SET_START_FLAG(I2C_Type *pHI2C)
+{
+ REG_SET_BITS(pHI2C->CTLSET, I2C_CTLSET_STA_Msk);
+ return;
+}
+
+__STATIC_FORCEINLINE void _I2C_CLR_START_FLAG(I2C_Type *pHI2C)
+{
+ REG_SET_BITS(pHI2C->CTLCLR, I2C_CTLCLR_STA_Msk);
+ return;
+}
+
+/**
+ * \brief Check Interrupt flag of an I2C
+ *
+ * \param [in] __HANDLE__ The handle of I2C
+ * \return
+ * 0 : no interrupt
+ * others: get interrupt
+ */
+#define __I2C_GET_SI_FLAG(__HANDLE__) REG_READ_MASK((__HANDLE__)->CTLSET, I2C_CTLSET_SI_Msk)
+
+
+/**
+ * \brief Set/Clear the I2C interrupt set-flag
+ *
+ * \param [in] pHI2C The handle of I2C
+ * \return
+ * None
+ */
+__STATIC_FORCEINLINE void _I2C_SET_SI_FLAG(I2C_Type *pHI2C)
+{
+ REG_SET_BITS(pHI2C->CTLSET, I2C_CTLSET_SI_Msk);
+ return;
+}
+
+__STATIC_FORCEINLINE void _I2C_CLR_SI_FLAG(I2C_Type *pHI2C)
+{
+ REG_SET_BITS(pHI2C->CTLCLR, I2C_CTLCLR_SI_Msk);
+ return;
+}
+
+/**
+ * \brief Enable/Disable General Call
+ *
+ * \param [in] pHI2C The handle of I2C
+ * \return None
+ */
+__STATIC_FORCEINLINE void _I2C_GC_ENABLE(I2C_Type *pHI2C)
+{
+ REG_SET_BITS(pHI2C->ADDR, I2C_ADDR_GC_Msk);
+ return;
+}
+
+__STATIC_FORCEINLINE void _I2C_GC_DISABLE(I2C_Type *pHI2C)
+{
+ REG_CLR_BITS(pHI2C->ADDR, I2C_ADDR_GC_Msk);
+ return;
+}
+
+/**
+ * \brief Enable/Disable I2C module
+ *
+ * \param [in] pHI2C The handle of I2C
+ * \return
+ * None
+ */
+__STATIC_FORCEINLINE void _I2C_ENABLE(I2C_Type *pHI2C)
+{
+ REG_SET_BITS(pHI2C->CTLSET, I2C_CTLSET_EN_Msk);
+ return;
+}
+
+__STATIC_FORCEINLINE void _I2C_DISABLE(I2C_Type *pHI2C)
+{
+ REG_SET_BITS(pHI2C->CTLCLR, I2C_CTLSET_EN_Msk);
+ return;
+}
+
+
+ /**
+ * \brief Configure the Start/Stop/ACK flag
+ *
+ * \param [in] pHI2C The handle of I2C
+ * \param [in] start_bit The target state of start_bit
+ * \param [in] stop_bit The target state of stop_bit
+ * \param [in] ack_bit The target state of ack_bit
+ * \return
+ * None
+ */
+ __STATIC_FORCEINLINE void _I2C_Config(I2C_Type *pHI2C, uint32_t start_bit, uint32_t stop_bit, uint32_t ack_bit)
+{
+ REG_WRITE_MASK(pHI2C->CTLCLR,
+ I2C_CTLCLR_STA_Msk | I2C_CTLCLR_STO_Msk | I2C_CTLCLR_AA_Msk,
+ I2C_CTLCLR_STA_Msk | I2C_CTLCLR_STO_Msk | I2C_CTLCLR_AA_Msk);
+
+ REG_WRITE_MASK(pHI2C->CTLSET,
+ I2C_CTLSET_STA_Msk | I2C_CTLSET_STO_Msk | I2C_CTLSET_AA_Msk,
+ (start_bit) | (stop_bit) | (ack_bit));
+ return;
+}
+
+
+//=============================================================================
+// Structure Definition
+//=============================================================================
+
+//=============================================================================
+// Global Data Definition
+//=============================================================================
+
+//=============================================================================
+// Private Function Definition
+//=============================================================================
+static I2C_ErrTypeDef
+_I2C_Wait_SI_Flag(I2C_Type *pHI2C, uint32_t timeout_ms)
+{
+ uint32_t start_ticks = 0;
+
+ start_ticks = sys_get_tick();
+
+ while( !REG_READ_MASK(pHI2C->CTLSET, I2C_CTLSET_SI_Msk) )
+ {
+ if( (sys_get_tick() - start_ticks) > timeout_ms )
+ {
+ return I2C_Err_TimeOut;
+ }
+ }
+
+ return I2C_Err_OK;
+}
+
+static I2C_SwState
+_I2C_Master_Send_Byte(I2C_Type *pHI2C, uint8_t **ppData, bool is_end)
+{
+ __IO uint32_t *pData_reg = &pHI2C->DATA;
+ I2C_SwState rval = I2C_SwState_SUCCESS;
+
+ switch( REG_READ(pHI2C->STAT) )
+ {
+ default:
+ _I2C_Config(pHI2C, I2C_START_BIT_L, I2C_STOP_BIT_H, I2C_ACK_BIT_L);
+ rval = I2C_SwState_ERROR;
+ break;
+
+ case I2C_State_MASTER_TX_START:
+ case I2C_State_MASTER_TX_RESTART:
+ case I2C_State_MASTER_TX_SLAW_ACK:
+ *((__IO uint8_t*)pData_reg) = *((__IO uint8_t*)(*ppData));
+ *ppData = *ppData + 1;
+ _I2C_Config(pHI2C, I2C_START_BIT_L, I2C_STOP_BIT_L, I2C_ACK_BIT_L);
+ break;
+
+ case I2C_State_MASTER_TX_SLAW_NOACK:
+ case I2C_State_MASTER_TX_DATA_NOACK:
+ _I2C_Config(pHI2C, I2C_START_BIT_L, I2C_STOP_BIT_H, I2C_ACK_BIT_L);
+ break;
+
+ case I2C_State_MASTER_TX_DATA_ACK:
+ if( is_end )
+ {
+ _I2C_Config(pHI2C, I2C_START_BIT_L, I2C_STOP_BIT_H, I2C_ACK_BIT_L);
+ break;
+ }
+
+ *((__IO uint8_t*)pData_reg) = *((__IO uint8_t*)(*ppData));
+ *ppData = *ppData + 1;
+ break;
+
+ case I2C_State_MASTER_TX_LOST_BUS:
+ _I2C_Config(pHI2C, I2C_START_BIT_H, I2C_STOP_BIT_L, I2C_ACK_BIT_L);
+ break;
+ }
+
+ _I2C_CLR_SI_FLAG(pHI2C);
+
+ return rval;
+}
+
+static I2C_SwState
+_I2C_Master_Recv_Byte(I2C_Type *pHI2C, uint8_t **ppData, uint32_t is_end)
+{
+ __IO uint32_t *pData_reg = &pHI2C->DATA;
+ I2C_SwState rval = I2C_SwState_SUCCESS;
+
+ switch( REG_READ(pHI2C->STAT) )
+ {
+ default:
+ _I2C_Config(pHI2C, I2C_START_BIT_L, I2C_STOP_BIT_H, I2C_ACK_BIT_L);
+ rval = I2C_SwState_ERROR;
+ break;
+
+ case I2C_State_MASTER_TX_DATA_ACK:
+ _I2C_Config(pHI2C, I2C_START_BIT_H, I2C_STOP_BIT_L, I2C_ACK_BIT_L);
+ break;
+
+ case I2C_State_MASTER_RX_START:
+ case I2C_State_MASTER_RX_RESTART:
+ *((__IO uint8_t*)pData_reg) = *((__IO uint8_t*)(*ppData));
+ *ppData = *ppData + 1;
+ _I2C_Config(pHI2C, I2C_START_BIT_L, I2C_STOP_BIT_L, I2C_ACK_BIT_L);
+ break;
+
+ case I2C_State_MASTER_RX_SLAR_ACK:
+ _I2C_Config(pHI2C, I2C_START_BIT_L,
+ I2C_STOP_BIT_L,
+ (is_end)? I2C_ACK_BIT_L : I2C_ACK_BIT_H);
+ break;
+
+ case I2C_State_MASTER_RX_DATA_ACK:
+ _I2C_Config(pHI2C, I2C_START_BIT_L,
+ I2C_STOP_BIT_L,
+ (is_end) ? I2C_ACK_BIT_L : I2C_ACK_BIT_H);
+
+ *(__IO uint8_t*)(*ppData) = *((__IO uint8_t*)pData_reg);
+ *ppData = *ppData + 1;
+
+ break;
+
+ case I2C_State_MASTER_RX_DATA_NOACK:
+ *(__IO uint8_t*)(*ppData) = *((__IO uint8_t*)pData_reg);
+ *ppData = *ppData + 1;
+
+ case I2C_State_MASTER_RX_SLAR_NOACK:
+ _I2C_Config(pHI2C, I2C_START_BIT_L, I2C_STOP_BIT_H, I2C_ACK_BIT_H);
+ break;
+
+ case I2C_State_MASTER_RX_LOST_BUS:
+ _I2C_Config(pHI2C, I2C_START_BIT_H, I2C_STOP_BIT_L, I2C_ACK_BIT_H);
+ break;
+ }
+
+ _I2C_CLR_SI_FLAG(pHI2C);
+
+ return rval;
+}
+
+static I2C_SwState
+_I2C_Slave_Send_Byte(I2C_Type *pHI2C, uint8_t **ppData, bool *pHasRxAddr, bool is_end)
+{
+ __IO uint32_t *pData_reg = &pHI2C->DATA;
+ I2C_SwState rval = I2C_SwState_SUCCESS;
+
+ switch( REG_READ(pHI2C->STAT) )
+ {
+ default:
+ _I2C_Config(pHI2C, I2C_START_BIT_L, I2C_STOP_BIT_H, I2C_ACK_BIT_H);
+ rval = I2C_SwState_ERROR;
+ break;
+
+ case I2C_State_SLAVE_RX_SLAR_ACK:
+ *pHasRxAddr = true;
+ case I2C_State_SLAVE_TX_DATA_ACK:
+ if( is_end )
+ {
+ _I2C_Config(pHI2C, I2C_START_BIT_L, I2C_STOP_BIT_H, I2C_ACK_BIT_H);
+ break;
+ }
+
+ *((__IO uint8_t*)pData_reg) = *((__IO uint8_t*)(*ppData));
+ *ppData = *ppData + 1;
+ _I2C_Config(pHI2C, I2C_START_BIT_L, I2C_STOP_BIT_L, I2C_ACK_BIT_H);
+ break;
+
+ case I2C_State_SLAVE_TX_LOST_BUS:
+ *((__IO uint8_t*)pData_reg) = *((__IO uint8_t*)(*ppData));
+ *ppData = *ppData + 1;
+ _I2C_Config(pHI2C, I2C_START_BIT_H, I2C_STOP_BIT_L, I2C_ACK_BIT_H);
+ break;
+
+ case I2C_State_SLAVE_TX_DATA_NOACK:
+ case I2C_State_SLAVE_TX_LAST_DATA:
+ _I2C_Config(pHI2C, I2C_START_BIT_L, I2C_STOP_BIT_L, I2C_ACK_BIT_H);
+ rval = I2C_SwState_SUCCESS;
+ break;
+
+ case I2C_State_SLAVE_STOP_RESTART: // master force stop
+ _I2C_Config(pHI2C, I2C_START_BIT_L, I2C_STOP_BIT_L, I2C_ACK_BIT_H);
+ rval = (*pHasRxAddr) ? I2C_SwState_FORCE_STOP : I2C_SwState_RESTART;
+ break;
+ }
+
+ _I2C_CLR_SI_FLAG(pHI2C);
+
+ return rval;
+}
+
+static I2C_SwState
+_I2C_Slave_Recv_Byte(I2C_Type *pHI2C, uint8_t **ppData, uint32_t is_end)
+{
+ __IO uint32_t *pData_reg = &pHI2C->DATA;
+ I2C_SwState rval = I2C_SwState_SUCCESS;
+
+ switch( REG_READ(pHI2C->STAT) )
+ {
+ default:
+ _I2C_Config(pHI2C, I2C_START_BIT_L, I2C_STOP_BIT_H, I2C_ACK_BIT_H);
+ rval = I2C_SwState_ERROR;
+ break;
+
+ case I2C_State_SLAVE_RX_SLAW_LOST_BUS:
+ case I2C_State_SLAVE_RX_BADDR_LOST_BUS:
+ _I2C_Config(pHI2C, I2C_START_BIT_H, I2C_STOP_BIT_L, I2C_ACK_BIT_H);
+ break;
+
+ case I2C_State_SLAVE_RX_SLAW_ACK:
+ case I2C_State_SLAVE_RX_BDATA_NOACK:
+ case I2C_State_SLAVE_RX_BROAD_ACK:
+ _I2C_Config(pHI2C, I2C_START_BIT_L,
+ I2C_STOP_BIT_L,
+ (is_end) ? I2C_ACK_BIT_L : I2C_ACK_BIT_H);
+
+ rval = I2C_SwState_HOLD_DATA;
+ break;
+
+ case I2C_State_SLAVE_RX_DATA_ACK:
+ *(__IO uint8_t*)(*ppData) = *((__IO uint8_t*)pData_reg);
+ *ppData = *ppData + 1;
+
+ _I2C_Config(pHI2C, I2C_START_BIT_L,
+ I2C_STOP_BIT_L,
+ (is_end) ? I2C_ACK_BIT_L : I2C_ACK_BIT_H);
+ break;
+
+ case I2C_State_SLAVE_RX_DATA_NOACK:
+ *(__IO uint8_t*)(*ppData) = *((__IO uint8_t*)pData_reg);
+ *ppData = *ppData + 1;
+
+ _I2C_Config(pHI2C, I2C_START_BIT_L,
+ (is_end) ? I2C_STOP_BIT_H : I2C_STOP_BIT_L,
+ I2C_ACK_BIT_H);
+ break;
+
+ case I2C_State_SLAVE_RX_BDATA_ACK:
+ *(__IO uint8_t*)(*ppData) = *((__IO uint8_t*)pData_reg);
+ *ppData = *ppData + 1;
+
+ _I2C_Config(pHI2C, I2C_START_BIT_L, I2C_STOP_BIT_L, I2C_ACK_BIT_H);
+ break;
+
+ case I2C_State_SLAVE_STOP_RESTART: // master force stop
+ _I2C_Config(pHI2C, I2C_START_BIT_L, I2C_STOP_BIT_L, I2C_ACK_BIT_H);
+ rval = I2C_SwState_FORCE_STOP;
+ break;
+ }
+
+ _I2C_CLR_SI_FLAG(pHI2C);
+
+ return rval;
+}
+//=============================================================================
+// Public Function Definition
+//=============================================================================
+void I2C_StructInit(I2C_InitTypeDef *pInit)
+{
+ int divider = 0;
+
+ pInit->Mode = I2C_Mode_MASTER;
+ pInit->OwnAddress = 0x0;
+ pInit->BroadAck = I2C_BroadAck_Disable;
+
+ divider = (g_SystemCoreClock / I2C_CLOCK_FREQ_MAX);
+ pInit->ClockDiv = (divider <= I2C_CLK_Div60) ? I2C_CLK_Div60 :
+ (divider <= I2C_CLK_Div120) ? I2C_CLK_Div120 :
+ (divider <= I2C_CLK_Div160) ? I2C_CLK_Div160 :
+ (divider <= I2C_CLK_Div192) ? I2C_CLK_Div192 :
+ (divider <= I2C_CLK_Div244) ? I2C_CLK_Div244 :
+ (divider <= I2C_CLK_Div256) ? I2C_CLK_Div256 :
+ I2C_CLK_Div960;
+
+ return;
+}
+
+
+/**
+ * @brief Deinitializes the i2c peripheral registers to their default
+ * reset values.
+ * @param i2c1.
+ * @retval None.
+ */
+void I2C_DeInit(I2C_Type *pHI2C)
+{
+ _I2C_DISABLE(pHI2C);
+
+ __HAL_SYSCFG_RESET_I2C();
+ __HAL_SYSCFG_I2C_CLK_DISABLE();
+ return;
+}
+
+
+I2C_ErrTypeDef I2C_Init(I2C_Type *pHI2C, I2C_InitTypeDef *pInit)
+{
+ __HAL_SYSCFG_I2C_CLK_ENABLE();
+ __HAL_SYSCFG_RESET_I2C();
+
+ if( pInit->Mode == I2C_Mode_MASTER )
+ {
+ uint32_t divider = 0ul;
+
+ /**
+ * I2C clock freq should less than I2C_CLOCK_FREQ_MAX
+ */
+// if( (g_SystemCoreClock / pInit->ClockDiv) > I2C_CLOCK_FREQ_MAX )
+// return I2C_Err_WrongParams;
+
+ divider = (pInit->ClockDiv == I2C_CLK_Div960) ? I2C_CLK_DIVIDER_960 :
+ (pInit->ClockDiv == I2C_CLK_Div256) ? I2C_CLK_DIVIDER_256 :
+ (pInit->ClockDiv == I2C_CLK_Div244) ? I2C_CLK_DIVIDER_244 :
+ (pInit->ClockDiv == I2C_CLK_Div192) ? I2C_CLK_DIVIDER_192 :
+ (pInit->ClockDiv == I2C_CLK_Div160) ? I2C_CLK_DIVIDER_160 :
+ (pInit->ClockDiv == I2C_CLK_Div120) ? I2C_CLK_DIVIDER_120 :
+ I2C_CLK_DIVIDER_60;
+
+ /* Set divider */
+ REG_WRITE_MASK(pHI2C->CTLSET, I2C_CLK_DIVIDER_Msk, divider);
+
+ /* clear ack flag */
+ _I2C_CLR_ACK_FLAG(pHI2C);
+ }
+ else if( pInit->Mode == I2C_Mode_SLAVE )
+ {
+ /* Configure Slave Address */
+ REG_WRITE_MASK(pHI2C->ADDR,
+ I2C_ADDR_ADDR_Msk | I2C_ADDR_GC_Msk,
+ (pInit->OwnAddress << I2C_ADDR_ADDR_Pos) | pInit->BroadAck);
+
+ REG_WRITE_MASK(pHI2C->CTLSET, I2C_CLK_DIVIDER_Msk, pInit->ClockDiv);
+
+ _I2C_SET_ACK_FLAG(pHI2C);
+ }
+ else
+ return I2C_Err_WrongParams;
+
+
+ _I2C_ENABLE(pHI2C);
+ _I2C_CLR_SI_FLAG(pHI2C);
+
+ return I2C_Err_OK;
+}
+
+I2C_ErrTypeDef I2C_Master_Transmit(I2C_Type *pHI2C, uint16_t DevAddr, uint8_t *pData, uint16_t Size)
+{
+ I2C_SwState rval = I2C_SwState_SUCCESS;
+ I2C_TxStage stage = I2C_TxStage_START_BIT;
+ uint16_t tx_nbytes = 0;
+
+ if( (int)pHI2C == (int)I2C0 )
+ sys_close_IRQ(I2C0_IRQn);
+
+ _I2C_SET_START_FLAG(pHI2C);
+ stage = I2C_TxStage_ADDRESS;
+
+ while( tx_nbytes < Size )
+ {
+ if( _I2C_Wait_SI_Flag(pHI2C, CONFIG_I2C_TIMEOUT) != I2C_Err_OK )
+ break;
+
+ if( stage == I2C_TxStage_ADDRESS )
+ {
+ uint8_t addr = (uint8_t)DevAddr & ~0x1u; // write mode
+ uint8_t *pAddr = 0;
+
+ pAddr = &addr;
+ rval = _I2C_Master_Send_Byte(pHI2C, &pAddr, false);
+ if( rval == I2C_SwState_ERROR )
+ break;
+
+ stage = I2C_TxStage_DATA;
+ continue;
+ }
+ else
+ {
+ rval = _I2C_Master_Send_Byte(pHI2C, &pData, false);
+ if( rval == I2C_SwState_ERROR )
+ break;
+ }
+
+ tx_nbytes = (rval == I2C_SwState_SUCCESS) ? tx_nbytes + 1 : tx_nbytes;
+ }
+
+ if( rval == I2C_SwState_SUCCESS )
+ {
+ // send STOP-bit
+ _I2C_Wait_SI_Flag(pHI2C, CONFIG_I2C_TIMEOUT);
+ _I2C_Master_Send_Byte(pHI2C, &pData, true);
+ }
+
+ return (rval == I2C_SwState_SUCCESS) ? I2C_Err_OK : I2C_Err_Fail;
+}
+
+I2C_ErrTypeDef I2C_Master_Receive(I2C_Type *pHI2C, uint8_t DevAddr, uint8_t *pData, uint16_t *pSize, uint16_t Timeout_ms)
+{
+ I2C_SwState rval = I2C_SwState_SUCCESS;
+ I2C_TxStage stage = I2C_TxStage_START_BIT;
+ uint16_t buf_size = *pSize;
+ int rx_nbytes = 0;
+
+ if( (int)pHI2C == (int)I2C0 )
+ sys_close_IRQ(I2C0_IRQn);
+
+ _I2C_SET_START_FLAG(pHI2C);
+ stage = I2C_TxStage_ADDRESS;
+
+ if( pSize ) *pSize = 0;
+
+ while( rx_nbytes < buf_size )
+ {
+ if( _I2C_Wait_SI_Flag(pHI2C, Timeout_ms) != I2C_Err_OK )
+ {
+ if( Timeout_ms == I2C_BLOCKING )
+ continue;
+
+ return I2C_Err_TimeOut;
+ }
+
+ if( stage == I2C_TxStage_ADDRESS )
+ {
+ uint8_t addr = (uint8_t)DevAddr | 0x1u; // read mode
+ uint8_t *pAddr = 0;
+
+ pAddr = &addr;
+ rval = _I2C_Master_Recv_Byte(pHI2C, &pAddr, (buf_size == 1));
+ if( rval == I2C_SwState_ERROR )
+ break;
+
+ /**
+ * send DevAddr+R and then receive data
+ * ps. Decrease the DevAddr+R byte
+ */
+ rx_nbytes = -1;
+ stage = I2C_TxStage_DATA;
+ continue;
+ }
+ else
+ {
+ rval = _I2C_Master_Recv_Byte(pHI2C, &pData, ((rx_nbytes + 1) == (buf_size-1)));
+ if( rval == I2C_SwState_ERROR )
+ break;
+ }
+
+ rx_nbytes = (rval == I2C_SwState_SUCCESS) ? rx_nbytes + 1 : rx_nbytes;
+ }
+
+ if( pSize ) *pSize = rx_nbytes;
+
+ return (rval == I2C_SwState_SUCCESS) ? I2C_Err_OK : I2C_Err_Fail;
+}
+
+I2C_ErrTypeDef I2C_Slave_Transmit(I2C_Type *pHI2C, uint8_t *pData, uint16_t Size, uint16_t Timeout_ms)
+{
+ __IO uint16_t tx_nbytes = 0;
+ I2C_SwState rval = I2C_SwState_SUCCESS;
+ bool HasRecvAddr = false;
+
+ if( (int)pHI2C == (int)I2C0 )
+ sys_close_IRQ(I2C0_IRQn);
+
+ while( tx_nbytes < Size )
+ {
+ if( _I2C_Wait_SI_Flag(pHI2C, Timeout_ms) != I2C_Err_OK )
+ {
+ if( Timeout_ms == I2C_BLOCKING )
+ continue;
+
+ return I2C_Err_TimeOut;
+ }
+
+ rval = _I2C_Slave_Send_Byte(pHI2C, &pData, &HasRecvAddr, false);
+ if( rval == I2C_SwState_ERROR || rval == I2C_SwState_FORCE_STOP )
+ {
+ break;
+ }
+
+ tx_nbytes = (rval == I2C_SwState_SUCCESS) ? tx_nbytes + 1 : tx_nbytes;
+ }
+
+ if( rval == I2C_SwState_SUCCESS )
+ {
+ // send STOP-bit
+ _I2C_Wait_SI_Flag(pHI2C, CONFIG_I2C_TIMEOUT);
+ _I2C_Slave_Send_Byte(pHI2C, &pData, &HasRecvAddr, true);
+ }
+
+ return (rval == I2C_SwState_SUCCESS) ? I2C_Err_OK : I2C_Err_Fail;
+}
+
+I2C_ErrTypeDef I2C_Slave_Receive(I2C_Type *pHI2C, uint8_t *pData, uint16_t *pSize, uint16_t Timeout_ms)
+{
+ uint16_t rx_nbytes = 0;
+ uint16_t buf_size = *pSize;
+ I2C_SwState rval = I2C_SwState_SUCCESS;
+
+ if( (int)pHI2C == (int)I2C0 )
+ sys_close_IRQ(I2C0_IRQn);
+
+ if( pSize ) *pSize = 0;
+
+ while( rx_nbytes < buf_size )
+ {
+ if( _I2C_Wait_SI_Flag(pHI2C, Timeout_ms) != I2C_Err_OK )
+ {
+ if( Timeout_ms == I2C_BLOCKING )
+ continue;
+
+ return I2C_Err_TimeOut;
+ }
+
+ rval = _I2C_Slave_Recv_Byte(pHI2C, &pData, ((rx_nbytes + 1) == buf_size));
+ if( rval == I2C_SwState_ERROR || rval == I2C_SwState_FORCE_STOP )
+ {
+ break;
+ }
+
+ rx_nbytes = (rval == I2C_SwState_SUCCESS) ? rx_nbytes + 1 : rx_nbytes;
+ }
+
+ if( pSize ) *pSize = rx_nbytes;
+
+ return (rval == I2C_SwState_SUCCESS) ? I2C_Err_OK : I2C_Err_Fail;
+}
+
+I2C_ErrTypeDef I2C_Master_Transmit_IT(I2C_IT_HandleTypeDef *pHITI2C, uint16_t DevAddr, uint8_t *pData, uint16_t Size)
+{
+ pHITI2C->XferMode = I2C_XferMode_Transmite;
+ pHITI2C->DevAddress = (uint8_t)DevAddr;
+ pHITI2C->pTxBuffPtr = pData;
+ pHITI2C->TxXferCount = Size;
+
+ if( (int)pHITI2C->pHI2C == (int)I2C0 )
+ sys_open_IRQ(I2C0_IRQn);
+
+ REG_WRITE_MASK(pHITI2C->pHI2C->CTLSET,
+ I2C_CTLSET_STA_Msk | I2C_CTLSET_SI_Msk,
+ I2C_CTLSET_STA_Msk | I2C_CTLSET_SI_Msk);
+
+ return I2C_Err_OK;
+}
+
+I2C_ErrTypeDef I2C_Master_Receive_IT(I2C_IT_HandleTypeDef *pHITI2C, uint8_t DevAddr, uint8_t *pData, uint16_t Size)
+{
+ pHITI2C->XferMode = I2C_XferMode_Recevie;
+ pHITI2C->DevAddress = (uint8_t)DevAddr;
+ pHITI2C->pRxBuffPtr = pData;
+ pHITI2C->RxXferCount = Size;
+
+ if( (int)pHITI2C->pHI2C == (int)I2C0 )
+ sys_open_IRQ(I2C0_IRQn);
+
+ REG_WRITE_MASK(pHITI2C->pHI2C->CTLSET,
+ I2C_CTLSET_STA_Msk | I2C_CTLSET_SI_Msk,
+ I2C_CTLSET_STA_Msk | I2C_CTLSET_SI_Msk);
+
+ return I2C_Err_OK;
+}
+
+I2C_ErrTypeDef I2C_Slave_Transmit_IT(I2C_IT_HandleTypeDef *pHITI2C, uint8_t *pData, uint16_t Size)
+{
+ pHITI2C->XferMode = I2C_XferMode_Transmite;
+ pHITI2C->pTxBuffPtr = pData;
+ pHITI2C->TxXferCount = Size;
+
+ _I2C_SET_SI_FLAG(pHITI2C->pHI2C);
+ if( (int)pHITI2C->pHI2C == (int)I2C0 )
+ sys_open_IRQ(I2C0_IRQn);
+
+ return I2C_Err_OK;
+}
+
+I2C_ErrTypeDef I2C_Slave_Receive_IT(I2C_IT_HandleTypeDef *pHITI2C, uint8_t *pData, uint16_t Size)
+{
+ pHITI2C->XferMode = I2C_XferMode_Recevie;
+ pHITI2C->pRxBuffPtr = pData;
+ pHITI2C->RxXferCount = Size;
+
+ _I2C_SET_SI_FLAG(pHITI2C->pHI2C);
+ if( (int)pHITI2C->pHI2C == (int)I2C0 )
+ sys_open_IRQ(I2C0_IRQn);
+
+ return I2C_Err_OK;
+}
+
+void I2C_Master_IRQHandler(I2C_IT_HandleTypeDef *pHITI2C)
+{
+ I2C_SwState rval = I2C_SwState_SUCCESS;
+
+ if( pHITI2C->XferMode == I2C_XferMode_Transmite )
+ {
+ if( pHITI2C->DevAddress & 0x8000 )
+ {
+ // xfer data stage, if pHITI2C->TxXferCount == 0, I2C should send STOP-bit
+ rval = _I2C_Master_Send_Byte(pHITI2C->pHI2C, &pHITI2C->pTxBuffPtr, (pHITI2C->TxXferCount) ? false : true);
+ if( rval == I2C_SwState_SUCCESS )
+ pHITI2C->TxXferCount--;
+
+ if( pHITI2C->TxXferCount == 0xFFFF )
+ {
+ pHITI2C->XferMode = I2C_XferMode_Idle;
+ }
+ }
+ else
+ {
+ uint8_t *pAddr = 0;
+
+ pHITI2C->DevAddress &= ~0x1u; // write mode
+
+ pAddr = (uint8_t*)&pHITI2C->DevAddress;
+ rval = _I2C_Master_Send_Byte(pHITI2C->pHI2C, &pAddr, false);
+ if( rval == I2C_SwState_SUCCESS )
+ pHITI2C->DevAddress |= 0x8000;
+ }
+ }
+ else if( pHITI2C->XferMode == I2C_XferMode_Recevie )
+ {
+ if( pHITI2C->DevAddress & 0x8000 )
+ {
+ rval = _I2C_Master_Recv_Byte(pHITI2C->pHI2C, &pHITI2C->pRxBuffPtr, (pHITI2C->RxXferCount - 2) ? false : true);
+ if( rval == I2C_SwState_SUCCESS )
+ pHITI2C->RxXferCount--;
+
+ if( pHITI2C->RxXferCount == 0 )
+ {
+ pHITI2C->XferMode = I2C_XferMode_Idle;
+ }
+ }
+ else
+ {
+ uint8_t *pAddr = 0;
+
+ pHITI2C->DevAddress |= 0x1u; // read mode
+
+ pAddr = (uint8_t*)&pHITI2C->DevAddress;
+ rval = _I2C_Master_Recv_Byte(pHITI2C->pHI2C, &pAddr, false);
+ if( rval == I2C_SwState_SUCCESS )
+ {
+ pHITI2C->DevAddress |= 0x8000;
+
+ /**
+ * send DevAddr+R and then receive data
+ * ps. Decrease the DevAddr+R byte
+ */
+ pHITI2C->RxXferCount++;
+ }
+ }
+ }
+
+ return;
+}
+
+void I2C_Slave_IRQHandler(I2C_IT_HandleTypeDef *pHITI2C)
+{
+ I2C_SwState rval = I2C_SwState_SUCCESS;
+
+ if( pHITI2C->XferMode == I2C_XferMode_Transmite )
+ {
+ bool HasRecvAddr = false;
+
+ // xfer data stage, if pHITI2C->TxXferCount == 0, I2C should send STOP-bit
+ rval = _I2C_Slave_Send_Byte(pHITI2C->pHI2C, &pHITI2C->pTxBuffPtr, &HasRecvAddr, (pHITI2C->TxXferCount) ? false : true);
+ pHITI2C->TxXferCount = (rval == I2C_SwState_SUCCESS) ? pHITI2C->TxXferCount - 1 :
+ (rval == I2C_SwState_FORCE_STOP) ? 0xFFFF :
+ pHITI2C->TxXferCount;
+
+ if( pHITI2C->TxXferCount == 0xFFFF )
+ {
+ pHITI2C->XferMode = I2C_XferMode_Idle;
+ }
+ }
+ else if( pHITI2C->XferMode == I2C_XferMode_Recevie )
+ {
+ rval = _I2C_Slave_Recv_Byte(pHITI2C->pHI2C, &pHITI2C->pRxBuffPtr, (pHITI2C->RxXferCount == 2));
+
+ pHITI2C->RxXferCount = (rval == I2C_SwState_SUCCESS) ? pHITI2C->RxXferCount - 1 :
+ (rval == I2C_SwState_FORCE_STOP) ? 0 :
+ pHITI2C->RxXferCount;
+
+ if( pHITI2C->RxXferCount == 0 )
+ {
+ pHITI2C->XferMode = I2C_XferMode_Idle;
+ }
+ }
+
+ return;
+}
+
+#endif /* CONFIG_ENABLE_HAL_I2C */
diff --git a/Drivers/PB5700/HAL_Lib/src/hal_lptim.c b/Drivers/PEC930/HAL_Lib/src/hal_lptim.c
similarity index 96%
rename from Drivers/PB5700/HAL_Lib/src/hal_lptim.c
rename to Drivers/PEC930/HAL_Lib/src/hal_lptim.c
index a8a626d..feb9f1c 100644
--- a/Drivers/PB5700/HAL_Lib/src/hal_lptim.c
+++ b/Drivers/PEC930/HAL_Lib/src/hal_lptim.c
@@ -53,18 +53,18 @@ void LPTIM_Init(LPTIM_Type *pHLpTim, LPTIM_InitTypeDef *pInit)
{
if( pHLpTim == LPTIM )
{
- // ToDo: reset module
+ __HAL_SYSCFG_RESET_LPTIM();
__HAL_SYSCFG_LPTIM_CLK_ENABLE();
REG_WRITE_MASK(pHLpTim->TCR, LPTIM_TCR_CLKS_Msk, pInit->LPTIM_ClockSource);
}
else if( pHLpTim == TIM0 )
{
- // ToDo: reset module
+ __HAL_SYSCFG_RESET_TIM0();
__HAL_SYSCFG_TIM0_CLK_ENABLE();
}
else if( pHLpTim == TIM1 )
{
- // ToDo: reset module
+ __HAL_SYSCFG_RESET_TIM1();
__HAL_SYSCFG_TIM1_CLK_ENABLE();
}
diff --git a/Drivers/PB5700/HAL_Lib/src/hal_opamp.c b/Drivers/PEC930/HAL_Lib/src/hal_opamp.c
similarity index 100%
rename from Drivers/PB5700/HAL_Lib/src/hal_opamp.c
rename to Drivers/PEC930/HAL_Lib/src/hal_opamp.c
diff --git a/Drivers/PB5700/HAL_Lib/src/hal_pwr.c b/Drivers/PEC930/HAL_Lib/src/hal_pwr.c
similarity index 54%
rename from Drivers/PB5700/HAL_Lib/src/hal_pwr.c
rename to Drivers/PEC930/HAL_Lib/src/hal_pwr.c
index e104a8d..72175cb 100644
--- a/Drivers/PB5700/HAL_Lib/src/hal_pwr.c
+++ b/Drivers/PEC930/HAL_Lib/src/hal_pwr.c
@@ -18,8 +18,12 @@
//=============================================================================
// Constant Definition
//=============================================================================
-#define __PWR_WAIT_RECHARGE() do{ __NOP(); __NOP(); __NOP(); __NOP(); \
- }while(0)
+#if 1
+ #define __PWR_WAIT_RECHARGE() do{ __NOP(); __NOP(); __NOP(); __NOP(); \
+ }while(0)
+#else
+ #define __PWR_WAIT_RECHARGE()
+#endif
//=============================================================================
// Macro Definition
//=============================================================================
@@ -39,31 +43,31 @@
//=============================================================================
// Public Function Definition
//=============================================================================
-void PWR_SetAutoWakeUp(uint32_t msec)
+void PWR_EnterSleepMode(CallbaskPreSleepTypeDef cb_pre_set,
+ CallbaskPostSleepTypeDef cb_post_set)
{
- sys_config_systick(msec * SYS_TICK_1_MS);
- return;
-}
+ int wakeup_type = 0;
-void PWR_EnterSleepMode(CallbaskPreDeepsleepTypeDef cb_pre_set,
- CallbaskPostDeepsleepTypeDef cb_post_set)
-{
sys_disable_girq();
if( cb_pre_set )
- cb_pre_set();
+ cb_pre_set(PWR_Mode_Sleep, (PWR_WakeupTypeDef*)&wakeup_type);
+
+ __HAL_SYSCFG_AMISC_CLK_ENABLE();
+
+ AMISC_SetHSIPwrSrc(AMISC_HSIPwrSrc_LowPower);
+
+ REG_WRITE(AMISC->DAC_CR, 0x0ul); // Off DAC leakage
__set_wfi_sleepmode(WFI_SHALLOW_SLEEP);
- SYSCFG_SetLowPower(true);
-
__WFI();
- __PWR_WAIT_RECHARGE();
+ /* __PWR_WAIT_RECHARGE(); */
if( cb_post_set )
- cb_post_set();
+ cb_post_set(PWR_Mode_Sleep);
- SYSCFG_SetLowPower(false);
+ AMISC_SetHSIPwrSrc(AMISC_HSIPwrSrc_Normal);
sys_enable_girq();
@@ -71,26 +75,55 @@ void PWR_EnterSleepMode(CallbaskPreDeepsleepTypeDef cb_pre_set,
}
-void PWR_EnterDeepSleepMode(CallbaskPreDeepsleepTypeDef cb_pre_set,
- CallbaskPostDeepsleepTypeDef cb_post_set)
+void PWR_EnterDeepSleepMode(CallbaskPreSleepTypeDef cb_pre_set,
+ CallbaskPostSleepTypeDef cb_post_set)
{
+ uint32_t value = 0;
+ int wakeup_type = 0;
+
sys_disable_girq();
if( cb_pre_set )
- cb_pre_set();
+ cb_pre_set(PWR_Mode_DeepSleep, (PWR_WakeupTypeDef*)&wakeup_type);
- __set_wfi_sleepmode(WFI_DEEP_SLEEP);
+ __HAL_SYSCFG_AMISC_CLK_ENABLE();
+
+ AMISC_SetHSIPwrSrc(AMISC_HSIPwrSrc_LowPower);
+
+ REG_WRITE(AMISC->DAC_CR, 0x0ul); // Off DAC leakage
SYSCFG_SetLowPower(true);
+ /* Close the clocks of all peripheral */
+ value = 0x0ul;
+ if( wakeup_type & PWR_Wakeup_LpTIM )
+ {
+ value |= SYSCFG_PCLKEN_LPTIM_Msk;
+ }
+
+ if( wakeup_type & PWR_Wakeup_WDG )
+ {
+ value |= SYSCFG_PCLKEN_WDG_Msk;
+ }
+
+ REG_WRITE(SYSCFG->PCLKEN, value);
+
+ REG_WRITE(SYSCFG->HCLKEN, SYSCFG_HCLKEN_GPIOB_Msk | SYSCFG_HCLKEN_GPIOA_Msk);
+
+ __set_wfi_sleepmode(WFI_DEEP_SLEEP);
+
__WFI();
__PWR_WAIT_RECHARGE();
- if( cb_post_set )
- cb_post_set();
-
SYSCFG_SetLowPower(false);
+ __HAL_SYSCFG_AMISC_CLK_ENABLE();
+ AMISC_SetHSIPwrSrc(AMISC_HSIPwrSrc_Normal);
+ __HAL_SYSCFG_AMISC_CLK_DISABLE();
+
+ if( cb_post_set )
+ cb_post_set(PWR_Mode_DeepSleep);
+
sys_enable_girq();
return;
diff --git a/Drivers/PB5700/HAL_Lib/src/hal_spi.c b/Drivers/PEC930/HAL_Lib/src/hal_spi.c
similarity index 100%
rename from Drivers/PB5700/HAL_Lib/src/hal_spi.c
rename to Drivers/PEC930/HAL_Lib/src/hal_spi.c
diff --git a/Drivers/PB5700/HAL_Lib/src/hal_syscfg.c b/Drivers/PEC930/HAL_Lib/src/hal_syscfg.c
similarity index 100%
rename from Drivers/PB5700/HAL_Lib/src/hal_syscfg.c
rename to Drivers/PEC930/HAL_Lib/src/hal_syscfg.c
diff --git a/Drivers/PB5700/HAL_Lib/src/hal_tim.c b/Drivers/PEC930/HAL_Lib/src/hal_tim.c
similarity index 91%
rename from Drivers/PB5700/HAL_Lib/src/hal_tim.c
rename to Drivers/PEC930/HAL_Lib/src/hal_tim.c
index cf57036..48a617f 100644
--- a/Drivers/PB5700/HAL_Lib/src/hal_tim.c
+++ b/Drivers/PEC930/HAL_Lib/src/hal_tim.c
@@ -494,6 +494,20 @@ void TIM_Cmd(TIM_Type *tim, FunctionalState state)
(tim->CR1 &= ~(0x01U << TIM_CR1_CEN_Pos));
}
+/**
+ * @brief Enables or disables the Asymmetric Mode.
+ * @param tim: select the TIM peripheral.
+ * @param state: new state of the tim peripheral.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None.
+ */
+void TIM_ASYMEN_Cmd(TIM_Type *tim, FunctionalState state)
+{
+ (state) ? \
+ (tim->CR1 |= (0x01U << TIM_CR1_ASYMEN_Pos)) : \
+ (tim->CR1 &= ~(0x01U << TIM_CR1_ASYMEN_Pos));
+}
+
/**
* @brief Enables or disables the TIM peripheral Main Outputs.
* @param tim: select the TIM peripheral.
@@ -622,10 +636,38 @@ void TIM_PrescalerConfig(TIM_Type *tim, uint16_t prescaler, uint16_t reloadMode)
tim->EGR = reloadMode;
}
-#if 0
+
+/**
+ * @brief Configures the External clock Mode1
+ * @param TIMx: where x can be 2, EPWM to select the TIM peripheral.
+ * @param TIM_ExtTRGPrescaler: The external Trigger Prescaler.
+ * This parameter can be one of the following values:
+ * @arg TIM_ExtTRGPSC_OFF: ETRP Prescaler OFF.
+ * @arg TIM_ExtTRGPSC_DIV2: ETRP frequency divided by 2.
+ * @arg TIM_ExtTRGPSC_DIV4: ETRP frequency divided by 4.
+ * @arg TIM_ExtTRGPSC_DIV8: ETRP frequency divided by 8.
+ * @param TIM_ExtTRGPolarity: The external Trigger Polarity.
+ * This parameter can be one of the following values:
+ * @arg TIM_ExtTRGPolarity_Inverted: active low or falling edge active.
+ * @arg TIM_ExtTRGPolarity_NonInverted: active high or rising edge active.
+ * @param ExtTRGFilter: External Trigger Filter.
+ * This parameter must be a value between 0x00 and 0x0F
+ * @retval None
+ */
+void TIM_ETRClockMode1Config(TIM_Type *tim, uint16_t TIM_ExtTRGPrescaler, uint16_t TIM_ExtTRGPolarity, uint16_t ExtTRGFilter)
+{
+ /* Configure the ETR Clock source */
+ TIM_ETRConfig(tim, TIM_ExtTRGPrescaler, TIM_ExtTRGPolarity, ExtTRGFilter);
+
+ /* Select the External clock mode1 . Select the Trigger selection : ETRF */
+ REG_WRITE_MASK(tim->SMCR, TIM_SMCR_SMS_Msk | TIM_SMCR_TS_Msk , TIM_SlaveMode_External1 | TIM_TS_ETRF );
+}
+
+
+
/**
* @brief Configures the TIMx Trigger as External Clock
- * @param TIMx: where x can be 1, 2, 3, 4, 5, 9, 12 or 15 to select the TIM peripheral.
+ * @param TIMx: where x can be 2, EPWM to select the TIM peripheral.
* @param TIM_TIxExternalCLKSource: Trigger source.
* This parameter can be one of the following values:
* @arg TIM_TIxExternalCLK1Source_TI1ED: TI1 Edge Detector
@@ -639,8 +681,7 @@ void TIM_PrescalerConfig(TIM_Type *tim, uint16_t prescaler, uint16_t reloadMode)
* This parameter must be a value between 0x0 and 0xF.
* @retval None
*/
-void TIM_TIxExternalClockConfig(TIM_Type *TIMx, uint16_t TIM_TIxExternalCLKSource,
- uint16_t TIM_ICPolarity, uint16_t ICFilter)
+void TIM_TIxExternalClockConfig(TIM_Type *TIMx, uint16_t TIM_TIxExternalCLKSource, uint16_t TIM_ICPolarity, uint16_t ICFilter)
{
/* Configure the Timer Input Clock Source */
@@ -650,46 +691,9 @@ void TIM_TIxExternalClockConfig(TIM_Type *TIMx, uint16_t TIM_TIxExternalCLKSourc
TIMx->SMCR |= TIM_SlaveMode_External1;
}
-/**
- * @brief Configures the External clock Mode1
- * @param TIMx: where x can be 1, 2, 3, 4, 5 or 8 to select the TIM peripheral.
- * @param TIM_ExtTRGPrescaler: The external Trigger Prescaler.
- * This parameter can be one of the following values:
- * @arg TIM_ExtTRGPSC_OFF: ETRP Prescaler OFF.
- * @arg TIM_ExtTRGPSC_DIV2: ETRP frequency divided by 2.
- * @arg TIM_ExtTRGPSC_DIV4: ETRP frequency divided by 4.
- * @arg TIM_ExtTRGPSC_DIV8: ETRP frequency divided by 8.
- * @param TIM_ExtTRGPolarity: The external Trigger Polarity.
- * This parameter can be one of the following values:
- * @arg TIM_ExtTRGPolarity_Inverted: active low or falling edge active.
- * @arg TIM_ExtTRGPolarity_NonInverted: active high or rising edge active.
- * @param ExtTRGFilter: External Trigger Filter.
- * This parameter must be a value between 0x00 and 0x0F
- * @retval None
- */
-void TIM_ETRClockMode1Config(TIM_Type *TIMx, uint16_t TIM_ExtTRGPrescaler, uint16_t TIM_ExtTRGPolarity,
- uint16_t ExtTRGFilter)
-{
- uint16_t tmpsmcr = 0;
- /* Configure the ETR Clock source */
- TIM_ETRConfig(TIMx, TIM_ExtTRGPrescaler, TIM_ExtTRGPolarity, ExtTRGFilter);
-
- /* Get the TIMx SMCR register value */
- tmpsmcr = TIMx->SMCR;
- /* Reset the SMS Bits */
- tmpsmcr &= (uint16_t)(~((uint16_t)TIM_SMCR_SMS_Msk));
- /* Select the External clock mode1 */
- tmpsmcr |= TIM_SlaveMode_External1;
- /* Select the Trigger selection : ETRF */
- tmpsmcr &= (uint16_t)(~((uint16_t)TIM_SMCR_TS_Msk));
- tmpsmcr |= TIM_TS_ETRF;
- /* Write to TIMx SMCR */
- TIMx->SMCR = tmpsmcr;
-}
-
/**
* @brief Configures the External clock Mode2
- * @param TIMx: where x can be 1, 2, 3, 4, 5 or 8 to select the TIM peripheral.
+ * @param TIMx: where x can be 2, EPWM to select the TIM peripheral.
* @param TIM_ExtTRGPrescaler: The external Trigger Prescaler.
* This parameter can be one of the following values:
* @arg TIM_ExtTRGPSC_OFF: ETRP Prescaler OFF.
@@ -704,18 +708,17 @@ void TIM_ETRClockMode1Config(TIM_Type *TIMx, uint16_t TIM_ExtTRGPrescaler, uint1
* This parameter must be a value between 0x00 and 0x0F
* @retval None
*/
-void TIM_ETRClockMode2Config(TIM_Type *TIMx, uint16_t TIM_ExtTRGPrescaler,
- uint16_t TIM_ExtTRGPolarity, uint16_t ExtTRGFilter)
+void TIM_ETRClockMode2Config(TIM_Type *tim, uint16_t TIM_ExtTRGPrescaler, uint16_t TIM_ExtTRGPolarity, uint16_t ExtTRGFilter)
{
/* Configure the ETR Clock source */
- TIM_ETRConfig(TIMx, TIM_ExtTRGPrescaler, TIM_ExtTRGPolarity, ExtTRGFilter);
+ TIM_ETRConfig(tim, TIM_ExtTRGPrescaler, TIM_ExtTRGPolarity, ExtTRGFilter);
/* Enable the External clock mode2 */
- TIMx->SMCR |= TIM_SMCR_ECE_Msk;
+ tim->SMCR |= TIM_SMCR_ECE_Msk;
}
/**
* @brief Configures the TIMx External Trigger (ETR).
- * @param TIMx: where x can be 1, 2, 3, 4, 5 or 8 to select the TIM peripheral.
+ * @param TIMx: where x can be 2, EPWM to select the TIM peripheral.
* @param TIM_ExtTRGPrescaler: The external Trigger Prescaler.
* This parameter can be one of the following values:
* @arg TIM_ExtTRGPSC_OFF: ETRP Prescaler OFF.
@@ -730,19 +733,10 @@ void TIM_ETRClockMode2Config(TIM_Type *TIMx, uint16_t TIM_ExtTRGPrescaler,
* This parameter must be a value between 0x00 and 0x0F
* @retval None
*/
-void TIM_ETRConfig(TIM_Type *TIMx, uint16_t TIM_ExtTRGPrescaler, uint16_t TIM_ExtTRGPolarity,
- uint16_t ExtTRGFilter)
+void TIM_ETRConfig(TIM_Type *tim, uint16_t TIM_ExtTRGPrescaler, uint16_t TIM_ExtTRGPolarity,uint16_t ExtTRGFilter)
{
- uint16_t tmpsmcr = 0;
- tmpsmcr = TIMx->SMCR;
- /* Reset the ETR Bits */
- tmpsmcr &= SMCR_ETR_Mask;
- /* Set the Prescaler, the Filter value and the Polarity */
- tmpsmcr |= (uint16_t)(TIM_ExtTRGPrescaler | (uint16_t)(TIM_ExtTRGPolarity | (uint16_t)(ExtTRGFilter << (uint16_t)8)));
- /* Write to TIMx SMCR */
- TIMx->SMCR = tmpsmcr;
+ REG_WRITE_MASK(tim->SMCR, TIM_SMCR_ETPS_Msk | TIM_SMCR_ETP_Msk | TIM_SMCR_ETF_Msk,TIM_ExtTRGPrescaler | TIM_ExtTRGPolarity | ExtTRGFilter << TIM_SMCR_ETF_Pos);
}
-#endif
/**
* @brief Specifies the tim Counter Mode to be used.
@@ -1386,6 +1380,49 @@ void TIM_SetCompare4(TIM_Type *tim, uint32_t compare)
tim->CCR4 = (uint16_t)compare;
}
+/**
+ * @brief Sets the tim Downwards Compare1 Register value
+ * @param tim: select the TIM peripheral.
+ * @param compare: specifies the Capture Compare1 register new value.
+ * @retval None.
+ */
+void TIM_SetDownCompare1(TIM_Type *tim, uint32_t compare)
+{
+ tim->CCDR1 = (uint16_t)compare;
+}
+
+/**
+ * @brief Sets the tim Downwards Compare2 Register value
+ * @param tim: select the TIM peripheral.
+ * @param compare: specifies the Capture Compare2 register new value.
+ * @retval None.
+ */
+void TIM_SetDownCompare2(TIM_Type *tim, uint32_t compare)
+{
+ tim->CCDR2 = (uint16_t)compare;
+}
+
+/**
+ * @brief Sets the tim Downwards Compare3 Register value
+ * @param tim: select the TIM peripheral.
+ * @param compare: specifies the Capture Compare3 register new value.
+ * @retval None.
+ */
+void TIM_SetDownCompare3(TIM_Type *tim, uint32_t compare)
+{
+ tim->CCDR3 = (uint16_t)compare;
+}
+
+/**
+ * @brief Sets the tim Downwards Compare4 Register value
+ * @param tim: select the TIM peripheral.
+ * @param compare: specifies the Capture Compare4 register new value.
+ * @retval None.
+ */
+void TIM_SetDownCompare4(TIM_Type *tim, uint32_t compare)
+{
+ tim->CCDR4 = (uint16_t)compare;
+}
/**
* @brief Gets the tim Input Capture 1 value.
@@ -1541,9 +1578,6 @@ void TIM_ClearITPendingBit(TIM_Type *tim, uint32_t it)
tim->SR &= ~it;
}
-
-
-
/**
* @brief Checks whether the specified TIM flag is set or not.
* @param tim: select the TIM peripheral.
@@ -1554,4 +1588,60 @@ FlagStatus TIM_GetCountDirection(TIM_Type *tim)
return ((tim->CR1 &TIM_CR1_DIR_Msk) ? SET : RESET);
}
+/**
+ * @brief Clears or safeguards the OCREF1 signal on an external event
+ * @param tim: where tim can be 2,EPWM to select the TIM peripheral.
+ * @param TIM_OCClear: new state of the Output Compare Clear Enable Bit.
+ * This parameter can be one of the following values:
+ * @arg TIM_OCClear_Enable: TIM Output clear enable
+ * @arg TIM_OCClear_Disable: TIM Output clear disable
+ * @retval None
+ */
+void TIM_ClearOC1Ref(TIM_Type *tim, uint16_t TIM_OCClear)
+{
+ REG_WRITE_MASK(TIM->CCMR1_OUTPUT, TIM_CCMR1_OUTPUT_OC1CE_Msk, TIM_OCClear);
+}
+
+/**
+ * @brief Clears or safeguards the OCREF2 signal on an external event
+ * @param tim: where tim can be 2,EPWM to select the TIM peripheral.
+ * @param TIM_OCClear: new state of the Output Compare Clear Enable Bit.
+ * This parameter can be one of the following values:
+ * @arg TIM_OCClear_Enable: TIM Output clear enable
+ * @arg TIM_OCClear_Disable: TIM Output clear disable
+ * @retval None
+ */
+void TIM_ClearOC2Ref(TIM_Type *tim, uint16_t TIM_OCClear)
+{
+ REG_WRITE_MASK(TIM->CCMR1_OUTPUT, TIM_CCMR1_OUTPUT_OC2CE_Msk, TIM_OCClear << 8);
+}
+
+/**
+ * @brief Clears or safeguards the OCREF3 signal on an external event
+ * @param tim: where tim can be 2,EPWM to select the TIM peripheral.
+ * @param TIM_OCClear: new state of the Output Compare Clear Enable Bit.
+ * This parameter can be one of the following values:
+ * @arg TIM_OCClear_Enable: TIM Output clear enable
+ * @arg TIM_OCClear_Disable: TIM Output clear disable
+ * @retval None
+ */
+void TIM_ClearOC3Ref(TIM_Type *tim, uint16_t TIM_OCClear)
+{
+ REG_WRITE_MASK(TIM->CCMR2_OUTPUT, TIM_CCMR2_OUTPUT_OC3CE_Msk, TIM_OCClear);
+}
+
+/**
+ * @brief Clears or safeguards the OCREF4 signal on an external event
+ * @param tim: where tim can be 2,EPWM to select the TIM peripheral.
+ * @param TIM_OCClear: new state of the Output Compare Clear Enable Bit.
+ * This parameter can be one of the following values:
+ * @arg TIM_OCClear_Enable: TIM Output clear enable
+ * @arg TIM_OCClear_Disable: TIM Output clear disable
+ * @retval None
+ */
+void TIM_ClearOC4Ref(TIM_Type *tim, uint16_t TIM_OCClear)
+{
+ REG_WRITE_MASK(TIM->CCMR2_OUTPUT, TIM_CCMR2_OUTPUT_OC4CE_Msk, TIM_OCClear << 8);
+}
+
#endif /* CONFIG_ENABLE_HAL_TIM2 || CONFIG_ENABLE_HAL_EPWM */
diff --git a/Drivers/PB5700/HAL_Lib/src/hal_uart.c b/Drivers/PEC930/HAL_Lib/src/hal_uart.c
similarity index 100%
rename from Drivers/PB5700/HAL_Lib/src/hal_uart.c
rename to Drivers/PEC930/HAL_Lib/src/hal_uart.c
diff --git a/Drivers/PB5700/HAL_Lib/src/hal_wdg.c b/Drivers/PEC930/HAL_Lib/src/hal_wdg.c
similarity index 90%
rename from Drivers/PB5700/HAL_Lib/src/hal_wdg.c
rename to Drivers/PEC930/HAL_Lib/src/hal_wdg.c
index 4fe5a86..97066c2 100644
--- a/Drivers/PB5700/HAL_Lib/src/hal_wdg.c
+++ b/Drivers/PEC930/HAL_Lib/src/hal_wdg.c
@@ -62,15 +62,16 @@ void WDG_BaseStructInit(WDG_BaseInitTypeDef *init_struct)
*/
void WDG_BaseInit( WDG_BaseInitTypeDef *init_struct)
{
- __HAL_SYSCFG_WDG_CLK_ENABLE();
+ __HAL_SYSCFG_RESET_WDG();
+ __HAL_SYSCFG_WDG_CLK_ENABLE();
- WDG_Unlock();
+ WDG_Unlock();
- WDG->LOAD = init_struct->Relaod;
- REG_WRITE_MASK(WDG->CR, WDG_CR_RSTE_Msk, init_struct->Reset);
- REG_WRITE_MASK(WDG->CR, WDG_CR_DBGE_Msk, init_struct->Debug);
+ WDG->LOAD = init_struct->Relaod;
+ REG_WRITE_MASK(WDG->CR, WDG_CR_RSTE_Msk, init_struct->Reset);
+ REG_WRITE_MASK(WDG->CR, WDG_CR_DBGE_Msk, init_struct->Debug);
- WDG_Clear();
+ WDG_Clear();
}
@@ -94,7 +95,7 @@ void WDG_SetReload(uint32_t reload)
*/
void WDG_Enable(void)
{
- REG_SET_BITS(WDG->CR, WDG_CR_INTE_Msk);
+ REG_SET_BITS(WDG->CR, WDG_CR_INTE_Msk);
}
/**
@@ -104,7 +105,7 @@ void WDG_Enable(void)
*/
void WDG_Disable(void)
{
- REG_CLR_BITS(WDG->CR, WDG_CR_INTE_Msk);
+ REG_CLR_BITS(WDG->CR, WDG_CR_INTE_Msk);
}
/**
@@ -161,7 +162,7 @@ uint32_t WDG_GetMIF(uint32_t mif_bit_mask)
*/
void WDG_Unlock(void)
{
- WDG->LOCK = 0x1ACCE551;
+ WDG->LOCK = 0x1ACCE551;
}
/**
* @brief Lock the WDG so thatit cannot be overwritten
@@ -170,7 +171,7 @@ void WDG_Unlock(void)
*/
void WDG_Lock(void)
{
- WDG->LOCK = 0;
+ WDG->LOCK = 0;
}
/**
* @brief Get WDG lock status. This Value is only read.
diff --git a/Drivers/PB5700/NMSIS/Core/Include/core_compatiable.h b/Drivers/PEC930/NMSIS/Core/Include/core_compatiable.h
similarity index 100%
rename from Drivers/PB5700/NMSIS/Core/Include/core_compatiable.h
rename to Drivers/PEC930/NMSIS/Core/Include/core_compatiable.h
diff --git a/Drivers/PB5700/NMSIS/Core/Include/core_feature_base.h b/Drivers/PEC930/NMSIS/Core/Include/core_feature_base.h
similarity index 100%
rename from Drivers/PB5700/NMSIS/Core/Include/core_feature_base.h
rename to Drivers/PEC930/NMSIS/Core/Include/core_feature_base.h
diff --git a/Drivers/PB5700/NMSIS/Core/Include/core_feature_bitmanip.h b/Drivers/PEC930/NMSIS/Core/Include/core_feature_bitmanip.h
similarity index 100%
rename from Drivers/PB5700/NMSIS/Core/Include/core_feature_bitmanip.h
rename to Drivers/PEC930/NMSIS/Core/Include/core_feature_bitmanip.h
diff --git a/Drivers/PB5700/NMSIS/Core/Include/core_feature_cache.h b/Drivers/PEC930/NMSIS/Core/Include/core_feature_cache.h
similarity index 100%
rename from Drivers/PB5700/NMSIS/Core/Include/core_feature_cache.h
rename to Drivers/PEC930/NMSIS/Core/Include/core_feature_cache.h
diff --git a/Drivers/PB5700/NMSIS/Core/Include/core_feature_cidu.h b/Drivers/PEC930/NMSIS/Core/Include/core_feature_cidu.h
similarity index 100%
rename from Drivers/PB5700/NMSIS/Core/Include/core_feature_cidu.h
rename to Drivers/PEC930/NMSIS/Core/Include/core_feature_cidu.h
diff --git a/Drivers/PB5700/NMSIS/Core/Include/core_feature_dsp.h b/Drivers/PEC930/NMSIS/Core/Include/core_feature_dsp.h
similarity index 99%
rename from Drivers/PB5700/NMSIS/Core/Include/core_feature_dsp.h
rename to Drivers/PEC930/NMSIS/Core/Include/core_feature_dsp.h
index 6a7e5a1..5fb3c67 100644
--- a/Drivers/PB5700/NMSIS/Core/Include/core_feature_dsp.h
+++ b/Drivers/PEC930/NMSIS/Core/Include/core_feature_dsp.h
@@ -19569,7 +19569,7 @@ __STATIC_FORCEINLINE unsigned long __RV_DREDAS16(unsigned long long a)
* Do halfs reduced subtraction and halfs reduced addition from a register. The result is written to Rd.
*
* **Description**:\n
- * For the `DREDSA16` instruction, add the top 16-bit Q15 element from the bottom 16-bit Q15 element of the bottom 32-bit Q31 content of 64-bit chunks in Rs1. At the same time, subtract the the top16-bit Q15 element with the bottom16-bit Q15 element of the top 32-bit Q31 content of 64-bit chunks in Rs1. The two Q15 results are then written into Rd.
+ * For the `DREDSA16` instruction, add the top 16-bit Q15 element from the bottom 16-bit Q15 element of the bottom 32-bit Q31 content of 64-bit chunks in Rs1. At the same time, subtract the the top16-bit Q15 element with the bottom16-bit Q15 element of the top 32-bit Q31 content of 64-bit chunks in Rs1. The two Q15 results are then written into Rd.
*
* **Operations**:\n
* ~~~
@@ -20445,7 +20445,7 @@ __STATIC_FORCEINLINE unsigned long long __RV_DPKBT16(unsigned long long a, unsig
*
* **Purpose**:\n
* Pack 16-bit data from 32-bit chunks in two registers.
- * * PKTT16 top.top
+ * * PKTT16 top.top
*
* **Description**:\n
* This instruction moves Rs1.W[x] [31:16] to Rd.W[x] [31:16] and moves Rs2.W[x] [31:16] to Rd.W[x] [15:0].
@@ -23979,7 +23979,7 @@ __STATIC_FORCEINLINE long __RV_DMADA32(long long t, unsigned long long a, unsign
*
* **Purpose**:\n
* Multiply the signed 16-bit content of the 32-bit elements of a register with the 16-bit content of the corresponding 32-bit
- * elements of another register and add the results with a 64-bit value of an even/odd pair of registers. The addition result
+ * elements of another register and add the results with a 64-bit value of an even/odd pair of registers. The addition result
* is written back to the register-pair.
* * DSMALBB: rt pair + bottom*bottom (all 32-bit elements)
*
diff --git a/Drivers/PB5700/NMSIS/Core/Include/core_feature_eclic.h b/Drivers/PEC930/NMSIS/Core/Include/core_feature_eclic.h
similarity index 100%
rename from Drivers/PB5700/NMSIS/Core/Include/core_feature_eclic.h
rename to Drivers/PEC930/NMSIS/Core/Include/core_feature_eclic.h
diff --git a/Drivers/PB5700/NMSIS/Core/Include/core_feature_fpu.h b/Drivers/PEC930/NMSIS/Core/Include/core_feature_fpu.h
similarity index 100%
rename from Drivers/PB5700/NMSIS/Core/Include/core_feature_fpu.h
rename to Drivers/PEC930/NMSIS/Core/Include/core_feature_fpu.h
diff --git a/Drivers/PB5700/NMSIS/Core/Include/core_feature_plic.h b/Drivers/PEC930/NMSIS/Core/Include/core_feature_plic.h
similarity index 100%
rename from Drivers/PB5700/NMSIS/Core/Include/core_feature_plic.h
rename to Drivers/PEC930/NMSIS/Core/Include/core_feature_plic.h
diff --git a/Drivers/PB5700/NMSIS/Core/Include/core_feature_pmp.h b/Drivers/PEC930/NMSIS/Core/Include/core_feature_pmp.h
similarity index 100%
rename from Drivers/PB5700/NMSIS/Core/Include/core_feature_pmp.h
rename to Drivers/PEC930/NMSIS/Core/Include/core_feature_pmp.h
diff --git a/Drivers/PB5700/NMSIS/Core/Include/core_feature_spmp.h b/Drivers/PEC930/NMSIS/Core/Include/core_feature_spmp.h
similarity index 100%
rename from Drivers/PB5700/NMSIS/Core/Include/core_feature_spmp.h
rename to Drivers/PEC930/NMSIS/Core/Include/core_feature_spmp.h
diff --git a/Drivers/PB5700/NMSIS/Core/Include/core_feature_timer.h b/Drivers/PEC930/NMSIS/Core/Include/core_feature_timer.h
similarity index 100%
rename from Drivers/PB5700/NMSIS/Core/Include/core_feature_timer.h
rename to Drivers/PEC930/NMSIS/Core/Include/core_feature_timer.h
diff --git a/Drivers/PB5700/NMSIS/Core/Include/core_feature_vector.h b/Drivers/PEC930/NMSIS/Core/Include/core_feature_vector.h
similarity index 100%
rename from Drivers/PB5700/NMSIS/Core/Include/core_feature_vector.h
rename to Drivers/PEC930/NMSIS/Core/Include/core_feature_vector.h
diff --git a/Drivers/PB5700/NMSIS/Core/Include/nmsis_bench.h b/Drivers/PEC930/NMSIS/Core/Include/nmsis_bench.h
similarity index 100%
rename from Drivers/PB5700/NMSIS/Core/Include/nmsis_bench.h
rename to Drivers/PEC930/NMSIS/Core/Include/nmsis_bench.h
diff --git a/Drivers/PB5700/NMSIS/Core/Include/nmsis_compiler.h b/Drivers/PEC930/NMSIS/Core/Include/nmsis_compiler.h
similarity index 100%
rename from Drivers/PB5700/NMSIS/Core/Include/nmsis_compiler.h
rename to Drivers/PEC930/NMSIS/Core/Include/nmsis_compiler.h
diff --git a/Drivers/PB5700/NMSIS/Core/Include/nmsis_core.h b/Drivers/PEC930/NMSIS/Core/Include/nmsis_core.h
similarity index 100%
rename from Drivers/PB5700/NMSIS/Core/Include/nmsis_core.h
rename to Drivers/PEC930/NMSIS/Core/Include/nmsis_core.h
diff --git a/Drivers/PB5700/NMSIS/Core/Include/nmsis_gcc.h b/Drivers/PEC930/NMSIS/Core/Include/nmsis_gcc.h
similarity index 100%
rename from Drivers/PB5700/NMSIS/Core/Include/nmsis_gcc.h
rename to Drivers/PEC930/NMSIS/Core/Include/nmsis_gcc.h
diff --git a/Drivers/PB5700/NMSIS/Core/Include/nmsis_iar.h b/Drivers/PEC930/NMSIS/Core/Include/nmsis_iar.h
similarity index 100%
rename from Drivers/PB5700/NMSIS/Core/Include/nmsis_iar.h
rename to Drivers/PEC930/NMSIS/Core/Include/nmsis_iar.h
diff --git a/Drivers/PB5700/NMSIS/Core/Include/nmsis_version.h b/Drivers/PEC930/NMSIS/Core/Include/nmsis_version.h
similarity index 100%
rename from Drivers/PB5700/NMSIS/Core/Include/nmsis_version.h
rename to Drivers/PEC930/NMSIS/Core/Include/nmsis_version.h
diff --git a/Drivers/PB5700/NMSIS/Core/Include/riscv_bits.h b/Drivers/PEC930/NMSIS/Core/Include/riscv_bits.h
similarity index 100%
rename from Drivers/PB5700/NMSIS/Core/Include/riscv_bits.h
rename to Drivers/PEC930/NMSIS/Core/Include/riscv_bits.h
diff --git a/Drivers/PB5700/NMSIS/Core/Include/riscv_encoding.h b/Drivers/PEC930/NMSIS/Core/Include/riscv_encoding.h
similarity index 100%
rename from Drivers/PB5700/NMSIS/Core/Include/riscv_encoding.h
rename to Drivers/PEC930/NMSIS/Core/Include/riscv_encoding.h
diff --git a/Drivers/PEC930/component.mk b/Drivers/PEC930/component.mk
new file mode 100644
index 0000000..79a155e
--- /dev/null
+++ b/Drivers/PEC930/component.mk
@@ -0,0 +1,92 @@
+#
+# component Makefile
+#
+
+
+#=======================================
+# Configurations
+#=======================================
+
+#
+# Drivers of MCU
+#
+
+SOC_CPU_NAME = n203e
+
+#=======================================
+# system
+#=======================================
+ifeq ("$(SOC)","pec930")
+ C_DEFS += -DCONFIG_USE_PEC930
+else
+$(error "Unknown SoC !!!")
+endif
+
+#
+# cpu
+#
+C_DEFS += -DCONFIG_CPU_N203E -DCONFIG_HAS_BPU
+
+CPU_FLAGS = -mabi=ilp32e -mcmodel=medlow
+CPU_FLAGS += -march=rv32emc_zba_zbb_zbs_zca_zcb_zcmp_zcmt_zicond
+
+
+#
+# Source
+#
+ASM_SOURCES := \
+ $(srctree)/Drivers/PEC930/Device/src/Startup/startup.S \
+ $(srctree)/Drivers/PEC930/Device/src/Startup/trap.S
+
+C_SOURCES += \
+ $(srctree)/Drivers/PEC930/Device/src/interrupt.c \
+ $(srctree)/Drivers/PEC930/Device/src/syscalls.c \
+ $(srctree)/Drivers/PEC930/Device/src/system_dev.c
+
+C_INCLUDES += \
+ -I$(srctree)/Drivers/PEC930/Device/inc \
+ -I$(srctree)/Drivers/PEC930/NMSIS/Core/Include \
+ -I$(srctree)/Drivers/PEC930/
+
+
+
+#=======================================
+# peripheral hal driver
+#=======================================
+C_SOURCES += \
+ $(srctree)/Drivers/PEC930/HAL_Lib/src/hal_adc.c \
+ $(srctree)/Drivers/PEC930/HAL_Lib/src/hal_amisc.c \
+ $(srctree)/Drivers/PEC930/HAL_Lib/src/hal_comp.c \
+ $(srctree)/Drivers/PEC930/HAL_Lib/src/hal_opamp.c \
+ $(srctree)/Drivers/PEC930/HAL_Lib/src/hal_crc.c \
+ $(srctree)/Drivers/PEC930/HAL_Lib/src/hal_dsp.c \
+ $(srctree)/Drivers/PEC930/HAL_Lib/src/hal_flash.c \
+ $(srctree)/Drivers/PEC930/HAL_Lib/src/hal_gpio.c \
+ $(srctree)/Drivers/PEC930/HAL_Lib/src/hal_i2c.c \
+ $(srctree)/Drivers/PEC930/HAL_Lib/src/hal_lptim.c \
+ $(srctree)/Drivers/PEC930/HAL_Lib/src/hal_pwr.c \
+ $(srctree)/Drivers/PEC930/HAL_Lib/src/hal_spi.c \
+ $(srctree)/Drivers/PEC930/HAL_Lib/src/hal_syscfg.c \
+ $(srctree)/Drivers/PEC930/HAL_Lib/src/hal_tim.c \
+ $(srctree)/Drivers/PEC930/HAL_Lib/src/hal_uart.c \
+ $(srctree)/Drivers/PEC930/HAL_Lib/src/hal_wdg.c \
+ $(srctree)/Drivers/PEC930/HAL_Lib/src/hal_device.c
+
+C_INCLUDES += \
+ -I$(srctree)/Drivers/PEC930/HAL_Lib/inc
+
+#=======================================
+# BSP
+#=======================================
+C_SOURCES += $(srctree)/Drivers/PEC930/BSP/StarterKit/starterkit.c
+
+C_INCLUDES += \
+ -I$(srctree)/Drivers/PEC930/BSP/StarterKit
+
+#=======================================
+# Flags
+#=======================================
+CFLAGS += $(CPU_FLAGS)
+CXXFLAGS +=
+LDFLAGS += $(CPU_FLAGS)
+LIBDIR +=
diff --git a/Drivers/PB5700/gcc_flashxip.ld b/Drivers/PEC930/gcc_flashxip.ld
similarity index 100%
rename from Drivers/PB5700/gcc_flashxip.ld
rename to Drivers/PEC930/gcc_flashxip.ld
diff --git a/Examples/I2C/I2C_Master_EEPROM/inc/isr.h b/Examples/I2C/I2C_Master_EEPROM/inc/isr.h
deleted file mode 100644
index b1ab850..0000000
--- a/Examples/I2C/I2C_Master_EEPROM/inc/isr.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file isr.h
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/09/16
- * @license
- * @description
- */
-
-#ifndef __isr_H_wuraIpBA_lTJm_HvJw_sNDo_uEd5JnucTReY__
-#define __isr_H_wuraIpBA_lTJm_HvJw_sNDo_uEd5JnucTReY__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-/**
- * ISRs of Internal Interrupt of IRQC
- */
-void irqc_mtip_handler(void);
-void irqc_msip_handler(void);
-
-/**
- * ISRs of External Interrupt of IRQC
- */
-void irqc_uart_handler(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/Examples/I2C/I2C_Master_EEPROM/src/isr.c b/Examples/I2C/I2C_Master_EEPROM/src/isr.c
deleted file mode 100644
index 4cd5b57..0000000
--- a/Examples/I2C/I2C_Master_EEPROM/src/isr.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file isr.c
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/09/16
- * @license
- * @description
- */
-
-
-#include "main.h"
-#include "isr.h"
-
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-/**
- * \brief System Software ISR
- *
- * \return None
- */
-__INTERRUPT void irqc_msip_handler(void)
-{
- sys_clear_swi();
- return;
-}
-
diff --git a/Examples/I2C/I2C_Master_EEPROM/src/main.c b/Examples/I2C/I2C_Master_EEPROM/src/main.c
deleted file mode 100644
index 0f04546..0000000
--- a/Examples/I2C/I2C_Master_EEPROM/src/main.c
+++ /dev/null
@@ -1,401 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file main.c
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/08/29
- * @license
- * @description
- */
-
-
-#include "main.h"
-#include "isr.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-//#define ENABLE_IIC_INT
-//=============================================================================
-// Macro Definition
-//=============================================================================
-#define EEPROM_I2C_ADDRESS 0xA0
-uint32_t testFlasg = 0;
-uint32_t errCounter = 0;
-uint32_t delay = 0;
-uint8_t i = 0;
-uint8_t ReadBuffer[20], WriteBuffer[20];
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-void I2C_Configure(void);
-void I2C_Handler(void);
-void I2C_TxData_Polling(uint8_t *Buffer, uint8_t Length);
-void EEPROM_WriteData(uint8_t Address, uint8_t *Buffer, uint8_t Length);
-void EEPROM_WritePage(uint8_t Address, uint8_t *Buffer, uint8_t Length);
-void I2C_RxData_Polling(uint8_t *Buffer, uint16_t Length);
-void EEPROM_ReadData(uint8_t Address, uint8_t *Buffer, uint8_t Length);
-void I2C_Send_WriteAddr(I2C_Type *i2c,uint8_t address);
-void I2C_Send_ReadAddr(I2C_Type *i2c,uint8_t address);
-
-void EEPROM_GenerateSTART(I2C_Type *i2c, FunctionalState state);
-void EEPROM_GenerateRESTART(I2C_Type *i2c, FunctionalState state);
-void EEPROM_Send_WriteAddr(I2C_Type *i2c, uint8_t address);
-void I2C_Send_ReadAddr(I2C_Type *i2c,uint8_t address);
-void EEPROM_Send_Data(I2C_Type *i2c, uint8_t data);
-void EEPROM_GenerateSTOP(I2C_Type *i2c, FunctionalState state);
-
-
-void I2C_Master_EEPROM_Polling_Sample(void);
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-int main(void)
-{
- SYSCFG_ClkInitTypeDef SysClkInit = {0};
-
- SysClkInit.ClkSource = SYSCFG_ClkSrc_HSI;
- SYSCFG_SysClkConfig(&SysClkInit);
-
- sys_config_systick(SYS_TICK_1_MS);
-
- I2C_Master_EEPROM_Polling_Sample();
-
- while(1)
- {
-
- }
-
-}
-
-void I2C_Master_EEPROM_Polling_Sample(void)
-{
- I2C_Configure();
-
- for (i = 0; i < 20; i++)
- {
- ReadBuffer[i] = 0;
- WriteBuffer[i] = i + 0x10;
- }
-
- EEPROM_GenerateSTART(I2C,ENABLE);
- EEPROM_Send_WriteAddr(I2C,0xA0);
- EEPROM_Send_Data(I2C,0x00);
- EEPROM_Send_Data(I2C,0x00);
-
- I2C_TxData_Polling((uint8_t *)WriteBuffer, 20);
- EEPROM_GenerateSTOP(I2C,ENABLE);
-
- for(delay = 0;delay <0x1000; delay ++);
-
- EEPROM_GenerateSTART(I2C,ENABLE);
- EEPROM_Send_WriteAddr(I2C,0xA0);
- EEPROM_Send_Data(I2C,0x00);
- EEPROM_Send_Data(I2C,0x00);
-
- EEPROM_GenerateRESTART(I2C,ENABLE);
- I2C_Send_ReadAddr(I2C,0xA1);
-
- I2C_RxData_Polling((uint8_t *)ReadBuffer, 20);
- EEPROM_GenerateSTOP(I2C,ENABLE);
-
- for (i = 0; i < 20; i++)
- {
- if(WriteBuffer[i] != ReadBuffer[i])
- {
- errCounter ++;
- }
- }
-}
-
-void I2C_Configure(void)
-{
- GPIO_InitTypeDef GPIO_InitStruct;
- I2C_InitTypeDef I2C_InitStruct;
-
- I2C_StructInit(&I2C_InitStruct);
- I2C_InitStruct.I2C_Mode = I2C_Mode_Master;
- I2C_InitStruct.I2C_OwnAddress = 0x00;
- I2C_InitStruct.I2C_ClockDiv = I2C_CLK_Div960;
- I2C_Init(I2C,&I2C_InitStruct);
-
- GPIO_InitStruct.GPIO_Pin = GPIO_Pin_00 | GPIO_Pin_01;
- GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF;
- GPIO_InitStruct.GPIO_AF_Mode = GPIO_AF_3;
- GPIO_Init(GPIOA, &GPIO_InitStruct);
-
- I2C_TargetAddressConfig(I2C,EEPROM_I2C_ADDRESS);
-#ifdef ENABLE_IIC_INT
- I2C_ITConfig(I2C, ENABLE);
- sys_irq_attr_t irq_attr = { .trig_mode = SYS_IRQ_TRIGGER_LEVEL, };
- sys_register_IRQ(I2C0_IRQn, I2C_Handler, &irq_attr);
- __enable_irq();
-# endif
- I2C_Cmd(I2C, ENABLE);
-}
-
-void EEPROM_WriteData(uint8_t Address, uint8_t *Buffer, uint8_t Length)
-{
- /****************SEND_START****************/
- I2C_GenerateSTART(I2C,ENABLE);
- while (RESET == I2C_GetFlagStatus(I2C, I2C_MASTER_START_ACK))
- {
-
- }
- EEPROM_WritePage(Address, Buffer, EEPROM_PAGE_SIZE);
-}
-
-void EEPROM_WritePage(uint8_t Address, uint8_t *Buffer, uint8_t Length)
-{
- I2C_Send_WriteAddr(I2C,Address);
-
- I2C_TxData_Polling((uint8_t *)Buffer, Length);
-
- I2C_GenerateSTOP(I2C, ENABLE);
- I2C_ITConfig(I2C, DISABLE);
- while (!I2C_GetFlagStatus(I2C, I2C_BUS_FREE))
- {
- }
-}
-
-void I2C_TxData_Polling(uint8_t *Buffer, uint8_t Length)
-{
- uint8_t i = 0;
-
- for (i = 0; i < Length; i++)
- {
- I2C_SendData(I2C, Buffer[i]);
- I2C_StaFlagConfig(I2C,I2C_STA_RESET,I2C_STO_RESET,I2C_SI_RESET,I2C_AA_RESET);
- while (RESET == I2C_GetFlagStatus(I2C, I2C_MASTER_WRDATEND_ACK));
- {
-
- }
- }
-}
-
-void I2C_Send_WriteAddr(I2C_Type *i2c,uint8_t address)
-{
- I2C_SendData(i2c, address);
- REG_WRITE_MASK(i2c->CTLCLR, I2C_CTLCLR_SI_Msk, 1 << I2C_CTLCLR_SI_Pos);
- while (RESET == I2C_GetFlagStatus(i2c, I2C_MASTER_WRDEVADREND_ACK));
- {
-
- }
-}
-
-void EEPROM_ReadData(uint8_t Address, uint8_t *Buffer, uint8_t Length)
-{
-
-
-
- I2C_GenerateSTART(I2C,ENABLE);
- I2C_ITConfig(I2C, DISABLE);
-// I2C_StaFlagConfig(I2C,I2C_STA_SET,I2C_STO_RESET,I2C_SI_RESET,I2C_AA_RESET);
- while (RESET == I2C_GetFlagStatus(I2C, I2C_MASTER_RPTSTART_ACK))
- {
-
- }
- I2C_Send_ReadAddr(I2C,0xA1);
-
- I2C_RxData_Polling((uint8_t *)Buffer, Length);
-
- I2C_GenerateSTOP(I2C, ENABLE);
-
- while (!I2C_GetITStatus(I2C, I2C_BUS_FREE))
- {
- }
-}
-
-void I2C_RxData_Polling(uint8_t *Buffer, uint16_t Length)
-{
- uint8_t i = 0;
- I2C_StaFlagConfig(I2C,I2C_STA_RESET,I2C_STO_RESET,I2C_SI_RESET,I2C_AA_SET);
- for (i = 0; i < Length; i++)
- {
- REG_WRITE_MASK(I2C->CTLCLR, I2C_CTLCLR_SI_Msk, 1 << I2C_CTLCLR_SI_Pos);
- while (RESET == I2C_GetFlagStatus(I2C, I2C_RXDAT_TXACK));
- {
-
- }
- Buffer[i] = I2C_ReceiveData(I2C);
- }
-}
-
-void EEPROM_GenerateSTART(I2C_Type *i2c, FunctionalState state)
-{
- I2C_GenerateSTART(I2C,ENABLE);
- while (RESET == I2C_GetFlagStatus(I2C, I2C_MASTER_START_ACK))
- {
-
- }
-}
-
-void EEPROM_GenerateRESTART(I2C_Type *i2c, FunctionalState state)
-{
- I2C_GenerateSTART(I2C,ENABLE);
- I2C_ITConfig(I2C,DISABLE );
- while (RESET == I2C_GetFlagStatus(I2C, I2C_MASTER_RPTSTART_ACK))
- {
-
- }
-}
-
-void EEPROM_Send_WriteAddr(I2C_Type *i2c, uint8_t address)
-{
- I2C_Send_WriteAddr(i2c,address);
-
- I2C_SendData(I2C, 0x00);
- I2C_StaFlagConfig(I2C,I2C_STA_RESET,I2C_STO_RESET,I2C_SI_RESET,I2C_AA_RESET);
- while (RESET == I2C_GetFlagStatus(I2C, I2C_MASTER_WRDATEND_ACK));
- {
-
- }
-}
-
-
-void EEPROM_Send_Data(I2C_Type *i2c, uint8_t data)
-{
- I2C_SendData(i2c, data);
- I2C_StaFlagConfig(I2C,I2C_STA_RESET,I2C_STO_RESET,I2C_SI_RESET,I2C_AA_RESET);
- while (RESET == I2C_GetFlagStatus(I2C, I2C_MASTER_WRDATEND_ACK));
- {
-
- }
-}
-void I2C_Send_ReadAddr(I2C_Type *i2c,uint8_t address)
-{
- I2C_SendData(i2c, address);
- REG_WRITE_MASK(i2c->CTLCLR, I2C_CTLCLR_SI_Msk, 1 << I2C_CTLCLR_SI_Pos);
- while (RESET == I2C_GetFlagStatus(i2c, I2C_MASTER_WRADR_RDCMD_ACK));
- {
-
- }
-}
-
-void EEPROM_GenerateSTOP(I2C_Type *i2c, FunctionalState state)
-{
- I2C_GenerateSTOP(i2c,ENABLE);
- I2C_ITConfig(i2c, DISABLE);
- while (RESET == I2C_GetFlagStatus(I2C, I2C_BUS_FREE))
- {
-
- }
-
-}
-/**********IRQ Number 17**********/
-__INTERRUPT void I2C_Handler(void)
-{
- if(I2C_GetFlagStatus(I2C, I2C_MASTER_START_ACK) == 1)
- {
- printf("I2C_STAT = 0x01,I2C_MASTER_START_ACK Interrupt Successful!/r/n");
- }
- if(I2C_GetFlagStatus(I2C, I2C_MASTER_RPTSTART_ACK) == 1)
- {
- printf("I2C_STAT = 0x02,I2C_MASTER_RPTSTART_ACK Interrupt Successful!/r/n");
- }
- if(I2C_GetFlagStatus(I2C, I2C_MASTER_WRDEVADREND_ACK) == 1)
- {
- printf("I2C_STAT = 0x02,I2C_MASTER_WRDEVADREND_ACK Interrupt Successful!/r/n");
- }
- if(I2C_GetFlagStatus(I2C, I2C_MASTER_WRDEVADREND_NACK) == 1)
- {
- printf("I2C_STAT = 0x02,I2C_MASTER_WRDEVADREND_NACK Interrupt Successful!/r/n");
- }
- if(I2C_GetFlagStatus(I2C, I2C_MASTER_WRDATEND_ACK) == 1)
- {
- printf("I2C_STAT = 0x02,I2C_MASTER_WRDATEND_ACK Interrupt Successful!/r/n");
- }
- if(I2C_GetFlagStatus(I2C, I2C_MASTER_START_ACK) == 1)
- {
- printf("I2C_STAT = 0x02,I2C_MASTER_START_ACK Interrupt Successful!/r/n");
- }
- if(I2C_GetFlagStatus(I2C, I2C_MASTER_START_ACK) == 1)
- {
- printf("I2C_STAT = 0x02,I2C_MASTER_START_ACK Interrupt Successful!/r/n");
- }
- if(I2C_GetFlagStatus(I2C, I2C_MASTER_START_ACK) == 1)
- {
- printf("I2C_STAT = 0x02,I2C_MASTER_START_ACK Interrupt Successful!/r/n");
- }
- if(I2C_GetFlagStatus(I2C, I2C_MASTER_START_ACK) == 1)
- {
- printf("I2C_STAT = 0x02,I2C_MASTER_START_ACK Interrupt Successful!/r/n");
- }
- if(I2C_GetFlagStatus(I2C, I2C_MASTER_START_ACK) == 1)
- {
- printf("I2C_STAT = 0x02,I2C_MASTER_START_ACK Interrupt Successful!/r/n");
- }
- if(I2C_GetFlagStatus(I2C, I2C_MASTER_START_ACK) == 1)
- {
- printf("I2C_STAT = 0x02,I2C_MASTER_START_ACK Interrupt Successful!/r/n");
- }
- if(I2C_GetFlagStatus(I2C, I2C_MASTER_START_ACK) == 1)
- {
- printf("I2C_STAT = 0x02,I2C_MASTER_START_ACK Interrupt Successful!/r/n");
- }
- if(I2C_GetFlagStatus(I2C, I2C_MASTER_START_ACK) == 1)
- {
- printf("I2C_STAT = 0x02,I2C_MASTER_START_ACK Interrupt Successful!/r/n");
- }
- if(I2C_GetFlagStatus(I2C, I2C_MASTER_START_ACK) == 1)
- {
- printf("I2C_STAT = 0x02,I2C_MASTER_START_ACK Interrupt Successful!/r/n");
- }
- if(I2C_GetFlagStatus(I2C, I2C_MASTER_START_ACK) == 1)
- {
- printf("I2C_STAT = 0x02,I2C_MASTER_START_ACK Interrupt Successful!/r/n");
- }
- if(I2C_GetFlagStatus(I2C, I2C_MASTER_START_ACK) == 1)
- {
- printf("I2C_STAT = 0x02,I2C_MASTER_START_ACK Interrupt Successful!/r/n");
- }
- if(I2C_GetFlagStatus(I2C, I2C_MASTER_START_ACK) == 1)
- {
- printf("I2C_STAT = 0x02,I2C_MASTER_START_ACK Interrupt Successful!/r/n");
- }
- if(I2C_GetFlagStatus(I2C, I2C_MASTER_START_ACK) == 1)
- {
- printf("I2C_STAT = 0x02,I2C_MASTER_START_ACK Interrupt Successful!/r/n");
- }
- if(I2C_GetFlagStatus(I2C, I2C_MASTER_START_ACK) == 1)
- {
- printf("I2C_STAT = 0x02,I2C_MASTER_START_ACK Interrupt Successful!/r/n");
- }
- if(I2C_GetFlagStatus(I2C, I2C_MASTER_START_ACK) == 1)
- {
- printf("I2C_STAT = 0x02,I2C_MASTER_START_ACK Interrupt Successful!/r/n");
- }
- if(I2C_GetFlagStatus(I2C, I2C_MASTER_START_ACK) == 1)
- {
- printf("I2C_STAT = 0x02,I2C_MASTER_START_ACK Interrupt Successful!/r/n");
- }
- if(I2C_GetFlagStatus(I2C, I2C_MASTER_START_ACK) == 1)
- {
- printf("I2C_STAT = 0x02,I2C_MASTER_START_ACK Interrupt Successful!/r/n");
- }
- if(I2C_GetFlagStatus(I2C, I2C_MASTER_START_ACK) == 1)
- {
- printf("I2C_STAT = 0x02,I2C_MASTER_START_ACK Interrupt Successful!/r/n");
- }
- if(I2C_GetFlagStatus(I2C, I2C_MASTER_START_ACK) == 1)
- {
- printf("I2C_STAT = 0x02,I2C_MASTER_START_ACK Interrupt Successful!/r/n");
- }
- if(I2C_GetFlagStatus(I2C, I2C_MASTER_START_ACK) == 1)
- {
- printf("I2C_STAT = 0x02,I2C_MASTER_START_ACK Interrupt Successful!/r/n");
- }
- if(I2C_GetFlagStatus(I2C, I2C_MASTER_START_ACK) == 1)
- {
- printf("I2C_STAT = 0x02,I2C_MASTER_START_ACK Interrupt Successful!/r/n");
- }
-}
diff --git a/Examples/I2C/I2C_Slave_STM32/inc/isr.h b/Examples/I2C/I2C_Slave_STM32/inc/isr.h
deleted file mode 100644
index b1ab850..0000000
--- a/Examples/I2C/I2C_Slave_STM32/inc/isr.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file isr.h
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/09/16
- * @license
- * @description
- */
-
-#ifndef __isr_H_wuraIpBA_lTJm_HvJw_sNDo_uEd5JnucTReY__
-#define __isr_H_wuraIpBA_lTJm_HvJw_sNDo_uEd5JnucTReY__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-/**
- * ISRs of Internal Interrupt of IRQC
- */
-void irqc_mtip_handler(void);
-void irqc_msip_handler(void);
-
-/**
- * ISRs of External Interrupt of IRQC
- */
-void irqc_uart_handler(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/Examples/I2C/I2C_Slave_STM32/readme.md b/Examples/I2C/I2C_Slave_STM32/readme.md
deleted file mode 100644
index 04dfe58..0000000
--- a/Examples/I2C/I2C_Slave_STM32/readme.md
+++ /dev/null
@@ -1,13 +0,0 @@
-IIC_SlaveMode_project
----
-
-This example is a demo project to IIC onePulseOutput
-
-## Hardware and Software environment
-
-+ This example runs on PB5700 devices.
-
-## Log
-
-+ STM32 as the Master and PB5700 as the slave for communication
-
diff --git a/Examples/I2C/I2C_Slave_STM32/src/isr.c b/Examples/I2C/I2C_Slave_STM32/src/isr.c
deleted file mode 100644
index 4cd5b57..0000000
--- a/Examples/I2C/I2C_Slave_STM32/src/isr.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file isr.c
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/09/16
- * @license
- * @description
- */
-
-
-#include "main.h"
-#include "isr.h"
-
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-/**
- * \brief System Software ISR
- *
- * \return None
- */
-__INTERRUPT void irqc_msip_handler(void)
-{
- sys_clear_swi();
- return;
-}
-
diff --git a/Examples/I2C/I2C_Slave_STM32/src/main.c b/Examples/I2C/I2C_Slave_STM32/src/main.c
deleted file mode 100644
index 196696b..0000000
--- a/Examples/I2C/I2C_Slave_STM32/src/main.c
+++ /dev/null
@@ -1,176 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file main.c
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/08/29
- * @license
- * @description
- */
-
-
-#include "main.h"
-#include "isr.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-#define I2C_SLAVE_ADDRESS 0x50
-uint8_t i = 0;
-uint8_t ReadBuffer[100], WriteBuffer[20];
-uint8_t readCounter = 0;
-uint8_t writeCounter = 0;
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-void I2C_Handler(void);
-void I2C_Slave_Configure(void);
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-int main(void)
-{
- SYSCFG_ClkInitTypeDef SysClkInit = {0};
-
- SysClkInit.ClkSource = SYSCFG_ClkSrc_HSI;
- SYSCFG_SysClkConfig(&SysClkInit);
-
- sys_config_systick(SYS_TICK_1_MS);
-
- I2C_Slave_Configure();
-
-
- while(1)
- {
-
- }
-
-}
-
-void I2C_Slave_Configure(void)
-{
- GPIO_InitTypeDef GPIO_InitStruct;
- I2C_InitTypeDef I2C_InitStruct;
-
- I2C_StructInit(&I2C_InitStruct);
- I2C_InitStruct.I2C_Mode = I2C_Mode_Master;
- I2C_InitStruct.I2C_OwnAddress = 0x00;
- I2C_InitStruct.I2C_ClockDiv = I2C_CLK_Div960;
- I2C_Init(I2C,&I2C_InitStruct);
-
- GPIO_InitStruct.GPIO_Pin = GPIO_Pin_00 | GPIO_Pin_01;
- GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF;
- GPIO_InitStruct.GPIO_AF_Mode = GPIO_AF_3;
- GPIO_Init(GPIOA, &GPIO_InitStruct);
- I2C_StaFlagConfig(I2C,I2C_STA_RESET,I2C_STO_RESET,I2C_SI_RESET,I2C_AA_SET);
- I2C_TargetAddressConfig(I2C,I2C_SLAVE_ADDRESS);
- I2C_ITConfig(I2C, ENABLE);
- for (i = 0; i < 20; i++)
- {
- ReadBuffer[i] = 0;
- WriteBuffer[i] = i + 0x10;
- }
-
- sys_irq_attr_t irq_attr = { .trig_mode = SYS_IRQ_TRIGGER_LEVEL, };
- sys_register_IRQ(I2C0_IRQn, I2C_Handler, &irq_attr);
- __enable_irq();
- I2C_Cmd(I2C, ENABLE);
-}
-
-/**********IRQ Number 17**********/
-__INTERRUPT void I2C_Handler(void)
-{
- switch(I2C_GetSta(I2C))
- {
- case (I2C_SLAVE_WRCMD_ACK):
- I2C_StaFlagConfig(I2C,I2C_STA_RESET,I2C_STO_RESET,I2C_SI_RESET,I2C_AA_SET);
-
- break;
-
- case (I2C_SLAVE_RXADR_WRCMD_ACK):
-
- break;
-
- case (I2C_RX_BROADCASTADR_ACK):
-
- break;
-
- case (I2C_SLAVE_RXBROADCASTADR_ACK):
-
- break;
-
- case (I2C_SLAVE_RXNEXTDAT_ACK):
- I2C_StaFlagConfig(I2C,I2C_STA_RESET,I2C_STO_RESET,I2C_SI_RESET,I2C_AA_SET);
- ReadBuffer[readCounter] = I2C_ReceiveData(I2C);
- readCounter++;
-
-
- break;
-
- case (I2C_SLAVE_RXNEXTDAT_NACK):
-
- break;
-
- case (I2C_BROADCAST_RXNEXTDAT_ACK):
-
- break;
-
- case (I2C_BROADCAST_RXNEXTDAT_NACK):
-
- break;
-
- case (I2C_SLAVE_RXSTOP_OR_RPTSTAT):
- I2C_StaFlagConfig(I2C,I2C_STA_RESET,I2C_STO_RESET,I2C_SI_RESET,I2C_AA_SET);
-
- break;
-
- case (I2C_SLAVE_RXADR_RXCMD_ACK):
- I2C_SendData(I2C,WriteBuffer[writeCounter]);
- I2C_StaFlagConfig(I2C,I2C_STA_RESET,I2C_STO_RESET,I2C_SI_RESET,I2C_AA_SET);
- writeCounter ++;
-
- break;
-
- case (I2C_BUSLOST_SLAVE_RXADR_RXCMD_ACK):
- I2C_StaFlagConfig(I2C,I2C_STA_RESET,I2C_STO_RESET,I2C_SI_RESET,I2C_AA_SET);
-
- break;
-
- case (I2C_SLAVE_TXDAT_ACK):
- I2C_SendData(I2C,WriteBuffer[writeCounter]);
- I2C_StaFlagConfig(I2C,I2C_STA_RESET,I2C_STO_RESET,I2C_SI_RESET,I2C_AA_SET);
- writeCounter ++;
-
- break;
-
- case (I2C_SLAVE_TXDAT_NACK):
- I2C_StaFlagConfig(I2C,I2C_STA_RESET,I2C_STO_RESET,I2C_SI_RESET,I2C_AA_SET);
-
- break;
-
- case (I2C_SLAVE_TXLASTDAT_ACK):
-// I2C_SendData(I2C,WriteBuffer[writeCounter]);
- I2C_StaFlagConfig(I2C,I2C_STA_RESET,I2C_STO_RESET,I2C_SI_RESET,I2C_AA_SET);
-// writeCounter ++;
-
- break;
-
- case (I2C_BUS_FREE):
- break;
- default:
- break;
- }
-}
diff --git a/Examples/adc/adc_conv_mode/.cproject b/Examples/adc/adc_conv_mode/.cproject
index 2f90cfe..1a0019e 100644
--- a/Examples/adc/adc_conv_mode/.cproject
+++ b/Examples/adc/adc_conv_mode/.cproject
@@ -40,28 +40,28 @@
-
+
-
-
-
+
+
+
@@ -69,14 +69,14 @@
@@ -95,7 +95,7 @@
-
-
+
+
@@ -193,10 +193,10 @@
@@ -205,14 +205,14 @@
@@ -226,7 +226,7 @@
diff --git a/Examples/adc/adc_conv_mode/Project.nuproject b/Examples/adc/adc_conv_mode/Project.nuproject
index b783ad6..0072223 100644
--- a/Examples/adc/adc_conv_mode/Project.nuproject
+++ b/Examples/adc/adc_conv_mode/Project.nuproject
@@ -7,7 +7,7 @@ SDK_CONFIG:
cmodel: medlow
extra_commonflags:
abi: ilp32e
- arch: rv32emac_zba_zbb_zbs
+ arch: rv32ema_zba_zbb_zbs_zca_zcb_zcmp_zcmt_zicond
toolchain: gnu
extra_cflags:
extra_ldflags:
diff --git a/Examples/adc/adc_conv_mode/component.mk b/Examples/adc/adc_conv_mode/component.mk
index b1b2bc6..6e37bb4 100644
--- a/Examples/adc/adc_conv_mode/component.mk
+++ b/Examples/adc/adc_conv_mode/component.mk
@@ -11,6 +11,6 @@ C_INCLUDES += -I$(srctree)/$(PROJ)/inc
LIBS +=
-CFLAGS +=
+CFLAGS += -DCONFIG_HAS_SYSLOG_FLOAT
LDFLAGS +=
LIBDIR +=
diff --git a/Examples/adc/adc_conv_mode/readme.md b/Examples/adc/adc_conv_mode/readme.md
index 0852e4a..305b514 100644
--- a/Examples/adc/adc_conv_mode/readme.md
+++ b/Examples/adc/adc_conv_mode/readme.md
@@ -13,8 +13,8 @@ This is an example of ADC conversion mode.
```
// in main.c
- #define CONFIG_TARGET_1_ADC_CHANNEL ADC_Channel_AVSS
- #define CONFIG_TARGET_ADC_MULTI_CHANNELS (ADC_Channel_AVSS | ADC_Channel_AMISC)
+ #define CONFIG_TARGET_1_ADC_CHANNEL ADC_Channel_03
+ #define CONFIG_TARGET_ADC_MULTI_CHANNELS (ADC_Channel_02 | ADC_Channel_03 | ADC_Channel_09)
```
+ User pull low of the specific key to trigger ADC work
@@ -22,48 +22,123 @@ This is an example of ADC conversion mode.
```
// in main.c
#define CONFIG_GPIO_INPUT_PORTx GPIOA
- #define CONFIG_GPIO_INPUT_PINx GPIO_Pin_05
+ #define CONFIG_GPIO_INPUT_PINx GPIO_Pin_02
```
## Single conversion mode
-```
-// in main.c
-#define CONFIG_TARGET_ADC_MODE_SIGNAL 1
-#define CONFIG_TARGET_ADC_MODE_CONTINOUS 0
-#define CONFIG_TARGET_ADC_MODE_SCAN 0
-#define CONFIG_TARGET_ADC_MODE_DISCONTINOUS 0
-```
+Software trigger ADC to sample a channel once
+> The target ADC channel is defined at `CONFIG_TARGET_1_ADC_CHANNEL`
+
++ Configure to single conversion mode
+
+ ```
+ // in main.c
+ #define CONFIG_TARGET_ADC_MODE_SIGNAL 1
+ #define CONFIG_TARGET_ADC_MODE_CONTINOUS 0
+ #define CONFIG_TARGET_ADC_MODE_SCAN 0
+ #define CONFIG_TARGET_ADC_MODE_DISCONTINOUS 0
+ ```
+
++ Operation flow
+
+ - Step 1. Connect the AIN-Channel (`CONFIG_TARGET_1_ADC_CHANNEL`) with an external device (e.g. power support) which provide difference voltage
+ - Step 2. Set a specific voltage to external device (e.g. power support)
+ - Step 3. Press button to trigger ADC start
+ - Step 4. Get the ADC conversion value from log message
+ - Step 5. Calculate the measured voltage
+
+ ```
+ the measured voltage = ADC_Value * ((AVDD - AVSS) / 4095)
+ ```
+
+ - Step 6. repeat `Step 2 ~ Step 5`
## Continuous mode
-```
-// in main.c
-#define CONFIG_TARGET_ADC_MODE_SIGNAL 0
-#define CONFIG_TARGET_ADC_MODE_CONTINOUS 1
-#define CONFIG_TARGET_ADC_MODE_SCAN 0
-#define CONFIG_TARGET_ADC_MODE_DISCONTINOUS 0
-```
+In this mode, ADC will always sequentially sample the specific channels after a trigger-event
+
++ Configure to continuous mode
+
+ ```
+ // in main.c
+ #define CONFIG_TARGET_ADC_MODE_SIGNAL 0
+ #define CONFIG_TARGET_ADC_MODE_CONTINOUS 1
+ #define CONFIG_TARGET_ADC_MODE_SCAN 0
+ #define CONFIG_TARGET_ADC_MODE_DISCONTINOUS 0
+ ```
+
++ Operation flow
+
+ - Step 1. Connect the AIN-Channel (`CONFIG_TARGET_1_ADC_CHANNEL`) with an external device (e.g. power support) which provide difference voltage
+ - Step 2. Set a specific voltage to the external device (e.g. power support)
+ - Step 3. Press button to trigger ADC start
+ - Step 4. Run-time change voltage from the external device (e.g. power support)
+ - Step 5. Get the ADC conversion value from log message
+ > It will auto-log `CONFIG_REPEAT_TIMES` times with a trigger-event
+ > ```
+ > // at main.c
+ > #define CONFIG_REPEAT_TIMES 10
+ > ```
## Scan mode
-```
-// in main.c
-#define CONFIG_TARGET_ADC_MODE_SIGNAL 0
-#define CONFIG_TARGET_ADC_MODE_CONTINOUS 0
-#define CONFIG_TARGET_ADC_MODE_SCAN 1
-#define CONFIG_TARGET_ADC_MODE_DISCONTINOUS 0
-```
+In Scan mode, ACD will sequentially sample the specific channels **once** after a trigger-event
+
++ Configure to Scan mode
+
+ ```
+ // in main.c
+ #define CONFIG_TARGET_ADC_MODE_SIGNAL 0
+ #define CONFIG_TARGET_ADC_MODE_CONTINOUS 0
+ #define CONFIG_TARGET_ADC_MODE_SCAN 1
+ #define CONFIG_TARGET_ADC_MODE_DISCONTINOUS 0
+ ```
+
++ Operation flow
+
+ - Step 1. Connect the AIN-Channels (`CONFIG_TARGET_ADC_MULTI_CHANNELS`) with an external device (e.g. power support) which provide difference voltages
+ - Step 2. Set specific voltages to the external device (e.g. power support) with multi-channels
+ - Step 3. Press button to trigger ADC start
+ - Step 4. Run-time change voltages of multi-channels of the external device (e.g. power support)
+ - Step 5. Get the ADC conversion values from log message
+ > It will auto-trigger the sample-event `CONFIG_REPEAT_TIMES` times
+ > ```
+ > // at main.c
+ > #define CONFIG_REPEAT_TIMES 10
+ > ```
## Discontinuous mode
-```
-// in main.c
-#define CONFIG_TARGET_ADC_MODE_SIGNAL 0
-#define CONFIG_TARGET_ADC_MODE_CONTINOUS 0
-#define CONFIG_TARGET_ADC_MODE_SCAN 1
-#define CONFIG_TARGET_ADC_MODE_DISCONTINOUS 0
-```
+It will group the selected AIN-Channels and sequentially trigger a sub-group of the selected AIN-Channels with a trigger-event
+> An example as below
+> ```
+> Selected AIN 4,5,7,9
+> Sub-Group 1: AIN 4, 5, 7
+> Sub-Group 2: AIN 9
+> the 1st trigger-evern => Execute Sub-Group 1
+> the 2nd trigger-evern => Execute Sub-Group 2
+> ```
+
+
++ Configure to Discontinuous mode
+
+ ```
+ // in main.c
+ #define CONFIG_TARGET_ADC_MODE_SIGNAL 0
+ #define CONFIG_TARGET_ADC_MODE_CONTINOUS 0
+ #define CONFIG_TARGET_ADC_MODE_SCAN 0
+ #define CONFIG_TARGET_ADC_MODE_DISCONTINOUS 1
+ ```
+
++ Operation flow
+
+ - Step 1. Connect the AIN-Channels (`CONFIG_TARGET_ADC_MULTI_CHANNELS`) with an external device (e.g. power support) which provide difference voltages
+ - Step 2. Set specific voltages to the external device (e.g. power support) with multi-channels
+ - Step 3. Press button to trigger ADC start
+ - Step 4. Run-time change voltages of multi-channels of the external device (e.g. power support)
+ - Step 5. Get the ADC conversion values from log message
+
## Log
@@ -71,8 +146,229 @@ Use serial port with baudrate 115200, 8bit, no parity check.
+ Single conversion mode
+ ```
+ Oct 2 2025 16:19:41
+ ADC run Single conversion mode
+ Button = PA2
+ wait key event (voltage level low)...
+ ADC Single Conversion
+ Trigger ADC
+ ch-03 ADC Value: 3395, voltage: 2.735898
+
+ ...
+ ```
+
+ Continuous mode
+ ```
+ Oct 2 2025 15:02:37
+ ADC run Continuous conversion mode
+ Button = PA2
+ wait key event (voltage level low)...
+ ADC Continuous mode
+
+ Trigger ADC <--- trigger ADC
+ => Change External Voltage
+ ch-09 ADC Value: 2327, voltage: 1.875238
+ ch-03 ADC Value: 3274, voltage: 2.638388
+ ch-02 ADC Value: 1342, voltage: 1.081465
+ => Change External Voltage
+ ch-09 ADC Value: 2331, voltage: 1.878461
+ ch-03 ADC Value: 3276, voltage: 2.640000
+ ch-02 ADC Value: 1349, voltage: 1.087106
+ => Change External Voltage
+ ch-09 ADC Value: 2341, voltage: 1.886520
+ ch-03 ADC Value: 3152, voltage: 2.540073 <--- change AIN3 voltage
+ ch-02 ADC Value: 1352, voltage: 1.089524
+ => Change External Voltage
+ ch-09 ADC Value: 2336, voltage: 1.882491
+ ch-03 ADC Value: 3159, voltage: 2.545714
+ ch-02 ADC Value: 1351, voltage: 1.088718
+ => Change External Voltage
+ ch-09 ADC Value: 2333, voltage: 1.880073
+ ch-03 ADC Value: 3028, voltage: 2.440146
+ ch-02 ADC Value: 1341, voltage: 1.080659
+ => Change External Voltage
+ ch-09 ADC Value: 2336, voltage: 1.882491
+ ch-03 ADC Value: 2906, voltage: 2.341831 <--- change AIN3 voltage
+ ch-02 ADC Value: 1343, voltage: 1.082271
+ => Change External Voltage
+ ch-09 ADC Value: 2345, voltage: 1.889744
+ ch-03 ADC Value: 2902, voltage: 2.338608
+ ch-02 ADC Value: 1347, voltage: 1.085495
+ => Change External Voltage
+ ch-09 ADC Value: 2332, voltage: 1.879267
+ ch-03 ADC Value: 2904, voltage: 2.340220
+ ch-02 ADC Value: 1717, voltage: 1.383663 <--- change AIN2 voltage
+ => Change External Voltage
+ ch-09 ADC Value: 2338, voltage: 1.884103
+ ch-03 ADC Value: 2902, voltage: 2.338608
+ ch-02 ADC Value: 2090, voltage: 1.684249
+ => Change External Voltage
+ ch-09 ADC Value: 2340, voltage: 1.885714
+ ch-03 ADC Value: 2910, voltage: 2.345055
+ ch-02 ADC Value: 2575, voltage: 2.075092 <--- change AIN2 voltage
+ => Change External Voltage
+ ch-09 ADC Value: 2328, voltage: 1.876044
+ ch-03 ADC Value: 2905, voltage: 2.341026
+ ch-02 ADC Value: 2585, voltage: 2.083150
+ => Change External Voltage
+ ch-09 ADC Value: 2082, voltage: 1.677802 <--- change AIN9 voltage
+ ch-03 ADC Value: 2907, voltage: 2.342637
+ ch-02 ADC Value: 2582, voltage: 2.080733
+ => Change External Voltage
+ ch-09 ADC Value: 1956, voltage: 1.576264
+ ch-03 ADC Value: 2905, voltage: 2.341026
+ ch-02 ADC Value: 2582, voltage: 2.080733
+ => Change External Voltage
+ ch-09 ADC Value: 2457, voltage: 1.980000
+ ch-03 ADC Value: 2905, voltage: 2.341026
+ ch-02 ADC Value: 2583, voltage: 2.081538
+ => Change External Voltage
+ ch-09 ADC Value: 2833, voltage: 2.283004 <--- change AIN9 voltage
+ ch-03 ADC Value: 2904, voltage: 2.340220
+ ch-02 ADC Value: 2589, voltage: 2.086374
+ ...
+ ```
+
+ Scan mode
+ ```
+ Oct 2 2025 15:44:15
+ ADC run Scan conversion mode
+ Button = PA2
+ wait key event (voltage level low)...
+ ADC Scan mode
+
+ => Change External Voltage
+ Trigger ADC <--- trigger ADC
+ ch-09 ADC Value: 2215, voltage: 1.784982
+ ch-03 ADC Value: 2902, voltage: 2.338608
+ ch-02 ADC Value: 2581, voltage: 2.079927
+ => Change External Voltage
+ Trigger ADC
+ ch-09 ADC Value: 2214, voltage: 1.784176
+ ch-03 ADC Value: 2903, voltage: 2.339414
+ ch-02 ADC Value: 2578, voltage: 2.077509
+ => Change External Voltage
+ Trigger ADC
+ ch-09 ADC Value: 2081, voltage: 1.676996
+ ch-03 ADC Value: 2902, voltage: 2.338608
+ ch-02 ADC Value: 2587, voltage: 2.084762
+ => Change External Voltage
+ Trigger ADC <--- trigger ADC
+ ch-09 ADC Value: 1961, voltage: 1.580293 <--- change AIN9 voltage
+ ch-03 ADC Value: 2906, voltage: 2.341831
+ ch-02 ADC Value: 2581, voltage: 2.079927
+ => Change External Voltage
+ Trigger ADC
+ ch-09 ADC Value: 1843, voltage: 1.485201
+ ch-03 ADC Value: 2907, voltage: 2.342637
+ ch-02 ADC Value: 2573, voltage: 2.073480
+ => Change External Voltage
+ Trigger ADC <--- trigger ADC
+ ch-09 ADC Value: 1843, voltage: 1.485201 <--- change AIN9 voltage
+ ch-03 ADC Value: 2901, voltage: 2.337802
+ ch-02 ADC Value: 2586, voltage: 2.083956
+ => Change External Voltage
+ Trigger ADC <--- trigger ADC
+ ch-09 ADC Value: 1848, voltage: 1.489231
+ ch-03 ADC Value: 2901, voltage: 2.337802
+ ch-02 ADC Value: 2830, voltage: 2.280586 <--- change AIN2 voltage
+ => Change External Voltage
+ Trigger ADC
+ ch-09 ADC Value: 1852, voltage: 1.492454
+ ch-03 ADC Value: 2906, voltage: 2.341831
+ ch-02 ADC Value: 2697, voltage: 2.173407
+ => Change External Voltage
+ Trigger ADC <--- trigger ADC
+ ch-09 ADC Value: 1847, voltage: 1.488425
+ ch-03 ADC Value: 2902, voltage: 2.338608
+ ch-02 ADC Value: 2453, voltage: 1.976776 <--- change AIN2 voltage
+ => Change External Voltage
+ Trigger ADC <--- trigger ADC
+ ch-09 ADC Value: 1846, voltage: 1.487619
+ ch-03 ADC Value: 2903, voltage: 2.339414
+ ch-02 ADC Value: 2344, voltage: 1.888938 <--- change AIN2 voltage
+ => Change External Voltage
+ Trigger ADC <--- trigger ADC
+ ch-09 ADC Value: 1851, voltage: 1.491648
+ ch-03 ADC Value: 2905, voltage: 2.341026
+ ch-02 ADC Value: 2459, voltage: 1.981612 <--- change AIN2 voltage
+ => Change External Voltage
+ Trigger ADC
+ ch-09 ADC Value: 1854, voltage: 1.494066
+ ch-03 ADC Value: 2893, voltage: 2.331355
+ ch-02 ADC Value: 2466, voltage: 1.987253
+ => Change External Voltage
+ Trigger ADC <--- trigger ADC
+ ch-09 ADC Value: 1848, voltage: 1.489231
+ ch-03 ADC Value: 3148, voltage: 2.536850 <--- change AIN3 voltage
+ ch-02 ADC Value: 2464, voltage: 1.985641
+ => Change External Voltage
+ Trigger ADC
+ ch-09 ADC Value: 1849, voltage: 1.490037
+ ch-03 ADC Value: 2782, voltage: 2.241905
+ ch-02 ADC Value: 2460, voltage: 1.982418
+ => Change External Voltage
+ Trigger ADC <--- trigger ADC
+ ch-09 ADC Value: 1850, voltage: 1.490842
+ ch-03 ADC Value: 2413, voltage: 1.944542 <--- change AIN3 voltage
+ ch-02 ADC Value: 2458, voltage: 1.980806
+ => Change External Voltage
+ Trigger ADC
+ ch-09 ADC Value: 1848, voltage: 1.489231
+ ch-03 ADC Value: 2412, voltage: 1.943736
+ ch-02 ADC Value: 2458, voltage: 1.980806
+ => Change External Voltage
+ Trigger ADC <--- trigger ADC
+ ch-09 ADC Value: 1850, voltage: 1.490842
+ ch-03 ADC Value: 2679, voltage: 2.158901 <--- change AIN3 voltage
+ ch-02 ADC Value: 2466, voltage: 1.987253
+ => Change External Voltage
+ Trigger ADC
+ ch-09 ADC Value: 1850, voltage: 1.490842
+ ch-03 ADC Value: 3023, voltage: 2.436117
+ ch-02 ADC Value: 2460, voltage: 1.982418
+ => Change External Voltage
+ Trigger ADC <--- trigger ADC
+ ch-09 ADC Value: 1854, voltage: 1.494066
+ ch-03 ADC Value: 3397, voltage: 2.737509 <--- change AIN3 voltage
+ ch-02 ADC Value: 2464, voltage: 1.985641
+
+ ...
+ ```
+
+ Discontinuous mode
+ > Sub-Group 1: AIN 2
+ > Sub-Group 2: AIN 3
+ > Sub-Group 3: AIN 9
+
+ ```
+ Oct 2 2025 16:13:42
+ ADC run Discontinuous conversion mode
+ Button = PA2
+ wait key event (voltage level low)...
+ ADC Discontinuous mode
+ => Change External Voltage
+
+ ## trigger 00-th
+ Trigger ADC <--- trigger ADC Sub-Group 1 (AIN 2)
+ ch-09 ADC Value: 0, voltage: 0.000000
+ ch-03 ADC Value: 0, voltage: 0.000000
+ ch-02 ADC Value: 2453, voltage: 1.976776
+
+ ## trigger 01-th
+ Trigger ADC <--- trigger ADC Sub-Group 2 (AIN 3)
+ ch-09 ADC Value: 0, voltage: 0.000000
+ ch-03 ADC Value: 3399, voltage: 2.739121
+ ch-02 ADC Value: 2453, voltage: 1.976776
+
+ ## trigger 02-th
+ Trigger ADC <--- trigger ADC Sub-Group 3 (AIN 9)
+ ch-09 ADC Value: 1843, voltage: 1.485201
+ ch-03 ADC Value: 3399, voltage: 2.739121
+ ch-02 ADC Value: 2453, voltage: 1.976776
+
+ ...
+ ```
diff --git a/Examples/adc/adc_conv_mode/src/main.c b/Examples/adc/adc_conv_mode/src/main.c
index ddfd69c..b932240 100644
--- a/Examples/adc/adc_conv_mode/src/main.c
+++ b/Examples/adc/adc_conv_mode/src/main.c
@@ -17,23 +17,25 @@
// Constant Definition
//=============================================================================
#define CONFIG_TARGET_ADC_MODE_SIGNAL 0
-#define CONFIG_TARGET_ADC_MODE_CONTINOUS 0
+#define CONFIG_TARGET_ADC_MODE_CONTINOUS 1
#define CONFIG_TARGET_ADC_MODE_SCAN 0
-#define CONFIG_TARGET_ADC_MODE_DISCONTINOUS 1
+#define CONFIG_TARGET_ADC_MODE_DISCONTINOUS 0
#define CONFIG_REPEAT_TIMES 10
/* Input Key I/O definitions */
#define CONFIG_GPIO_INPUT_PORTx GPIOA
-#define CONFIG_GPIO_INPUT_PINx GPIO_Pin_05
+#define CONFIG_GPIO_INPUT_PINx GPIO_Pin_02
#define CONFIG_GPIO_IRQ GPIOA_IRQn // GPIOB_IRQn
-#define CONFIG_TARGET_1_ADC_CHANNEL ADC_Channel_AVSS
-#define CONFIG_TARGET_ADC_MULTI_CHANNELS (ADC_Channel_AVSS | ADC_Channel_AMISC)
+#define CONFIG_TARGET_1_ADC_CHANNEL ADC_Channel_03 // ADC_Channel_AVSS
+#define CONFIG_TARGET_ADC_MULTI_CHANNELS (ADC_Channel_02 | ADC_Channel_03 | ADC_Channel_09) // (ADC_Channel_AVSS | ADC_Channel_AMISC)
+#define CONFIG_TARGET_ADC_SUB_CHANNEL ADC_SubChannel_VBuf_1_5
//=============================================================================
// Macro Definition
//=============================================================================
-
+#define _ADC_Convert_Voltage(__ADC_12b_value__) \
+ ((__ADC_12b_value__) * 3.3f / 4095.0f)
//=============================================================================
// Structure Definition
//=============================================================================
@@ -47,6 +49,8 @@ static bool g_hasPullLow = false;
//=============================================================================
__INTERRUPT void GPIOx_Handler(void)
{
+ SAVE_IRQ_CSR_CONTEXT();
+
if( GPIO_GetITFlag(CONFIG_GPIO_INPUT_PORTx, CONFIG_GPIO_INPUT_PINx) )
{
GPIO_ClearITFlag(CONFIG_GPIO_INPUT_PORTx, CONFIG_GPIO_INPUT_PINx);
@@ -54,6 +58,7 @@ __INTERRUPT void GPIOx_Handler(void)
g_hasPullLow = true;
}
+ RESTORE_IRQ_CSR_CONTEXT();
return;
}
@@ -68,6 +73,7 @@ _ADC_Conv_Single(ADC_ChannelsTypeDef channel)
int rval = 0;
uint16_t value = 0;
ADC_InitTypeDef init = {0};
+ int index = 31ul - HAL_CLZ(channel);
log_color(SLOG_CYAN, "ADC Single Conversion\n");
@@ -79,6 +85,7 @@ _ADC_Conv_Single(ADC_ChannelsTypeDef channel)
ADC_Init(ADC0, &init);
/* Start ADC conversion */
+ msg("Trigger ADC\n");
ADC_Start(ADC0);
/* Wait ADC idle */
@@ -86,7 +93,8 @@ _ADC_Conv_Single(ADC_ChannelsTypeDef channel)
/* Get ADC conversion value */
value = ADC_GetChannelConvValue(ADC0, channel);
- msg(" ADC Value: %d\n", value);
+ msg(" ch-%02d ADC Value: %d, voltage: %f\n",
+ index, value, _ADC_Convert_Voltage(value));
ADC_DeInit(ADC0);
return rval;
@@ -109,7 +117,8 @@ _ADC_Conv_Continuous(ADC_ChannelsTypeDef channels)
init.IsSoftTrig = true;
ADC_Init(ADC0, &init);
- /* Start ADC conversion */
+ /* Start ADC conversion once */
+ msg("Trigger ADC \n");
ADC_Start(ADC0);
sys_delay(3);
@@ -118,8 +127,10 @@ _ADC_Conv_Continuous(ADC_ChannelsTypeDef channels)
uint32_t chnnls_set = 0;
/**
- * ToDo: User modify the AIN channel voltage
+ * User modify the AIN channel voltage
*/
+ log_color(SLOG_GREEN, "=> Change External Voltage\n");
+ sys_delay(1000);
chnnls_set = (uint32_t)channels;
@@ -131,7 +142,8 @@ _ADC_Conv_Continuous(ADC_ChannelsTypeDef channels)
/* Get ADC conversion value */
value = ADC_GetChannelConvValue(ADC0, 0x1ul << index);
- msg(" ch-%02d ADC Value: %d\n", index, value);
+ msg(" ch-%02d ADC Value: %d, voltage: %f\n",
+ index, value, _ADC_Convert_Voltage(value));
}
}
@@ -160,12 +172,16 @@ _ADC_Conv_Scan(ADC_ChannelsTypeDef channels)
for(int i = 0; i < CONFIG_REPEAT_TIMES; i++)
{
/**
- * ToDo: User modify the AIN channel voltage
+ * User modify the AIN channel voltage
*/
+ log_color(SLOG_GREEN, "=> Change External Voltage\n");
+ sys_delay(1000);
- /* Start ADC conversion */
+ /* Start ADC conversion every time */
+ msg("Trigger ADC \n");
ADC_Start(ADC0);
+
/* Wait ADC idle */
while( ADC_IsIdle(ADC0) == 0 );
@@ -179,8 +195,9 @@ _ADC_Conv_Scan(ADC_ChannelsTypeDef channels)
chnnls_set &= ~(0x1ul << index);
/* Get ADC conversion value */
- value = ADC_GetChannelConvValue(ADC0, 0x1ul << index);
- msg(" ch-%02d ADC Value: %d\n", index, value);
+ value = ADC_ITGetConvValue(ADC0, 0x1ul << index);
+ msg(" ch-%02d ADC Value: %d, voltage: %f\n",
+ index, value, _ADC_Convert_Voltage(value));
}
}
@@ -217,11 +234,18 @@ _ADC_Conv_Discontinuous(ADC_ChannelsTypeDef channels)
for(int i = 0; i < CONFIG_REPEAT_TIMES; i++)
{
+ /**
+ * User modify the AIN channel voltage
+ */
+ log_color(SLOG_GREEN, "=> Change External Voltage\n");
+ sys_delay(1000);
+
for(int j = 0; j < trigger_cnt; j++)
{
- msg(" ## trigger %02d-th\n", j);
+ msg("\n ## trigger %02d-th\n", j);
/* Start ADC conversion */
+ msg(" Trigger ADC \n");
ADC_Start(ADC0);
/* Wait ADC idle */
@@ -237,8 +261,9 @@ _ADC_Conv_Discontinuous(ADC_ChannelsTypeDef channels)
chnnls_set &= ~(0x1ul << index);
/* Get ADC conversion value */
- value = ADC_GetChannelConvValue(ADC0, 0x1ul << index);
- msg(" ch-%02d ADC Value: %d\n", index, value);
+ value = ADC_ITGetConvValue(ADC0, 0x1ul << index);
+ msg(" ch-%02d ADC Value: %d, voltage: %f\n",
+ index, value, _ADC_Convert_Voltage(value));
}
}
}
@@ -274,7 +299,7 @@ int main(void)
#endif
);
- msg(" key = P%s%d\n",
+ msg(" Button = P%s%d\n",
(CONFIG_GPIO_INPUT_PORTx == GPIOA) ? "A" : "B",
31ul - HAL_CLZ(CONFIG_GPIO_INPUT_PINx));
@@ -302,7 +327,7 @@ int main(void)
g_hasPullLow = false;
#if (CONFIG_TARGET_ADC_MODE_CONTINOUS)
- rval = _ADC_Conv_Continuous(CONFIG_TARGET_1_ADC_CHANNEL);
+ rval = _ADC_Conv_Continuous(CONFIG_TARGET_ADC_MULTI_CHANNELS);
if( rval ) break;
#elif (CONFIG_TARGET_ADC_MODE_SCAN)
diff --git a/Examples/adc/adc_for_TI/.cproject b/Examples/adc/adc_for_TI/.cproject
deleted file mode 100644
index 21d0162..0000000
--- a/Examples/adc/adc_for_TI/.cproject
+++ /dev/null
@@ -1,293 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Examples/adc/adc_for_TI/readme.md b/Examples/adc/adc_for_TI/readme.md
deleted file mode 100644
index cdbc22b..0000000
--- a/Examples/adc/adc_for_TI/readme.md
+++ /dev/null
@@ -1,17 +0,0 @@
-ADC test
----
-
-This example is used to run compare test function.
-
-## Hardware and Software environment
-
-+ This example runs on PB5700 devices.
-
-## How to use it ?
-
-### In order to make the program work, you must do the following:
-
-+ Open your preferred toolchain
-+ Rebuild all files and load your image into target memory
-+ Run the example
-+ READ AIN2 ADC DATA
\ No newline at end of file
diff --git a/Examples/adc/adc_for_TI/src/main.c b/Examples/adc/adc_for_TI/src/main.c
deleted file mode 100644
index 4d15b57..0000000
--- a/Examples/adc/adc_for_TI/src/main.c
+++ /dev/null
@@ -1,77 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file main.c
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/08/29
- * @license
- * @description
- */
-
-
-#include "main.h"
-#include "isr.h"
-#include
-//=============================================================================
-// Constant Definition
-//=============================================================================
-#define GPIO_PORTx GPIOA
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-int main(void)
-{
- {
- SYSCFG_ClkInitTypeDef SysClkInit = {0};
-
- SysClkInit.ClkSource = SYSCFG_ClkSrc_HSI;
- SYSCFG_SysClkConfig(&SysClkInit);
- }
-
- sys_config_systick(SYS_TICK_1_MS);
-
- syslog_init();
-
- info("%s\nThis is a demo project to adc Conversion TriggerSW\n", __TIME__);
-
- __HAL_SYSCFG_ADC_CLK_ENABLE();
-
- REG_WRITE_MASK(ADC0->CON0, ADC_CON0_M_Msk, ADC_Channel_02); // Selection AIN2 (@ref ADC_ChannelsTypeDef)
-
- /* ADC Enable */
- REG_SET_BITS(ADC0->CON0, ADC_CON0_EN_Msk);
-
- while( 1 )
- {
- uint16_t adcValue = 0;
-
- ADC->CON0 |= ADC_CON0_START_Msk;
- while( (ADC->STAT & ADC_STAT_DONE_Msk) == 0 );
-
- adcValue = REG_READ_MASK(ADC->DAT2, 0xFFF); // Read AIN2 DATA DAT2
-
- msg("ACD sample value = x%08X\n", adcValue);
-
- REG_CLR_BITS(ADC->STAT, ADC_STAT_DONE_Msk);
- }
-
-}
diff --git a/Apps/demo_project/.cproject b/Examples/adc/adc_single_conv/.cproject
similarity index 95%
rename from Apps/demo_project/.cproject
rename to Examples/adc/adc_single_conv/.cproject
index d9ac06f..1a0019e 100644
--- a/Apps/demo_project/.cproject
+++ b/Examples/adc/adc_single_conv/.cproject
@@ -45,23 +45,23 @@
-
-
-
+
+
+
@@ -69,14 +69,14 @@
@@ -95,7 +95,7 @@
-
-
+
+
@@ -193,10 +193,10 @@
@@ -205,14 +205,14 @@
@@ -226,7 +226,7 @@
diff --git a/Examples/I2C/I2C_Master_EEPROM/.project b/Examples/adc/adc_single_conv/.project
similarity index 100%
rename from Examples/I2C/I2C_Master_EEPROM/.project
rename to Examples/adc/adc_single_conv/.project
diff --git a/Examples/I2C/I2C_Master_EEPROM/Project.nuproject b/Examples/adc/adc_single_conv/Project.nuproject
similarity index 100%
rename from Examples/I2C/I2C_Master_EEPROM/Project.nuproject
rename to Examples/adc/adc_single_conv/Project.nuproject
diff --git a/Examples/I2C/I2C_Master_EEPROM/component.mk b/Examples/adc/adc_single_conv/component.mk
similarity index 100%
rename from Examples/I2C/I2C_Master_EEPROM/component.mk
rename to Examples/adc/adc_single_conv/component.mk
diff --git a/Examples/adc/adc_for_TI/inc/isr.h b/Examples/adc/adc_single_conv/inc/isr.h
similarity index 100%
rename from Examples/adc/adc_for_TI/inc/isr.h
rename to Examples/adc/adc_single_conv/inc/isr.h
diff --git a/Examples/I2C/I2C_Master_EEPROM/inc/main.h b/Examples/adc/adc_single_conv/inc/main.h
similarity index 100%
rename from Examples/I2C/I2C_Master_EEPROM/inc/main.h
rename to Examples/adc/adc_single_conv/inc/main.h
diff --git a/Examples/adc/adc_single_conv_interrupt/readme.md b/Examples/adc/adc_single_conv/readme.md
similarity index 59%
rename from Examples/adc/adc_single_conv_interrupt/readme.md
rename to Examples/adc/adc_single_conv/readme.md
index 0d7c791..b457ad1 100644
--- a/Examples/adc/adc_single_conv_interrupt/readme.md
+++ b/Examples/adc/adc_single_conv/readme.md
@@ -31,6 +31,32 @@ This example is a single channel conversion of ADC with interrupt
#define CONFIG_ADC_IO_SRC_PORT GPIOA
#define CONFIG_ADC_IO_SRC_PIN GPIO_Pin_13
#define CONFIG_TARGGET_ADC_CHANNEL ADC_Channel_07
+ #elif 0
+ #define CONFIG_ADC_IO_SRC_PORT GPIOA
+ #define CONFIG_ADC_IO_SRC_PIN GPIO_Pin_06
+ #define CONFIG_TARGGET_ADC_CHANNEL ADC_Channel_08
+ #elif 0
+ #define CONFIG_ADC_IO_SRC_PORT GPIOA
+ #define CONFIG_ADC_IO_SRC_PIN GPIO_Pin_07
+ #define CONFIG_TARGGET_ADC_CHANNEL ADC_Channel_09
+ #elif 0
+ #define CONFIG_ADC_IO_SRC_PORT GPIOA
+ #define CONFIG_ADC_IO_SRC_PIN GPIO_Pin_14
+ #define CONFIG_TARGGET_ADC_CHANNEL ADC_Channel_10
+ #elif 0
+ #define CONFIG_ADC_IO_SRC_PORT GPIOA
+ #define CONFIG_ADC_IO_SRC_PIN GPIO_Pin_15
+ #define CONFIG_TARGGET_ADC_CHANNEL ADC_Channel_11
+ #elif 0
+ #define CONFIG_ADC_IO_SRC_PORT GPIOB
+ #define CONFIG_ADC_IO_SRC_PIN GPIO_Pin_00
+ #define CONFIG_TARGGET_ADC_CHANNEL ADC_Channel_12
+ #elif 0
+ #define CONFIG_ADC_IO_SRC_PORT GPIOB
+ #define CONFIG_ADC_IO_SRC_PIN GPIO_Pin_01
+ #define CONFIG_TARGGET_ADC_CHANNEL ADC_Channel_13
+ #elif 0
+ #define CONFIG_TARGGET_ADC_CHANNEL ADC_Channel_14
#else
#define CONFIG_TARGGET_ADC_CHANNEL ADC_Channel_15
#endif
diff --git a/Examples/adc/adc_for_TI/src/isr.c b/Examples/adc/adc_single_conv/src/isr.c
similarity index 100%
rename from Examples/adc/adc_for_TI/src/isr.c
rename to Examples/adc/adc_single_conv/src/isr.c
diff --git a/Examples/adc/adc_single_conv_interrupt/src/main.c b/Examples/adc/adc_single_conv/src/main.c
similarity index 51%
rename from Examples/adc/adc_single_conv_interrupt/src/main.c
rename to Examples/adc/adc_single_conv/src/main.c
index 984772e..2d0a18a 100644
--- a/Examples/adc/adc_single_conv_interrupt/src/main.c
+++ b/Examples/adc/adc_single_conv/src/main.c
@@ -17,6 +17,8 @@
// Constant Definition
//=============================================================================
+#define CONFIG_USE_ADC_INTERRUPT 1
+
#if 1
#define CONFIG_ADC_IO_SRC_PORT GPIOA
#define CONFIG_ADC_IO_SRC_PIN GPIO_Pin_08
@@ -41,6 +43,32 @@
#define CONFIG_ADC_IO_SRC_PORT GPIOA
#define CONFIG_ADC_IO_SRC_PIN GPIO_Pin_13
#define CONFIG_TARGGET_ADC_CHANNEL ADC_Channel_07
+#elif 0
+ #define CONFIG_ADC_IO_SRC_PORT GPIOA
+ #define CONFIG_ADC_IO_SRC_PIN GPIO_Pin_06
+ #define CONFIG_TARGGET_ADC_CHANNEL ADC_Channel_08
+#elif 0
+ #define CONFIG_ADC_IO_SRC_PORT GPIOA
+ #define CONFIG_ADC_IO_SRC_PIN GPIO_Pin_07
+ #define CONFIG_TARGGET_ADC_CHANNEL ADC_Channel_09
+#elif 0
+ #define CONFIG_ADC_IO_SRC_PORT GPIOA
+ #define CONFIG_ADC_IO_SRC_PIN GPIO_Pin_14
+ #define CONFIG_TARGGET_ADC_CHANNEL ADC_Channel_10
+#elif 0
+ #define CONFIG_ADC_IO_SRC_PORT GPIOA
+ #define CONFIG_ADC_IO_SRC_PIN GPIO_Pin_15
+ #define CONFIG_TARGGET_ADC_CHANNEL ADC_Channel_11
+#elif 0
+ #define CONFIG_ADC_IO_SRC_PORT GPIOB
+ #define CONFIG_ADC_IO_SRC_PIN GPIO_Pin_00
+ #define CONFIG_TARGGET_ADC_CHANNEL ADC_Channel_12
+#elif 0
+ #define CONFIG_ADC_IO_SRC_PORT GPIOB
+ #define CONFIG_ADC_IO_SRC_PIN GPIO_Pin_01
+ #define CONFIG_TARGGET_ADC_CHANNEL ADC_Channel_13
+#elif 0
+ #define CONFIG_TARGGET_ADC_CHANNEL ADC_Channel_14
#else
#define CONFIG_TARGGET_ADC_CHANNEL ADC_Channel_15
#endif
@@ -57,8 +85,20 @@
//=============================================================================
// Global Data Definition
//=============================================================================
-static uint16_t g_ConvValue = 0;
-static bool g_IsDone = false;
+static uint16_t g_ConvValue = 0;
+static bool g_IsDone = false;
+static ADC_SubChannelTypeDef g_a15_sub_chnnl = ADC_SubChannel_NONE;
+
+static ADC_SubChannelTypeDef g_sub_channels[] =
+{
+ ADC_SubChannel_TEMP,
+ ADC_SubChannel_DAC0,
+ ADC_SubChannel_DAC1,
+ ADC_SubChannel_VBuf_1_5,
+ ADC_SubChannel_VDDL,
+ ADC_SubChannel_VSS,
+ ADC_SubChannel_VDD,
+};
//=============================================================================
// Private Function Definition
//=============================================================================
@@ -68,8 +108,6 @@ __INTERRUPT void ADC0_Handler(void)
g_ConvValue = ADC_ITGetConvValue(ADC0, CONFIG_TARGGET_ADC_CHANNEL);
- ADC_ClearITFlag(ADC0);
-
g_IsDone = true;
RESTORE_IRQ_CSR_CONTEXT();
@@ -81,6 +119,11 @@ static void _Config_AIN_IO(void)
{
GPIO_InitTypeDef gpio_init = {0};
+ if( CONFIG_TARGGET_ADC_CHANNEL == ADC_Channel_13 )
+ {
+ SYSCFG_SetRstPin2NormalIO(true);
+ }
+
gpio_init.GPIO_Pin = CONFIG_ADC_IO_SRC_PIN;
gpio_init.GPIO_Mode = GPIO_Mode_ANAL;
GPIO_Init(CONFIG_ADC_IO_SRC_PORT, &gpio_init);
@@ -97,7 +140,12 @@ int main(void)
{ /* Configure system clock */
SYSCFG_ClkInitTypeDef SysClkInit = {0};
+ #if 1
SysClkInit.ClkSource = SYSCFG_ClkSrc_HSI;
+ #else
+ SysClkInit.ClkSource = SYSCFG_ClkSrc_FreqDiv;
+ SysClkInit.SysClk_Div = SYSCFG_SysClkDiv4;
+ #endif
SYSCFG_SysClkConfig(&SysClkInit);
}
@@ -112,42 +160,80 @@ int main(void)
{ /* Configure ADC */
ADC_InitTypeDef init = {0};
- sys_irq_attr_t irq_attr = { .disable_vector = false, };
-
- irq_attr.trig_mode = SYS_IRQ_TRIGGER_LEVEL;
- irq_attr.level = SYS_IRQ_LEVEL_L;
- irq_attr.priority = SYS_IRQ_PRIORITY_MIDDEN;
- sys_register_IRQ(ADC0_IRQn, ADC0_Handler, &irq_attr);
ADC_StructInit(&init);
+ if( init.SelChannels == ADC_Channel_15 )
+ {
+ ADC_SelSubChannel(g_a15_sub_chnnl);
+
+ init.ClkPrescaler = ADC_ClkDiv_32;
+ }
+
init.SelChannels = CONFIG_TARGGET_ADC_CHANNEL;
init.IsSoftTrig = true;
ADC_Init(ADC0, &init);
- ADC_ITConfig(ADC0, ADC_IT_CONV_DONE);
+ if( init.SelChannels == ADC_Channel_15 )
+ {
+ ADC_SetSampleCycles(ADC0, 0x1F);
+ }
+
+ #if defined(CONFIG_USE_ADC_INTERRUPT) && (CONFIG_USE_ADC_INTERRUPT)
+ {
+ sys_irq_attr_t irq_attr = { .disable_vector = false, };
+
+ irq_attr.trig_mode = SYS_IRQ_TRIGGER_LEVEL;
+ irq_attr.level = SYS_IRQ_LEVEL_L;
+ irq_attr.priority = SYS_IRQ_PRIORITY_MIDDEN;
+ sys_register_IRQ(ADC0_IRQn, ADC0_Handler, &irq_attr);
+ ADC_ITConfig(ADC0, ADC_IT_CONV_DONE);
+ }
+ #endif
}
g_IsDone = false;
ADC_Start(ADC0);
+ sys_delay(100);
+
while(1)
{
static int cnt = 0;
+ #if defined(CONFIG_USE_ADC_INTERRUPT) && (CONFIG_USE_ADC_INTERRUPT)
if( g_IsDone == false )
continue;
+ g_IsDone = false;
+ #else /* CONFIG_USE_ADC_INTERRUPT */
+ g_ConvValue = ADC_GetChannelConvValue(ADC0, CONFIG_TARGGET_ADC_CHANNEL);
+ #endif /* CONFIG_USE_ADC_INTERRUPT */
+
cnt++;
- msg(" %d-th ADC Single Conv Value = 0x%02X (%d)\n",
+ msg(" %d-th ADC Single Conv Value(12-bits) = 0x%02X (%d)\n",
cnt, g_ConvValue, g_ConvValue);
- g_IsDone = false;
+ if( CONFIG_TARGGET_ADC_CHANNEL == ADC_Channel_15 )
+ {
+ log_color(SLOG_GREEN, "\n\nSet internal signal: %s\n",
+ (g_a15_sub_chnnl == ADC_SubChannel_TEMP ) ? "Temperature" :
+ (g_a15_sub_chnnl == ADC_SubChannel_DAC0 ) ? "DAC 0" :
+ (g_a15_sub_chnnl == ADC_SubChannel_DAC1 ) ? "DAC 1" :
+ (g_a15_sub_chnnl == ADC_SubChannel_VBuf_1_5 ) ? "V1.5" :
+ (g_a15_sub_chnnl == ADC_SubChannel_VDDL ) ? "VDDL" :
+ (g_a15_sub_chnnl == ADC_SubChannel_VSS ) ? "VSS" :
+ (g_a15_sub_chnnl == ADC_SubChannel_VDD ) ? "VDD" :
+ "None");
- sys_delay(1000);
+ ADC_SelSubChannel(g_a15_sub_chnnl);
+
+ g_a15_sub_chnnl = g_sub_channels[cnt % (sizeof(g_sub_channels)/sizeof(g_sub_channels[0]))];
+ }
ADC_Start(ADC0);
+ sys_delay(1000);
}
return 0;
diff --git a/Examples/adc/adc_trigger_src/.cproject b/Examples/adc/adc_trigger_src/.cproject
deleted file mode 100644
index 2f90cfe..0000000
--- a/Examples/adc/adc_trigger_src/.cproject
+++ /dev/null
@@ -1,294 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Examples/adc/adc_trigger_src/readme.md b/Examples/adc/adc_trigger_src/readme.md
deleted file mode 100644
index 0d42102..0000000
--- a/Examples/adc/adc_trigger_src/readme.md
+++ /dev/null
@@ -1,34 +0,0 @@
-adc_trigger_src
----
-
-This is an example to select the source to trigger ADC start
-> It uses the specific pin to trigge ADC
-
-+ Select the ADC converison channel
-
- ```
- // in main.c
- #define CONFIG_TARGGET_ADC_1_CHANNEL ADC_Channel_15
- ```
-
-+ Select the specific pin to trigger ADC
- > It supports PB1 or PB2
-
- ```
- // in main.c
- #define CONFIG_ADC_EXT_TRIG_SRC ADC_ExtTrigSource_PB1
- ```
-
-+ Select the trigger mode of the specific pin
- > It supports rising or falling trigger mode
-
- ```
- // in main.c
- #define CONFIG_ADC_EXT_TRIG_MODE ADC_ExtTrigMode_PinRising
- ```
-
-
-## Log
-
-Use serial port with baudrate 115200, 8bit, no parity check.
-
diff --git a/Examples/adc/adc_trigger_src/src/main.c b/Examples/adc/adc_trigger_src/src/main.c
deleted file mode 100644
index 7316960..0000000
--- a/Examples/adc/adc_trigger_src/src/main.c
+++ /dev/null
@@ -1,111 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file main.c
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/08/29
- * @license
- * @description
- */
-
-
-#include "main.h"
-#include "isr.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-#define CONFIG_TARGGET_ADC_1_CHANNEL ADC_Channel_15
-#define CONFIG_ADC_EXT_TRIG_SRC ADC_ExtTrigSource_PB1 // ADC_ExtTrigSource_PB2
-#define CONFIG_ADC_EXT_TRIG_MODE ADC_ExtTrigMode_PinRising // ADC_ExtTrigMode_PinFaling
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-static uint16_t g_ConvValue = 0;
-static bool g_IsDone = false;
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-__INTERRUPT void ADC0_Handler(void)
-{
- SAVE_IRQ_CSR_CONTEXT();
-
- ADC_ClearITFlag(ADC0);
-
- g_ConvValue = ADC_GetChannelConvValue(ADC0, CONFIG_TARGGET_ADC_1_CHANNEL);
-
- g_IsDone = true;
-
- RESTORE_IRQ_CSR_CONTEXT();
- return;
-}
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-int main(void)
-{
- { /* Configure system clock */
- SYSCFG_ClkInitTypeDef SysClkInit = {0};
-
- SysClkInit.ClkSource = SYSCFG_ClkSrc_HSI;
- SYSCFG_SysClkConfig(&SysClkInit);
- }
-
- sys_config_systick(SYS_TICK_1_MS);
-
- syslog_init();
-
- info("%s %s\nADC Trigger single conversion (AIN-%d) from external source (Pin: %s)\n",
- __DATE__, __TIME__,
- (31ul - HAL_CLZ(CONFIG_TARGGET_ADC_1_CHANNEL)),
- (CONFIG_ADC_EXT_TRIG_SRC == ADC_ExtTrigSource_PB1) ? "PB1" : "PB2");
-
- { /* Configure ADC */
- ADC_InitTypeDef init = {0};
- sys_irq_attr_t irq_attr = { .disable_vector = false, };
-
- irq_attr.trig_mode = SYS_IRQ_TRIGGER_LEVEL;
- irq_attr.level = SYS_IRQ_LEVEL_L;
- irq_attr.priority = SYS_IRQ_PRIORITY_MIDDEN;
- sys_register_IRQ(ADC0_IRQn, ADC0_Handler, &irq_attr);
-
- ADC_StructInit(&init);
-
- init.SelChannels = CONFIG_TARGGET_ADC_1_CHANNEL;
- init.IsSoftTrig = false;
- ADC_Init(ADC0, &init);
-
- ADC_ExtTrigConfig(ADC0, CONFIG_ADC_EXT_TRIG_SRC, CONFIG_ADC_EXT_TRIG_MODE);
- ADC_ITConfig(ADC0, ADC_IT_CONV_DONE);
- }
-
- g_IsDone = false;
-
- /* User makes External-Pin Rising/Falling to trigger ADC start */
-
- while(1)
- {
- static int cnt = 0;
-
- if( g_IsDone == false )
- continue;
-
- cnt++;
-
- msg(" %d-th ADC Single Conv Value = 0x%02X (%d)\n",
- cnt, g_ConvValue, g_ConvValue);
-
- g_IsDone = false;
- }
-
- return 0;
-}
diff --git a/Examples/I2C/I2C_Master_EEPROM/.cproject b/Examples/adc/adc_trigger_src_io/.cproject
similarity index 95%
rename from Examples/I2C/I2C_Master_EEPROM/.cproject
rename to Examples/adc/adc_trigger_src_io/.cproject
index d9ac06f..1a0019e 100644
--- a/Examples/I2C/I2C_Master_EEPROM/.cproject
+++ b/Examples/adc/adc_trigger_src_io/.cproject
@@ -45,23 +45,23 @@
-
-
-
+
+
+
@@ -69,14 +69,14 @@
@@ -95,7 +95,7 @@
-
-
+
+
@@ -193,10 +193,10 @@
@@ -205,14 +205,14 @@
@@ -226,7 +226,7 @@
diff --git a/Examples/I2C/I2C_Slave_STM32/.project b/Examples/adc/adc_trigger_src_io/.project
similarity index 100%
rename from Examples/I2C/I2C_Slave_STM32/.project
rename to Examples/adc/adc_trigger_src_io/.project
diff --git a/Examples/I2C/I2C_Slave_STM32/Project.nuproject b/Examples/adc/adc_trigger_src_io/Project.nuproject
similarity index 100%
rename from Examples/I2C/I2C_Slave_STM32/Project.nuproject
rename to Examples/adc/adc_trigger_src_io/Project.nuproject
diff --git a/Examples/I2C/I2C_Slave_STM32/component.mk b/Examples/adc/adc_trigger_src_io/component.mk
similarity index 100%
rename from Examples/I2C/I2C_Slave_STM32/component.mk
rename to Examples/adc/adc_trigger_src_io/component.mk
diff --git a/Examples/adc/adc_single_conv_interrupt/inc/isr.h b/Examples/adc/adc_trigger_src_io/inc/isr.h
similarity index 100%
rename from Examples/adc/adc_single_conv_interrupt/inc/isr.h
rename to Examples/adc/adc_trigger_src_io/inc/isr.h
diff --git a/Examples/I2C/I2C_Slave_STM32/inc/main.h b/Examples/adc/adc_trigger_src_io/inc/main.h
similarity index 100%
rename from Examples/I2C/I2C_Slave_STM32/inc/main.h
rename to Examples/adc/adc_trigger_src_io/inc/main.h
diff --git a/Examples/adc/adc_trigger_src_io/readme.md b/Examples/adc/adc_trigger_src_io/readme.md
new file mode 100644
index 0000000..71a46fd
--- /dev/null
+++ b/Examples/adc/adc_trigger_src_io/readme.md
@@ -0,0 +1,108 @@
+adc_trigger_src_io
+---
+
+This is an example to select the source (I/O) to trigger ADC start
+> It uses the specific pin to trigge ADC
+
++ Select the ADC converison channel
+
+ ```
+ // in main.c
+ #define CONFIG_ADC_IO_SRC_PORT GPIOA
+ #define CONFIG_ADC_IO_SRC_PIN GPIO_Pin_09
+ #define CONFIG_TARGGET_ADC_1_CHANNEL ADC_Channel_03
+ ```
+
++ Select the specific pin to trigger ADC
+ > It supports PB1 (nRST) or PB2 (JTCK)
+ >> PB1/PB2 MUST be changed to normal I/O mode
+
+ ```
+ // in main.c
+ #define CONFIG_ADC_EXT_TRIG_SRC ADC_ExtTrigSource_PB1
+ ```
+
++ Select the trigger mode of the specific pin
+ > It supports rising or falling trigger mode
+
+ ```
+ // in main.c
+ #define CONFIG_ADC_EXT_TRIG_MODE ADC_ExtTrigMode_PinRising
+ ```
+
+
+## Log
+
+Use serial port with baudrate 115200, 8bit, no parity check.
+
++ Link PB1 to button
+
+ - Trigger ADC when free button
+
+ ```
+ Oct 7 2025 15:46:32
+ ADC Trigger single conversion (AIN-3) from external source (Pin: PB1 Rising)
+ Button = PA2
+ Press Button to setup I/O trigger ...
+ PB1 (nRST) => I/O
+ 1-th ADC Single Conv Value = 0x77C (1916) <--- Trigger ADC when free button
+ 2-th ADC Single Conv Value = 0x778 (1912)
+ 3-th ADC Single Conv Value = 0x77A (1914)
+ 4-th ADC Single Conv Value = 0x77E (1918)
+ 5-th ADC Single Conv Value = 0x77F (1919)
+ ```
+
+ - Trigger ADC when press button
+
+ ```
+ Oct 7 2025 15:59:09
+ ADC Trigger single conversion (AIN-3) from external source (Pin: PB1 Falling)
+ Button = PA2
+ Press Button to setup I/O trigger ...
+ PB1 (nRST) => I/O
+ 1-th ADC Single Conv Value = 0x775 (1909) <--- Trigger ADC when press button
+ 2-th ADC Single Conv Value = 0x789 (1929)
+ 3-th ADC Single Conv Value = 0x78A (1930)
+ 4-th ADC Single Conv Value = 0x777 (1911)
+ ```
+
++ Link PB2 to button
+
+ - Trigger ADC when free button
+
+ ```
+ Oct 7 2025 16:18:35
+ ADC Trigger single conversion (AIN-3) from external source (Pin: PB2 Rising)
+ Button = PA2
+ Press Button to setup I/O trigger ...
+ 1-th ADC Single Conv Value = 0x7DF (2015) <--- Link ICE handshaking
+ 2-th ADC Single Conv Value = 0x722 (1826)
+ 3-th ADC Single Conv Value = 0x6E8 (1768)
+ 4-th ADC Single Conv Value = 0x752 (1874)
+ 5-th ADC Single Conv Value = 0x748 (1864)
+ 6-th ADC Single Conv Value = 0x675 (1653)
+ PB2 (JTCK) => I/O <--- disable ICE
+ 7-th ADC Single Conv Value = 0x789 (1929) <--- free button
+ 8-th ADC Single Conv Value = 0x7E5 (2021)
+ ...
+ ```
+
+ - Trigger ADC when press button
+
+ ```
+ Oct 3 2025 16:22:41
+ ADC Trigger single conversion (AIN-3) from external source (Pin: PB2 Falling)
+ Button = PA2
+ Press Button to setup I/O trigger ...
+ ...
+ 31-th ADC Single Conv Value = 0x78A (1930) <--- Link ICE handshaking
+ 32-th ADC Single Conv Value = 0x77B (1915)
+ 33-th ADC Single Conv Value = 0x7A8 (1960)
+ 34-th ADC Single Conv Value = 0x792 (1938)
+ 35-th ADC Single Conv Value = 0x777 (1911) <--- Link ICE handshaking
+ PB2 (JTCK) => I/O <--- disable ICE
+ 36-th ADC Single Conv Value = 0x7EC (2028) <--- press button
+ 37-th ADC Single Conv Value = 0x777 (1911)
+ 38-th ADC Single Conv Value = 0x78E (1934)
+ 39-th ADC Single Conv Value = 0x792 (1938)
+ ```
diff --git a/Examples/adc/adc_single_conv_interrupt/src/isr.c b/Examples/adc/adc_trigger_src_io/src/isr.c
similarity index 100%
rename from Examples/adc/adc_single_conv_interrupt/src/isr.c
rename to Examples/adc/adc_trigger_src_io/src/isr.c
diff --git a/Examples/adc/adc_trigger_src_io/src/main.c b/Examples/adc/adc_trigger_src_io/src/main.c
new file mode 100644
index 0000000..4d90c47
--- /dev/null
+++ b/Examples/adc/adc_trigger_src_io/src/main.c
@@ -0,0 +1,223 @@
+/**
+ * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
+ */
+/** @file main.c
+ *
+ * @author Wei-Lun Hsu
+ * @version 0.1
+ * @date 2024/08/29
+ * @license
+ * @description
+ */
+
+
+#include "main.h"
+#include "isr.h"
+//=============================================================================
+// Constant Definition
+//=============================================================================
+
+#define CONFIG_ADC_IO_SRC_PORT GPIOA
+#define CONFIG_ADC_IO_SRC_PIN GPIO_Pin_09
+#define CONFIG_TARGGET_ADC_1_CHANNEL ADC_Channel_03
+
+/**
+ * I/O triggr is PB1 or PB2
+ * + ADC_ExtTrigSource_PB1
+ * + ADC_ExtTrigSource_PB2
+ */
+#define CONFIG_ADC_EXT_TRIG_SRC ADC_ExtTrigSource_PB1
+
+/**
+ * Trigger edge
+ * + ADC_ExtTrigMode_PinRising
+ * + ADC_ExtTrigMode_PinFaling
+ */
+#define CONFIG_ADC_EXT_TRIG_MODE ADC_ExtTrigMode_PinFaling
+
+/* Input Key I/O definitions */
+#define CONFIG_GPIO_INPUT_PORTx GPIOA
+#define CONFIG_GPIO_INPUT_PINx GPIO_Pin_02
+#define CONFIG_GPIO_IRQ GPIOA_IRQn // GPIOB_IRQn
+//=============================================================================
+// Macro Definition
+//=============================================================================
+
+//=============================================================================
+// Structure Definition
+//=============================================================================
+
+//=============================================================================
+// Global Data Definition
+//=============================================================================
+static uint16_t g_ConvValue = 0;
+static bool g_IsDone = false;
+static bool g_hasPullLow = false;
+//=============================================================================
+// Private Function Definition
+//=============================================================================
+__INTERRUPT void GPIOx_Handler(void)
+{
+ SAVE_IRQ_CSR_CONTEXT();
+
+ if( GPIO_GetITFlag(CONFIG_GPIO_INPUT_PORTx, CONFIG_GPIO_INPUT_PINx) )
+ {
+ GPIO_ClearITFlag(CONFIG_GPIO_INPUT_PORTx, CONFIG_GPIO_INPUT_PINx);
+
+ g_hasPullLow = true;
+ }
+
+ RESTORE_IRQ_CSR_CONTEXT();
+ return;
+}
+
+__INTERRUPT void ADC0_Handler(void)
+{
+ SAVE_IRQ_CSR_CONTEXT();
+
+ g_ConvValue = ADC_ITGetConvValue(ADC0, CONFIG_TARGGET_ADC_1_CHANNEL);
+
+ g_IsDone = true;
+
+ RESTORE_IRQ_CSR_CONTEXT();
+ return;
+}
+
+static void _Config_ButtonIO(void)
+{
+ GPIO_InitTypeDef GPIO_InitStruct = {0};
+
+ msg(" Button = P%s%d\n",
+ (CONFIG_GPIO_INPUT_PORTx == GPIOA) ? "A" : "B",
+ 31ul - HAL_CLZ(CONFIG_GPIO_INPUT_PINx));
+
+ GPIO_InitStruct.GPIO_Pin = CONFIG_GPIO_INPUT_PINx;
+ GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IN ;
+ GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL;
+ GPIO_InitStruct.GPIO_ITInit.GPIO_Trigger = GPIO_Trigger_Level;
+ GPIO_InitStruct.GPIO_ITInit.GPIO_Polarity = GPIO_Polarity_Low_Fall;
+ GPIO_Init(CONFIG_GPIO_INPUT_PORTx , &GPIO_InitStruct);
+
+ GPIO_ITEnable(CONFIG_GPIO_INPUT_PORTx, CONFIG_GPIO_INPUT_PINx);
+ return;
+}
+
+static void _Config_AIN_IO(void)
+{
+ GPIO_InitTypeDef gpio_init = {0};
+
+ gpio_init.GPIO_Pin = CONFIG_ADC_IO_SRC_PIN;
+ gpio_init.GPIO_Mode = GPIO_Mode_ANAL;
+ GPIO_Init(CONFIG_ADC_IO_SRC_PORT, &gpio_init);
+ return;
+}
+//=============================================================================
+// Public Function Definition
+//=============================================================================
+int main(void)
+{
+ REG_WRITE(SYSCFG->PRSTEN1, 0xFFFFFFFFul);
+ REG_WRITE(SYSCFG->PRSTEN, 0xFFFFFFFFul);
+ REG_WRITE(SYSCFG->PRSTEN1, 0x0ul);
+ REG_WRITE(SYSCFG->PRSTEN, 0x0ul);
+
+ { /* Configure system clock */
+ SYSCFG_ClkInitTypeDef SysClkInit = {0};
+
+ SysClkInit.ClkSource = SYSCFG_ClkSrc_HSI;
+ SYSCFG_SysClkConfig(&SysClkInit);
+ }
+
+ sys_config_systick(SYS_TICK_1_MS);
+
+ syslog_init();
+
+ info("%s %s\nADC Trigger single conversion (AIN-%d) from external source (Pin: %s %s)\n",
+ __DATE__, __TIME__,
+ (31ul - HAL_CLZ(CONFIG_TARGGET_ADC_1_CHANNEL)),
+ (CONFIG_ADC_EXT_TRIG_SRC == ADC_ExtTrigSource_PB1) ? "PB1" :
+ (CONFIG_ADC_EXT_TRIG_SRC == ADC_ExtTrigSource_PB2) ? "PB2" :
+ "N/A",
+ (CONFIG_ADC_EXT_TRIG_MODE == ADC_ExtTrigMode_PinRising) ? "Rising" : "Falling"
+ );
+
+ _Config_ButtonIO();
+ _Config_AIN_IO();
+
+ g_hasPullLow = false;
+
+ { /* Configure ADC */
+ ADC_InitTypeDef init = {0};
+ sys_irq_attr_t irq_attr = { .disable_vector = false, };
+
+ irq_attr.trig_mode = SYS_IRQ_TRIGGER_LEVEL;
+ irq_attr.level = SYS_IRQ_LEVEL_L;
+ irq_attr.priority = SYS_IRQ_PRIORITY_MIDDEN;
+ sys_register_IRQ(ADC0_IRQn, ADC0_Handler, &irq_attr);
+ sys_register_IRQ(CONFIG_GPIO_IRQ, GPIOx_Handler, &irq_attr);
+
+ ADC_StructInit(&init);
+
+ init.SelChannels = CONFIG_TARGGET_ADC_1_CHANNEL;
+ init.IsSoftTrig = false;
+ ADC_Init(ADC0, &init);
+
+ ADC_ExtTrigConfig(ADC0, CONFIG_ADC_EXT_TRIG_SRC, CONFIG_ADC_EXT_TRIG_MODE);
+ ADC_ITConfig(ADC0, ADC_IT_CONV_DONE);
+ }
+
+ g_IsDone = false;
+
+ /* User makes External-Pin Rising/Falling to trigger ADC start */
+ msg("Press Button to setup I/O trigger ...\n");
+
+ while(1)
+ {
+ static int cnt = 0;
+
+ if( g_hasPullLow == true )
+ {
+ static int is_io_mode = false;
+ GPIO_InitTypeDef gpio_init = {0};
+
+ g_hasPullLow = false;
+
+ if( CONFIG_ADC_EXT_TRIG_SRC == ADC_ExtTrigSource_PB1 )
+ {
+ SYSCFG_SetRstPin2NormalIO(true);
+
+ gpio_init.GPIO_Pin = GPIO_Pin_01;
+ msg(" PB1 (nRST) => I/O\n");
+ }
+ else if( CONFIG_ADC_EXT_TRIG_SRC == ADC_ExtTrigSource_PB2 )
+ {
+ SYSCFG_SetICEPin2NormalIO(true);
+
+ gpio_init.GPIO_Pin = GPIO_Pin_02;
+ msg(" PB2 (JTCK) => I/O\n");
+ }
+
+ if( is_io_mode == false )
+ {
+ gpio_init.GPIO_Mode = GPIO_Mode_IN;
+ gpio_init.GPIO_PuPd = GPIO_PuPd_UP;
+ gpio_init.GPIO_OType = GPIO_OType_PP;
+ GPIO_Init(GPIOB , &gpio_init);
+
+ is_io_mode = true;
+ }
+ }
+
+ if( g_IsDone == false )
+ continue;
+
+ cnt++;
+
+ msg(" %d-th ADC Single Conv Value = 0x%02X (%d)\n",
+ cnt, g_ConvValue, g_ConvValue);
+
+ g_IsDone = false;
+ }
+
+ return 0;
+}
diff --git a/Examples/adc/adc_verify_wr_rd_reg/.cproject b/Examples/adc/adc_verify_wr_rd_reg/.cproject
deleted file mode 100644
index 21d0162..0000000
--- a/Examples/adc/adc_verify_wr_rd_reg/.cproject
+++ /dev/null
@@ -1,293 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Examples/adc/adc_verify_wr_rd_reg/inc/isr.h b/Examples/adc/adc_verify_wr_rd_reg/inc/isr.h
deleted file mode 100644
index b1ab850..0000000
--- a/Examples/adc/adc_verify_wr_rd_reg/inc/isr.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file isr.h
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/09/16
- * @license
- * @description
- */
-
-#ifndef __isr_H_wuraIpBA_lTJm_HvJw_sNDo_uEd5JnucTReY__
-#define __isr_H_wuraIpBA_lTJm_HvJw_sNDo_uEd5JnucTReY__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-/**
- * ISRs of Internal Interrupt of IRQC
- */
-void irqc_mtip_handler(void);
-void irqc_msip_handler(void);
-
-/**
- * ISRs of External Interrupt of IRQC
- */
-void irqc_uart_handler(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/Examples/adc/adc_verify_wr_rd_reg/readme.md b/Examples/adc/adc_verify_wr_rd_reg/readme.md
deleted file mode 100644
index 00aa3ff..0000000
--- a/Examples/adc/adc_verify_wr_rd_reg/readme.md
+++ /dev/null
@@ -1,284 +0,0 @@
-adc read/write_registers
----
-
-This example is used to read/write_registers
-
-# Log
-
-Use serial port with baudrate 115200 8bit, no parity check.
-User can receive log infomation on `PA00->TXD` of DUT.
-
-16:43:25
-This is a demo project to adc Read Write register
-
-CON0: Register Default: 0XC0400000, Register Read: 0XC0400000
-Match
-
-CON0: Register Write: 0XFFFFFFFF, Register result value: 0XCF7F3F2F, Register Read: 0XCF7F3F2F
-Match
-
-CON0: Register Write: 0X0, Register result value: 0X0, Register Read: 0X0
-Match
-
-CON0: Register Write: 0X5A5A5A5A, Register result value: 0X4A5A1A0A, Register Read: 0X4A5A1A0A
-Match
-
-CON0: Register Write: 0XA5A5A5A5, Register result value: 0X85252525, Register Read: 0X85252525
-Match
-
-STAT: Register Default: 0X30040, Register Read: 0X30040
-Match
-
-STAT: Register Write: 0XFFFFFFFF, Register result value: 0XFF01C0, Register Read: 0XFF01C0
-Match
-
-STAT: Register Write: 0X0, Register result value: 0X30000, Register Read: 0X30000
-Match
-
-STAT: Register Write: 0X5A5A5A5A, Register result value: 0X5A0040, Register Read: 0X5A0040
-Match
-
-STAT: Register Write: 0XA5A5A5A5, Register result value: 0XA50180, Register Read: 0XA50180
-Match
-
-DATA0: Register Default: 0X0, Register Read: 0X0
-Match
-
-DATA1: Register Default: 0X0, Register Read: 0X0
-Match
-
-DATA2: Register Default: 0X0, Register Read: 0X0
-Match
-
-DATA3: Register Default: 0X0, Register Read: 0X0
-Match
-
-DATA4: Register Default: 0X0, Register Read: 0X0
-Match
-
-DATA5: Register Default: 0X0, Register Read: 0X0
-Match
-
-DATA6: Register Default: 0X0, Register Read: 0X0
-Match
-
-DATA7: Register Default: 0X0, Register Read: 0X0
-Match
-
-DATA8: Register Default: 0X0, Register Read: 0X0
-Match
-
-DATA9: Register Default: 0X0, Register Read: 0X0
-Match
-
-DATA10: Register Default: 0X0, Register Read: 0X0
-Match
-
-DATA11: Register Default: 0X0, Register Read: 0X0
-Match
-
-DATA12: Register Default: 0X0, Register Read: 0X0
-Match
-
-DATA13: Register Default: 0X0, Register Read: 0X0
-Match
-
-DATA14: Register Default: 0X0, Register Read: 0X0
-Match
-
-DATA15: Register Default: 0X0, Register Read: 0X0
-Match
-
-DATA0: Register Write: 0XFFFFFFFF, Register result value: 0XFFF0000, Register Read: 0XFFF0000
-Match
-
-DATA1: Register Write: 0XFFFFFFFF, Register result value: 0XFFF0000, Register Read: 0XFFF0000
-Match
-
-DATA2: Register Write: 0XFFFFFFFF, Register result value: 0XFFF0000, Register Read: 0XFFF0000
-Match
-
-DATA3: Register Write: 0XFFFFFFFF, Register result value: 0XFFF0000, Register Read: 0XFFF0000
-Match
-
-DATA4: Register Write: 0XFFFFFFFF, Register result value: 0XFFF0000, Register Read: 0XFFF0000
-Match
-
-DATA5: Register Write: 0XFFFFFFFF, Register result value: 0XFFF0000, Register Read: 0XFFF0000
-Match
-
-DATA6: Register Write: 0XFFFFFFFF, Register result value: 0XFFF0000, Register Read: 0XFFF0000
-Match
-
-DATA7: Register Write: 0XFFFFFFFF, Register result value: 0XFFF0000, Register Read: 0XFFF0000
-Match
-
-DATA8: Register Write: 0XFFFFFFFF, Register result value: 0XFFF0000, Register Read: 0XFFF0000
-Match
-
-DATA9: Register Write: 0XFFFFFFFF, Register result value: 0XFFF0000, Register Read: 0XFFF0000
-Match
-
-DATA10: Register Write: 0XFFFFFFFF, Register result value: 0XFFF0000, Register Read: 0XFFF0000
-Match
-
-DATA11: Register Write: 0XFFFFFFFF, Register result value: 0XFFF0000, Register Read: 0XFFF0000
-Match
-
-DATA12: Register Write: 0XFFFFFFFF, Register result value: 0XFFF0000, Register Read: 0XFFF0000
-Match
-
-DATA13: Register Write: 0XFFFFFFFF, Register result value: 0XFFF0000, Register Read: 0XFFF0000
-Match
-
-DATA14: Register Write: 0XFFFFFFFF, Register result value: 0XFFF0000, Register Read: 0XFFF0000
-Match
-
-DATA15: Register Write: 0XFFFFFFFF, Register result value: 0XFFF0000, Register Read: 0XFFF0000
-Match
-
-DATA0: Register Write: 0X0, Register result value: 0X0, Register Read: 0X0
-Match
-
-DATA1: Register Write: 0X0, Register result value: 0X0, Register Read: 0X0
-Match
-
-DATA2: Register Write: 0X0, Register result value: 0X0, Register Read: 0X0
-Match
-
-DATA3: Register Write: 0X0, Register result value: 0X0, Register Read: 0X0
-Match
-
-DATA4: Register Write: 0X0, Register result value: 0X0, Register Read: 0X0
-Match
-
-DATA5: Register Write: 0X0, Register result value: 0X0, Register Read: 0X0
-Match
-
-DATA6: Register Write: 0X0, Register result value: 0X0, Register Read: 0X0
-Match
-
-DATA7: Register Write: 0X0, Register result value: 0X0, Register Read: 0X0
-Match
-
-DATA8: Register Write: 0X0, Register result value: 0X0, Register Read: 0X0
-Match
-
-DATA9: Register Write: 0X0, Register result value: 0X0, Register Read: 0X0
-Match
-
-DATA10: Register Write: 0X0, Register result value: 0X0, Register Read: 0X0
-Match
-
-DATA11: Register Write: 0X0, Register result value: 0X0, Register Read: 0X0
-Match
-
-DATA12: Register Write: 0X0, Register result value: 0X0, Register Read: 0X0
-Match
-
-DATA13: Register Write: 0X0, Register result value: 0X0, Register Read: 0X0
-Match
-
-DATA14: Register Write: 0X0, Register result value: 0X0, Register Read: 0X0
-Match
-
-DATA15: Register Write: 0X0, Register result value: 0X0, Register Read: 0X0
-Match
-
-DATA0: Register Write: 0X5A5A5A5A, Register result value: 0XA5A0000, Register Read: 0XA5A0000
-Match
-
-DATA1: Register Write: 0X5A5A5A5A, Register result value: 0XA5A0000, Register Read: 0XA5A0000
-Match
-
-DATA2: Register Write: 0X5A5A5A5A, Register result value: 0XA5A0000, Register Read: 0XA5A0000
-Match
-
-DATA3: Register Write: 0X5A5A5A5A, Register result value: 0XA5A0000, Register Read: 0XA5A0000
-Match
-
-DATA4: Register Write: 0X5A5A5A5A, Register result value: 0XA5A0000, Register Read: 0XA5A0000
-Match
-
-DATA5: Register Write: 0X5A5A5A5A, Register result value: 0XA5A0000, Register Read: 0XA5A0000
-Match
-
-DATA6: Register Write: 0X5A5A5A5A, Register result value: 0XA5A0000, Register Read: 0XA5A0000
-Match
-
-DATA7: Register Write: 0X5A5A5A5A, Register result value: 0XA5A0000, Register Read: 0XA5A0000
-Match
-
-DATA8: Register Write: 0X5A5A5A5A, Register result value: 0XA5A0000, Register Read: 0XA5A0000
-Match
-
-DATA9: Register Write: 0X5A5A5A5A, Register result value: 0XA5A0000, Register Read: 0XA5A0000
-Match
-
-DATA10: Register Write: 0X5A5A5A5A, Register result value: 0XA5A0000, Register Read: 0XA5A0000
-Match
-
-DATA11: Register Write: 0X5A5A5A5A, Register result value: 0XA5A0000, Register Read: 0XA5A0000
-Match
-
-DATA12: Register Write: 0X5A5A5A5A, Register result value: 0XA5A0000, Register Read: 0XA5A0000
-Match
-
-DATA13: Register Write: 0X5A5A5A5A, Register result value: 0XA5A0000, Register Read: 0XA5A0000
-Match
-
-DATA14: Register Write: 0X5A5A5A5A, Register result value: 0XA5A0000, Register Read: 0XA5A0000
-Match
-
-DATA15: Register Write: 0X5A5A5A5A, Register result value: 0XA5A0000, Register Read: 0XA5A0000
-Match
-
-DATA0: Register Write: 0XA5A5A5A5, Register result value: 0X5A50000, Register Read: 0X5A50000
-Match
-
-DATA1: Register Write: 0XA5A5A5A5, Register result value: 0X5A50000, Register Read: 0X5A50000
-Match
-
-DATA2: Register Write: 0XA5A5A5A5, Register result value: 0X5A50000, Register Read: 0X5A50000
-Match
-
-DATA3: Register Write: 0XA5A5A5A5, Register result value: 0X5A50000, Register Read: 0X5A50000
-Match
-
-DATA4: Register Write: 0XA5A5A5A5, Register result value: 0X5A50000, Register Read: 0X5A50000
-Match
-
-DATA5: Register Write: 0XA5A5A5A5, Register result value: 0X5A50000, Register Read: 0X5A50000
-Match
-
-DATA6: Register Write: 0XA5A5A5A5, Register result value: 0X5A50000, Register Read: 0X5A50000
-Match
-
-DATA7: Register Write: 0XA5A5A5A5, Register result value: 0X5A50000, Register Read: 0X5A50000
-Match
-
-DATA8: Register Write: 0XA5A5A5A5, Register result value: 0X5A50000, Register Read: 0X5A50000
-Match
-
-DATA9: Register Write: 0XA5A5A5A5, Register result value: 0X5A50000, Register Read: 0X5A50000
-Match
-
-DATA10: Register Write: 0XA5A5A5A5, Register result value: 0X5A50000, Register Read: 0X5A50000
-Match
-
-DATA11: Register Write: 0XA5A5A5A5, Register result value: 0X5A50000, Register Read: 0X5A50000
-Match
-
-DATA12: Register Write: 0XA5A5A5A5, Register result value: 0X5A50000, Register Read: 0X5A50000
-Match
-
-DATA13: Register Write: 0XA5A5A5A5, Register result value: 0X5A50000, Register Read: 0X5A50000
-Match
-
-DATA14: Register Write: 0XA5A5A5A5, Register result value: 0X5A50000, Register Read: 0X5A50000
-Match
-
-DATA15: Register Write: 0XA5A5A5A5, Register result value: 0X5A50000, Register Read: 0X5A50000
-Match
-
-done~~~
\ No newline at end of file
diff --git a/Examples/adc/adc_verify_wr_rd_reg/src/isr.c b/Examples/adc/adc_verify_wr_rd_reg/src/isr.c
deleted file mode 100644
index af63b27..0000000
--- a/Examples/adc/adc_verify_wr_rd_reg/src/isr.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file isr.c
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/09/16
- * @license
- * @description
- */
-
-
-#include "main.h"
-#include "isr.h"
-
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-/**
- * \brief System Software ISR
- *
- * \return None
- */
-__INTERRUPT void irqc_msip_handler(void)
-{
- sys_clear_swi();
-
- return;
-}
-
diff --git a/Examples/adc/adc_verify_wr_rd_reg/src/main.c b/Examples/adc/adc_verify_wr_rd_reg/src/main.c
deleted file mode 100644
index 3f937a3..0000000
--- a/Examples/adc/adc_verify_wr_rd_reg/src/main.c
+++ /dev/null
@@ -1,209 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file main.c
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/08/29
- * @license
- * @description
- */
-
-
-#include "main.h"
-#include "isr.h"
-#include
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-int main(void)
-{
-
- uint32_t read_value;
- uint32_t write_value;
- uint32_t result_value;
-
- {
- SYSCFG_ClkInitTypeDef SysClkInit = {0};
-
- SysClkInit.ClkSource = SYSCFG_ClkSrc_HSI;
- SYSCFG_SysClkConfig(&SysClkInit);
- }
-
- sys_config_systick(SYS_TICK_1_MS);
-
- syslog_init();
-
- info("%s\nThis is a demo project to adc Read Write register\n", __TIME__);
-
- __HAL_SYSCFG_ADC_CLK_ENABLE();
- __HAL_SYSCFG_RESET_ADC();
- //-------------------ADCON0 ------------------//
-
- volatile uint32_t *registers_CON0[] = {&ADC->CON0 };
- uint32_t CON0_default_value = 0xC0400000;
- uint32_t CON0_write_values[] = {0xFFFFFFFF, 0x00000000, 0x5A5A5A5A, 0xA5A5A5A5};
-
- for (int i = 0; i < 1; i++) // READ CHECK REG
- {
- read_value = REG_READ(*registers_CON0[i]);
- printf("\nCON%d: Register Default: 0X%X, Register Read: 0X%X\n", i, CON0_default_value, read_value);
- if (CON0_default_value == read_value)
- {
- printf("Match\n");
- }
- else
- {
- err("No Match\n");
- }
- }
-
- for (int j = 0; j < 4; j++) // WRITE & CHECK REG
- {
- for (int i = 0; i < 1; i++)
- {
- write_value = CON0_write_values[j];
- result_value = (write_value & 0xCF7F3F2F); //cs 0xCF7F3FAF
- REG_WRITE(*registers_CON0[i], write_value);
- sys_delay(1); //cs
-
- read_value = REG_READ(*registers_CON0[i]);
- printf("\nCON%d: Register Write: 0X%X, Register result value: 0X%X, Register Read: 0X%X\n", i, write_value, result_value, read_value);
- if (result_value == read_value)
- {
- printf("Match\n");
- }
- else
- {
- err("No Match\n");
- }
- }
- }
-
-
- //-------------------ADCSTAT ------------------//
-
- volatile uint32_t *registers_STAT[]= {&ADC->STAT };
- uint32_t STAT_default_value = 0x00030040; //CS 0x0003E440
- uint32_t STAT_write_values[] = {0XFFFFFFFF,0X00000000,0x5A5A5A5A, 0xA5A5A5A5};
-
- __HAL_SYSCFG_RESET_ADC();
-
- for (int i = 0; i < 1; i++) // READ CHECK REG
- {
- read_value =REG_READ(*registers_STAT[i]);
- printf("\nSTAT: Register Default: 0X%X, Register Read: 0X%X\n", STAT_default_value, read_value);
- if (STAT_default_value == read_value)
- {
- printf("Match\n");
- }
- else
- {
- err("No Match\n");
- }
- }
-
- for (int j = 0; j < 4; j++) // WRITE & CHECK REG
- {
-
- for (int i = 0; i < 1; i++)
- {
- write_value = STAT_write_values[j];
-
- if(write_value==0)
- {
- result_value = (write_value & 0x00FF01C0)| 0x00030000;
- }
- else
- {
- result_value = (write_value & 0x00FF01C0); //CS 0x00FF01C0 b'00000000111111110000000111000000'
- }
-
- REG_WRITE(*registers_STAT[i], write_value);
- read_value = REG_READ(*registers_STAT[i]);
- printf("\nSTAT: Register Write: 0X%X, Register result value: 0X%X, Register Read: 0X%X\n", write_value, result_value, read_value);
- if (result_value == read_value)
- {
- printf("Match\n");
- }
- else
- {
- err("No Match\n");
- }
- }
- }
-
- //-------------------ADCDATA ------------------//
-
- volatile uint32_t *registers[]= {&ADC->DAT0, &ADC->DAT1, &ADC->DAT2, &ADC->DAT3, &ADC->DAT4, &ADC->DAT5, \
- &ADC->DAT6, &ADC->DAT7, &ADC->DAT8, &ADC->DAT9, &ADC->DAT10, &ADC->DAT11, \
- &ADC->DAT12, &ADC->DAT13, &ADC->DAT14, &ADC->DAT15
- };
- uint32_t default_values = 0X0;
- uint32_t write_values[] = {0xFFFFFFFF, 0x00000000, 0x5A5A5A5A, 0xA5A5A5A5};
-
- __HAL_SYSCFG_RESET_ADC();
-
- for (int i = 0; i < 16; i++) // READ CHECK REG
- {
- read_value =REG_READ(*registers[i]);
- printf("\nDATA%d: Register Default: 0X%X, Register Read: 0X%X\n", i, default_values, read_value);
- if (default_values == read_value)
- {
- printf("Match\n");
- }
- else
- {
- err("No Match\n");
- }
- }
-
- for (int j = 0; j < 4; j++) // WRITE & CHECK REG
- {
-
- for (int i = 0; i < 16; i++)
- {
- write_value = write_values[j];
- result_value = (write_value & 0x0FFF0000);
- REG_WRITE(*registers[i], write_value);
- read_value = REG_READ(*registers[i]);
- printf("\nDATA%d: Register Write: 0X%X, Register result value: 0X%X, Register Read: 0X%X\n", i, write_value, result_value, read_value);
- if (result_value == read_value)
- {
- printf("Match\n");
- }
- else
- {
- err("No Match\n");
- }
- }
- }
-
- msg("\ndone~~~\n");
-
- while(1)
- {
- __NOP();
- }
-}
diff --git a/Examples/amisc/dac_test/.cproject b/Examples/amisc/dac_test/.cproject
deleted file mode 100644
index 21d0162..0000000
--- a/Examples/amisc/dac_test/.cproject
+++ /dev/null
@@ -1,293 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Examples/amisc/dac_test/Project.nuproject b/Examples/amisc/dac_test/Project.nuproject
deleted file mode 100644
index 0743ed2..0000000
--- a/Examples/amisc/dac_test/Project.nuproject
+++ /dev/null
@@ -1,25 +0,0 @@
-SDK_CONFIG:
- Debug:
- core: N203E
- extra_asmflags:
- archext:
- extra_cxxflags:
- cmodel: medlow
- extra_commonflags:
- abi: ilp32e
- arch: rv32emac
- toolchain: gnu
- extra_cflags:
- extra_ldflags:
- Release:
- core: N203E
- extra_asmflags:
- archext:
- extra_cxxflags:
- cmodel: medlow
- extra_commonflags:
- abi: ilp32e
- arch: rv32emac
- toolchain: gnu
- extra_cflags:
- extra_ldflags:
diff --git a/Examples/amisc/dac_test/inc/isr.h b/Examples/amisc/dac_test/inc/isr.h
deleted file mode 100644
index b77f364..0000000
--- a/Examples/amisc/dac_test/inc/isr.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file isr.h
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/09/16
- * @license
- * @description
- */
-
-#ifndef __isr_H_wuraIpBA_lTJm_HvJw_sNDo_uEd5JnucTReY__
-#define __isr_H_wuraIpBA_lTJm_HvJw_sNDo_uEd5JnucTReY__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "main.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/Examples/amisc/dac_test/src/main.c b/Examples/amisc/dac_test/src/main.c
deleted file mode 100644
index 541fdd6..0000000
--- a/Examples/amisc/dac_test/src/main.c
+++ /dev/null
@@ -1,149 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file main.c
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/08/29
- * @license
- * @description
- */
-
-
-#include "main.h"
-#include "isr.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-#define GPIO_PORTx GPIOA
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-int main(void)
-{
- GPIO_InitTypeDef Init_GPIO = {0};
- AMISC_VBUFConfigTypeDef VBUFConfig = {0};
-
-
- {
- SYSCFG_ClkInitTypeDef SysClkInit = {0};
-
- SysClkInit.ClkSource = SYSCFG_ClkSrc_HSI;
- SYSCFG_SysClkConfig(&SysClkInit);
- }
-
- sys_config_systick(SYS_TICK_10_MS);
-
- syslog_init();
-
- info("%s\nThis is a demo project to dac0_1 \n", __TIME__);
-
- AMISC_Init();
-
- VBUFConfig.Ana2IOT = AMISC_Ana2IO_En; // dac0_1 out=pa8
- VBUFConfig.Ana2PGA = AMISC_Ana2PGA_Disable;
- VBUFConfig.Ana2PGA = AMISC_AnaSel_dac0; //AMISC_AnaSel_dac0 AMISC_AnaSel_dac1
-
- AMISC_VBUF_Config(&VBUFConfig);
- AMISC_Vbuf_Enable();
-
- AMISC_DAC0_Config(0x10); // test_dac0
- AMISC_DAC0_Enable();
-
- //AMISC_DAC1_Config(0x10); // test_dac1
- // AMISC_DAC1_Enable();
-
- //uint32_t sel = (GPIO_ReadOutputData(GPIOA) >> 0) & 0x0F; // pa3:pa2:pa1:pa0
-
- while(1)
- {
- uint32_t sel = (GPIO_ReadOutputData(GPIOA) >> 0) & 0x0F; // pa3:pa2:pa1:pa0
- switch( sel )
- {
-
- default:
- case 0x00:
- AMISC_DAC0_Config(0x00); //0mV for 3.3V
- AMISC_DAC1_Config(0x00);
- break;
-
- case 0x01:
- AMISC_DAC0_Config(0x02); //6.44mV
- AMISC_DAC1_Config(0x02);
- break;
-
- case 0x02:
- AMISC_DAC0_Config(0x04); //12.88mV
- AMISC_DAC1_Config(0x04);
- break;
-
- case 0x03:
- AMISC_DAC0_Config(0x08); //25.76mV
- AMISC_DAC1_Config(0x08);
- break;
-
- case 0x04:
- AMISC_DAC0_Config(0x10); //51.52mV
- AMISC_DAC1_Config(0x10);
- break;
-
- case 0x05:
- AMISC_DAC0_Config(0x20); //103.04mV
- AMISC_DAC1_Config(0x20);
- break;
-
- case 0x06:
- AMISC_DAC0_Config(0x40); //206.8mV
- AMISC_DAC1_Config(0x40);
- break;
-
- case 0x07:
- AMISC_DAC0_Config(0x80); //412.16mV
- AMISC_DAC1_Config(0x80);
- break;
-
- case 0x08:
- AMISC_DAC0_Config(0x100); //824.32mV
- AMISC_DAC1_Config(0x100);
- break;
-
- case 0x09:
- AMISC_DAC0_Config(0x200); //1648.64mV
- AMISC_DAC1_Config(0x200);
- break;
-
- case 0x0A:
- AMISC_DAC0_Config(0x300); //2472.96mV
- AMISC_DAC1_Config(0x300);
- break;
-
- case 0x0B:
- AMISC_DAC0_Config(0x3FF); //3.297.28mV
- AMISC_DAC1_Config(0x3FF);
- break;
-
- }
-
- __asm("nop");
- __asm("nop");
-
- }
-}
diff --git a/Examples/comp/Compare_GpioVsVref/.cproject b/Examples/comp/Compare_GpioVsVref/.cproject
deleted file mode 100644
index 21d0162..0000000
--- a/Examples/comp/Compare_GpioVsVref/.cproject
+++ /dev/null
@@ -1,293 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Examples/comp/Compare_GpioVsVref/Project.nuproject b/Examples/comp/Compare_GpioVsVref/Project.nuproject
deleted file mode 100644
index 0743ed2..0000000
--- a/Examples/comp/Compare_GpioVsVref/Project.nuproject
+++ /dev/null
@@ -1,25 +0,0 @@
-SDK_CONFIG:
- Debug:
- core: N203E
- extra_asmflags:
- archext:
- extra_cxxflags:
- cmodel: medlow
- extra_commonflags:
- abi: ilp32e
- arch: rv32emac
- toolchain: gnu
- extra_cflags:
- extra_ldflags:
- Release:
- core: N203E
- extra_asmflags:
- archext:
- extra_cxxflags:
- cmodel: medlow
- extra_commonflags:
- abi: ilp32e
- arch: rv32emac
- toolchain: gnu
- extra_cflags:
- extra_ldflags:
diff --git a/Examples/comp/Compare_GpioVsVref/inc/isr.h b/Examples/comp/Compare_GpioVsVref/inc/isr.h
deleted file mode 100644
index b77f364..0000000
--- a/Examples/comp/Compare_GpioVsVref/inc/isr.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file isr.h
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/09/16
- * @license
- * @description
- */
-
-#ifndef __isr_H_wuraIpBA_lTJm_HvJw_sNDo_uEd5JnucTReY__
-#define __isr_H_wuraIpBA_lTJm_HvJw_sNDo_uEd5JnucTReY__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "main.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/Examples/comp/Compare_GpioVsVref/readme.md b/Examples/comp/Compare_GpioVsVref/readme.md
deleted file mode 100644
index 74954ad..0000000
--- a/Examples/comp/Compare_GpioVsVref/readme.md
+++ /dev/null
@@ -1,17 +0,0 @@
-compare test
----
-
-This example is used to run compare test function.
-
-## Hardware and Software environment
-
-+ This example runs on PB5700 devices.
-
-## How to use it ?
-
-### In order to make the program work, you must do the following:
-
-+ Open your preferred toolchain
-+ Rebuild all files and load your image into target memory
-+ Run the example
-+ compare0 & 1 Negative(PA6 PA12) & Positive(PA8 PA11) Output results in COUT(PA7 PA13)
\ No newline at end of file
diff --git a/Examples/comp/Compare_GpioVsVref/src/main.c b/Examples/comp/Compare_GpioVsVref/src/main.c
deleted file mode 100644
index 7692127..0000000
--- a/Examples/comp/Compare_GpioVsVref/src/main.c
+++ /dev/null
@@ -1,113 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file main.c
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/08/29
- * @license
- * @description
- */
-
-
-#include "main.h"
-#include "isr.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-#define GPIO_PORTx GPIOA
-
-/**
- * Use COMP0 or COMP1
- */
-#define CONFIG_USE_COMP0
-// #define CONFIG_USE_COMP1
-
-#if defined(CONFIG_USE_COMP0)
- #define COMPx COMP0
-#elif defined(CONFIG_USE_COMP1)
- #define COMPx COMP1
-#endif
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-int main(void)
-{
- GPIO_InitTypeDef Init_GPIO = {0};
- COMP_InitTypeDef Init_Comp = {0};
-
- {
- SYSCFG_ClkInitTypeDef SysClkInit = {0};
-
- SysClkInit.ClkSource = SYSCFG_ClkSrc_HSI;
- SYSCFG_SysClkConfig(&SysClkInit);
- }
-
- sys_config_systick(SYS_TICK_10_MS);
-
- syslog_init();
-
- info("%s\nThis is a demo project to compare gpio vs Vreflnt\n", __TIME__);
-
- Init_Comp.COMP_NegativeSel = COMP_Vin_IO; // vin io comp0=pa6 comp1=pa12
- Init_Comp.COMP_Filter = COMP_Filter_Bypass;
- Init_Comp.COMP_Polarity = COMP_Polarity_Normal;
- Init_Comp.COMP_PositiveSel = COMP_Vip_IO3; // vip comp0_1 pga io0=pa8 io1=pa11 io2=pa14 io3=pa15
- Init_Comp.COMP_Interrupt = 0x0; // disable interrupt;
- Init_Comp.COMP_InitDelay = 0x3C;
- Init_Comp.COMP_Out = COMP_Out_Disable; //Out_Enable COMP0 --->PA7 COMP1 --->PA13
- Init_Comp.COMP_Hsy = COMP_Hsy_Enable;
-
- COMP_Init(COMP0, &Init_Comp);
-
- COMP_Init(COMP1, &Init_Comp);
-
- COMP_Enable(COMP0);
- COMP_Enable(COMP1);
-
- Init_GPIO.GPIO_Pin = GPIO_Pin_03|GPIO_Pin_04;
- Init_GPIO.GPIO_Mode = GPIO_Mode_OUT;
- Init_GPIO.GPIO_PuPd = GPIO_PuPd_NOPULL;
- Init_GPIO.GPIO_OType = GPIO_OType_PP;
- GPIO_Init(GPIO_PORTx , &Init_GPIO);
-
- while(1)
- {
- if( COMP_GetOutputLevel(COMP0) == 0 )
- {
- GPIO_ResetBits(GPIO_PORTx, GPIO_Pin_03);
- }
- else
- {
- GPIO_SetBits(GPIO_PORTx, GPIO_Pin_03);
- }
-
- if( COMP_GetOutputLevel(COMP1) == 0 )
- {
- GPIO_WriteBit(GPIO_PORTx, GPIO_Pin_04, GPIO_PIN_LOW);
- }
- else
- {
- GPIO_WriteBit(GPIO_PORTx, GPIO_Pin_04, GPIO_PIN_HIGH);
- }
-
- }
-}
diff --git a/Examples/comp/Compare_for_TI/.cproject b/Examples/comp/Compare_for_TI/.cproject
deleted file mode 100644
index 21d0162..0000000
--- a/Examples/comp/Compare_for_TI/.cproject
+++ /dev/null
@@ -1,293 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Examples/comp/Compare_for_TI/Project.nuproject b/Examples/comp/Compare_for_TI/Project.nuproject
deleted file mode 100644
index 0743ed2..0000000
--- a/Examples/comp/Compare_for_TI/Project.nuproject
+++ /dev/null
@@ -1,25 +0,0 @@
-SDK_CONFIG:
- Debug:
- core: N203E
- extra_asmflags:
- archext:
- extra_cxxflags:
- cmodel: medlow
- extra_commonflags:
- abi: ilp32e
- arch: rv32emac
- toolchain: gnu
- extra_cflags:
- extra_ldflags:
- Release:
- core: N203E
- extra_asmflags:
- archext:
- extra_cxxflags:
- cmodel: medlow
- extra_commonflags:
- abi: ilp32e
- arch: rv32emac
- toolchain: gnu
- extra_cflags:
- extra_ldflags:
diff --git a/Examples/comp/Compare_for_TI/readme.md b/Examples/comp/Compare_for_TI/readme.md
deleted file mode 100644
index 16e618a..0000000
--- a/Examples/comp/Compare_for_TI/readme.md
+++ /dev/null
@@ -1,17 +0,0 @@
-compare test
----
-
-This example is used to run compare test function.
-
-## Hardware and Software environment
-
-+ This example runs on PB5700 devices.
-
-## How to use it ?
-
-### In order to make the program work, you must do the following:
-
-+ Open your preferred toolchain
-+ Rebuild all files and load your image into target memory
-+ Run the example
-+ compare0 & 1 Output results in COUT
\ No newline at end of file
diff --git a/Examples/comp/Compare_for_TI/src/main.c b/Examples/comp/Compare_for_TI/src/main.c
deleted file mode 100644
index c99d24c..0000000
--- a/Examples/comp/Compare_for_TI/src/main.c
+++ /dev/null
@@ -1,109 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file main.c
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/08/29
- * @license
- * @description
- */
-
-
-#include "main.h"
-#include "isr.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-#define GPIO_PORTx GPIOA
-
-/**
- * Use COMP0 or COMP1
- */
-#define CONFIG_USE_COMP0
-// #define CONFIG_USE_COMP1
-
-#if defined(CONFIG_USE_COMP0)
- #define COMPx COMP0
-#elif defined(CONFIG_USE_COMP1)
- #define COMPx COMP1
-#endif
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-int main(void)
-{
- GPIO_InitTypeDef Init_GPIO = {0};
- COMP_InitTypeDef Init_Comp = {0};
-
- {
- SYSCFG_ClkInitTypeDef SysClkInit = {0};
-
- SysClkInit.ClkSource = SYSCFG_ClkSrc_HSI;
- SYSCFG_SysClkConfig(&SysClkInit);
- }
-
- sys_config_systick(SYS_TICK_10_MS);
-
- syslog_init();
-
- info("%s\nThis is a demo project to compare gpio vs Vreflnt\n", __TIME__);
-
- __HAL_SYSCFG_COMP0_CLK_ENABLE();
-
- REG_WRITE_MASK(COMP0->CTRL, COMP_CTRL_VIN_SEL_Msk , COMP_Vin_IO ); // COMP0 selection Negative(IO) @ref COMP_Vin
-
- COMP_Enable(COMP0);
-
- __HAL_SYSCFG_COMP1_CLK_ENABLE();
-
- REG_WRITE_MASK(COMP1->CTRL, COMP_CTRL_VIN_SEL_Msk , COMP_Vin_IO ); // COMP1 selection Negative(IO) @ref COMP_Vin
-
- COMP_Enable(COMP1);
-
- Init_GPIO.GPIO_Pin = GPIO_Pin_03|GPIO_Pin_04;
- Init_GPIO.GPIO_Mode = GPIO_Mode_OUT;
- Init_GPIO.GPIO_PuPd = GPIO_PuPd_NOPULL;
- Init_GPIO.GPIO_OType = GPIO_OType_PP;
- GPIO_Init(GPIO_PORTx , &Init_GPIO);
-
- while(1)
- {
- if( COMP_GetOutputLevel(COMP0) == 0 )
- {
- GPIO_ResetBits(GPIO_PORTx, GPIO_Pin_03);
- }
- else
- {
- GPIO_SetBits(GPIO_PORTx, GPIO_Pin_03);
- }
-
- if( COMP_GetOutputLevel(COMP1) == 0 )
- {
- GPIO_WriteBit(GPIO_PORTx, GPIO_Pin_04, GPIO_PIN_LOW);
- }
- else
- {
- GPIO_WriteBit(GPIO_PORTx, GPIO_Pin_04, GPIO_PIN_HIGH);
- }
-
- }
-}
diff --git a/Examples/comp/comp_test/.cproject b/Examples/comp/comp_test/.cproject
deleted file mode 100644
index 21d0162..0000000
--- a/Examples/comp/comp_test/.cproject
+++ /dev/null
@@ -1,293 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Examples/comp/comp_test/Project.nuproject b/Examples/comp/comp_test/Project.nuproject
deleted file mode 100644
index 0743ed2..0000000
--- a/Examples/comp/comp_test/Project.nuproject
+++ /dev/null
@@ -1,25 +0,0 @@
-SDK_CONFIG:
- Debug:
- core: N203E
- extra_asmflags:
- archext:
- extra_cxxflags:
- cmodel: medlow
- extra_commonflags:
- abi: ilp32e
- arch: rv32emac
- toolchain: gnu
- extra_cflags:
- extra_ldflags:
- Release:
- core: N203E
- extra_asmflags:
- archext:
- extra_cxxflags:
- cmodel: medlow
- extra_commonflags:
- abi: ilp32e
- arch: rv32emac
- toolchain: gnu
- extra_cflags:
- extra_ldflags:
diff --git a/Examples/comp/comp_test/component.mk b/Examples/comp/comp_test/component.mk
deleted file mode 100644
index b1b2bc6..0000000
--- a/Examples/comp/comp_test/component.mk
+++ /dev/null
@@ -1,16 +0,0 @@
-#
-# component Makefile
-#
-
-
-C_SOURCES += \
- $(srctree)/$(PROJ)/src/isr.c \
- $(srctree)/$(PROJ)/src/main.c
-
-C_INCLUDES += -I$(srctree)/$(PROJ)/inc
-
-
-LIBS +=
-CFLAGS +=
-LDFLAGS +=
-LIBDIR +=
diff --git a/Examples/comp/comp_test/inc/isr.h b/Examples/comp/comp_test/inc/isr.h
deleted file mode 100644
index b77f364..0000000
--- a/Examples/comp/comp_test/inc/isr.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file isr.h
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/09/16
- * @license
- * @description
- */
-
-#ifndef __isr_H_wuraIpBA_lTJm_HvJw_sNDo_uEd5JnucTReY__
-#define __isr_H_wuraIpBA_lTJm_HvJw_sNDo_uEd5JnucTReY__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "main.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/Examples/comp/comp_test/inc/main.h b/Examples/comp/comp_test/inc/main.h
deleted file mode 100644
index 6bc013b..0000000
--- a/Examples/comp/comp_test/inc/main.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file main.h
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/08/29
- * @license
- * @description
- */
-
-#ifndef __main_H_wxBnwdPw_lq7D_H4I5_sHPp_uXof15pFLp4V__
-#define __main_H_wxBnwdPw_lq7D_H4I5_sHPp_uXof15pFLp4V__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-#include "hal_device.h"
-#include "syslog.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/Examples/comp/comp_test/src/main.c b/Examples/comp/comp_test/src/main.c
deleted file mode 100644
index e69a65d..0000000
--- a/Examples/comp/comp_test/src/main.c
+++ /dev/null
@@ -1,125 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file main.c
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/08/29
- * @license
- * @description
- */
-
-
-#include "main.h"
-#include "isr.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-#define GPIO_PORTx GPIOA
-
-/**
- * Use COMP0 or COMP1
- */
-#define CONFIG_USE_COMP0
-// #define CONFIG_USE_COMP1
-
-#if defined(CONFIG_USE_COMP0)
- #define COMPx COMP0
-#elif defined(CONFIG_USE_COMP1)
- #define COMPx COMP1
-#endif
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-int main(void)
-{
- GPIO_InitTypeDef Init_GPIO = {0};
- COMP_InitTypeDef Init_Comp = {0};
-
- {
- SYSCFG_ClkInitTypeDef SysClkInit = {0};
-
- SysClkInit.ClkSource = SYSCFG_ClkSrc_HSI;
- SYSCFG_SysClkConfig(&SysClkInit);
- }
-
- sys_config_systick(SYS_TICK_10_MS);
-
- // syslog_init();
-
- // info("%s\nThis is a demo project to compare gpio vs Vreflnt\n", __TIME__);
-
- Init_Comp.COMP_NegativeSel = COMP_Vin_IO; //vin comp0=pa6 comp1=pa12
- Init_Comp.COMP_Filter = COMP_Filter_Sample_2; //COMP_Filter_Bypass
- Init_Comp.COMP_Polarity = COMP_Polarity_Normal;
- Init_Comp.COMP_PositiveSel = COMP_Vip_IO3; // vip comp0_1 pga io0=pa8 io1=pa11 io2=pa14 io3=pa15
- Init_Comp.COMP_Interrupt = 0x0; // disable interrupt;
- Init_Comp.COMP_InitDelay = 0x3C;
- Init_Comp.COMP_Out = COMP_Out_Enable; //Out_Enable COMP0 --->PA7 COMP1 --->PA13
- Init_Comp.COMP_Hsy = COMP_Hsy_Enable; // COMP_Hsy_Enable
- COMP_Init(COMP0, &Init_Comp);
-
- Init_Comp.COMP_PositiveSel = COMP_Vip_IO2; // vip comp0_1 pga io0=pa8 io1=pa11 io2=pa14 io3=pa15
- COMP_Init(COMP1, &Init_Comp);
-
- COMP_Enable(COMP0);
- COMP_Enable(COMP1);
-
- /* Init_GPIO.GPIO_Pin = GPIO_Pin_03|GPIO_Pin_04;
- Init_GPIO.GPIO_Mode = GPIO_Mode_OUT;
- Init_GPIO.GPIO_PuPd = GPIO_PuPd_NOPULL;
- Init_GPIO.GPIO_OType = GPIO_OType_PP;
- GPIO_Init(GPIO_PORTx , &Init_GPIO); */
-
- COMP_VipTypeDef val=0x00 ;
- while(1)
- {
- uint32_t sel = (GPIO_ReadOutputData(GPIOA) >> 0) & 0x03; // pa1:pa0
- // COMP_VipTypeDef val=0x00 ;
- switch( sel )
- {
-
- default:
- case 0x00:
- val = COMP_Vip_IO0;
- break;
-
- case 0x01:
- val = COMP_Vip_IO1;
- break;
-
- case 0x02:
- val = COMP_Vip_IO2;
- break;
-
- case 0x03:
- val = COMP_Vip_IO3;
- break;
-
- }
-
- REG_WRITE_MASK(COMP0->VIPSEL ,COMP_VIPSEL_VIP_SEL_Msk, val );
- REG_WRITE_MASK(COMP1->VIPSEL ,COMP_VIPSEL_VIP_SEL_Msk, val );
- __asm("nop");
- }
-
- return 0;
-}
diff --git a/Examples/crc/crc_calculate/.cproject b/Examples/crc/crc_calculate/.cproject
index 21d0162..1a0019e 100644
--- a/Examples/crc/crc_calculate/.cproject
+++ b/Examples/crc/crc_calculate/.cproject
@@ -40,27 +40,28 @@
-
+
-
-
+
+
+
@@ -68,14 +69,14 @@
@@ -94,7 +95,7 @@
-
-
+
+
@@ -192,10 +193,10 @@
@@ -204,14 +205,14 @@
@@ -225,7 +226,7 @@
diff --git a/Examples/crc/crc_calculate/Project.nuproject b/Examples/crc/crc_calculate/Project.nuproject
index 0743ed2..0072223 100644
--- a/Examples/crc/crc_calculate/Project.nuproject
+++ b/Examples/crc/crc_calculate/Project.nuproject
@@ -7,7 +7,7 @@ SDK_CONFIG:
cmodel: medlow
extra_commonflags:
abi: ilp32e
- arch: rv32emac
+ arch: rv32ema_zba_zbb_zbs_zca_zcb_zcmp_zcmt_zicond
toolchain: gnu
extra_cflags:
extra_ldflags:
@@ -19,7 +19,7 @@ SDK_CONFIG:
cmodel: medlow
extra_commonflags:
abi: ilp32e
- arch: rv32emac
+ arch: rv32emac_zba_zbb_zbs
toolchain: gnu
extra_cflags:
extra_ldflags:
diff --git a/Examples/I2C/I2C_Slave_STM32/.cproject b/Examples/dac/dac_base/.cproject
similarity index 95%
rename from Examples/I2C/I2C_Slave_STM32/.cproject
rename to Examples/dac/dac_base/.cproject
index d9ac06f..1a0019e 100644
--- a/Examples/I2C/I2C_Slave_STM32/.cproject
+++ b/Examples/dac/dac_base/.cproject
@@ -45,23 +45,23 @@
-
-
-
+
+
+
@@ -69,14 +69,14 @@
@@ -95,7 +95,7 @@
-
-
+
+
@@ -193,10 +193,10 @@
@@ -205,14 +205,14 @@
@@ -226,7 +226,7 @@
diff --git a/Examples/adc/adc_for_TI/.project b/Examples/dac/dac_base/.project
similarity index 100%
rename from Examples/adc/adc_for_TI/.project
rename to Examples/dac/dac_base/.project
diff --git a/Examples/adc/adc_single_conv_interrupt/Project.nuproject b/Examples/dac/dac_base/Project.nuproject
similarity index 89%
rename from Examples/adc/adc_single_conv_interrupt/Project.nuproject
rename to Examples/dac/dac_base/Project.nuproject
index b783ad6..0072223 100644
--- a/Examples/adc/adc_single_conv_interrupt/Project.nuproject
+++ b/Examples/dac/dac_base/Project.nuproject
@@ -7,7 +7,7 @@ SDK_CONFIG:
cmodel: medlow
extra_commonflags:
abi: ilp32e
- arch: rv32emac_zba_zbb_zbs
+ arch: rv32ema_zba_zbb_zbs_zca_zcb_zcmp_zcmt_zicond
toolchain: gnu
extra_cflags:
extra_ldflags:
diff --git a/Examples/adc/adc_for_TI/component.mk b/Examples/dac/dac_base/component.mk
similarity index 100%
rename from Examples/adc/adc_for_TI/component.mk
rename to Examples/dac/dac_base/component.mk
diff --git a/Examples/adc/adc_trigger_src/inc/isr.h b/Examples/dac/dac_base/inc/isr.h
similarity index 100%
rename from Examples/adc/adc_trigger_src/inc/isr.h
rename to Examples/dac/dac_base/inc/isr.h
diff --git a/Examples/adc/adc_for_TI/inc/main.h b/Examples/dac/dac_base/inc/main.h
similarity index 100%
rename from Examples/adc/adc_for_TI/inc/main.h
rename to Examples/dac/dac_base/inc/main.h
diff --git a/Examples/dac/dac_base/readme.md b/Examples/dac/dac_base/readme.md
new file mode 100644
index 0000000..e372c68
--- /dev/null
+++ b/Examples/dac/dac_base/readme.md
@@ -0,0 +1,62 @@
+dac_base
+---
+
+This example is used to demo the usage of DAC
+> It is a `10-bits DAC`
+
+
+## Log
+
+Use serial port with baudrate 115200, 8bit, no parity check.
+
++ DAC0
+ - Measure DAC outupt (PA8)
+ > + `step= 0`, PA8 Output= 1 mV
+ > + `step= 128`, PA8 Output= 407 mV
+ > + `step= 256`, PA8 Output= 815 mV
+ > + `step= 384`, PA8 Output= 1219 mV
+ > + `step= 512`, PA8 Output= 1627 mV
+ > + `step= 640`, PA8 Output= 2017 mV
+ > + `step= 768`, PA8 Output= 2413 mV
+ > + `step= 896`, PA8 Output= 2825 mV
+ > + `step= 1023`, PA8 Output= 3231 mV
+
+ ```
+ Oct 1 2025 16:42:52
+ Run DAC-0 and output to PA8 <--- If VDD = 3300
+ DAC step= 0, Expect Output= 0 mV
+ DAC step= 128, Expect Output= 412 mV
+ DAC step= 256, Expect Output= 825 mV
+ DAC step= 384, Expect Output= 1237 mV
+ DAC step= 512, Expect Output= 1650 mV
+ DAC step= 640, Expect Output= 2062 mV
+ DAC step= 768, Expect Output= 2475 mV
+ DAC step= 896, Expect Output= 2887 mV
+ DAC step= 1023, Expect Output= 3296 mV
+ ```
+
++ DAC1
+ - Measure DAC outupt (PA8)
+ > + `step= 0`, PA8 Output= 1 mV
+ > + `step= 128`, PA8 Output= 408 mV
+ > + `step= 256`, PA8 Output= 815 mV
+ > + `step= 384`, PA8 Output= 1218 mV
+ > + `step= 512`, PA8 Output= 1628 mV
+ > + `step= 640`, PA8 Output= 2018 mV
+ > + `step= 768`, PA8 Output= 2413 mV
+ > + `step= 896`, PA8 Output= 2825 mV
+ > + `step= 1023`, PA8 Output= 3231 mV
+
+ ```
+ Oct 1 2025 16:50:50
+ Run DAC-1 and output to PA8 <--- If VDD = 3300
+ DAC step= 0, Expect Output= 0 mV
+ DAC step= 128, Expect Output= 412 mV
+ DAC step= 256, Expect Output= 825 mV
+ DAC step= 384, Expect Output= 1237 mV
+ DAC step= 512, Expect Output= 1650 mV
+ DAC step= 640, Expect Output= 2062 mV
+ DAC step= 768, Expect Output= 2475 mV
+ DAC step= 896, Expect Output= 2887 mV
+ DAC step= 1023, Expect Output= 3296 mV
+ ```
\ No newline at end of file
diff --git a/Examples/adc/adc_trigger_src/src/isr.c b/Examples/dac/dac_base/src/isr.c
similarity index 100%
rename from Examples/adc/adc_trigger_src/src/isr.c
rename to Examples/dac/dac_base/src/isr.c
diff --git a/Examples/system/sys_exception/src/main.c b/Examples/dac/dac_base/src/main.c
similarity index 61%
rename from Examples/system/sys_exception/src/main.c
rename to Examples/dac/dac_base/src/main.c
index 75c03a7..f1d565d 100644
--- a/Examples/system/sys_exception/src/main.c
+++ b/Examples/dac/dac_base/src/main.c
@@ -16,7 +16,12 @@
//=============================================================================
// Constant Definition
//=============================================================================
+#define CONFIG_USE_DAC0 0
+/**
+ * The reference mVoltage of ADC on board
+ */
+#define CONFIG_ADC_REF_mVOLTAGE 3300 // 5000
//=============================================================================
// Macro Definition
//=============================================================================
@@ -33,20 +38,6 @@
// Private Function Definition
//=============================================================================
-static void _excp_break(uint32_t cause, uint32_t sp)
-{
- msg(" => enter ebreak handler (cause= %d)\n", cause);
- return;
-}
-
-static void _excp_ecall(uint32_t cause, uint32_t sp)
-{
- excp_frame_t *pFrame = (excp_frame_t*)sp;
- pFrame->epc += 4;
-
- msg(" => enter ecall handler (cause= %d)\n", cause);
- return;
-}
//=============================================================================
// Public Function Definition
//=============================================================================
@@ -54,23 +45,45 @@ int main(void)
{
SYSCFG_ClkInitTypeDef SysClkInit = {0};
+ #if 1
SysClkInit.ClkSource = SYSCFG_ClkSrc_HSI;
+ #else
+ SysClkInit.ClkSource = SYSCFG_ClkSrc_FreqDiv;
+ SysClkInit.SysClk_Div = SYSCFG_SysClkDiv2;
+ #endif
+
SYSCFG_SysClkConfig(&SysClkInit);
sys_config_systick(SYS_TICK_1_MS);
syslog_init();
- info("%s %s\nSoftware triggers exception event\n", __DATE__, __TIME__);
+ info("%s %s\nRun DAC-%d and output to PA8\n",
+ __DATE__, __TIME__, (CONFIG_USE_DAC0) ? 0 : 1);
- sys_excp_register_handler(EXCPn_Break, (uint32_t)&_excp_break);
- sys_excp_register_handler(EXCPn_MmodeEcall, (uint32_t)&_excp_ecall);
+ AMISC_Init();
-#if 1
- __ECALL();
-#else
- __EBREAK();
-#endif
+ for(int dac_step = 0; dac_step <= (0x1ul << 10); dac_step += ((0x1ul << 10) >> 3))
+ {
+ dac_step = (dac_step == (0x1ul << 10)) ? (0x1ul << 10) -1 : dac_step;
+
+ #if defined(CONFIG_USE_DAC0) && (CONFIG_USE_DAC0)
+ AMISC_OutInternalSignalToIO(AMISC_InternalSrc_DAC0, true);
+
+ AMISC_DAC0_Config(dac_step);
+ AMISC_DAC0_Enable();
+ #else
+ AMISC_OutInternalSignalToIO(AMISC_InternalSrc_DAC1, true);
+
+ AMISC_DAC1_Config(dac_step);
+ AMISC_DAC1_Enable();
+ #endif
+
+ msg(" DAC step= %d, Expect Output= %d mV\n",
+ dac_step, (dac_step * CONFIG_ADC_REF_mVOLTAGE) >> 10);
+
+ sys_delay(1000);
+ }
while(1)
{
diff --git a/Examples/dsp/dsp_divide/.cproject b/Examples/dsp/dsp_divide/.cproject
index 21d0162..1a0019e 100644
--- a/Examples/dsp/dsp_divide/.cproject
+++ b/Examples/dsp/dsp_divide/.cproject
@@ -40,27 +40,28 @@
-
+
-
-
+
+
+
@@ -68,14 +69,14 @@
@@ -94,7 +95,7 @@
-
-
+
+
@@ -192,10 +193,10 @@
@@ -204,14 +205,14 @@
@@ -225,7 +226,7 @@
diff --git a/Examples/dsp/dsp_divide/Project.nuproject b/Examples/dsp/dsp_divide/Project.nuproject
index 0743ed2..0072223 100644
--- a/Examples/dsp/dsp_divide/Project.nuproject
+++ b/Examples/dsp/dsp_divide/Project.nuproject
@@ -7,7 +7,7 @@ SDK_CONFIG:
cmodel: medlow
extra_commonflags:
abi: ilp32e
- arch: rv32emac
+ arch: rv32ema_zba_zbb_zbs_zca_zcb_zcmp_zcmt_zicond
toolchain: gnu
extra_cflags:
extra_ldflags:
@@ -19,7 +19,7 @@ SDK_CONFIG:
cmodel: medlow
extra_commonflags:
abi: ilp32e
- arch: rv32emac
+ arch: rv32emac_zba_zbb_zbs
toolchain: gnu
extra_cflags:
extra_ldflags:
diff --git a/Examples/dsp/dsp_sqrt/.cproject b/Examples/dsp/dsp_sqrt/.cproject
index 21d0162..1a0019e 100644
--- a/Examples/dsp/dsp_sqrt/.cproject
+++ b/Examples/dsp/dsp_sqrt/.cproject
@@ -40,27 +40,28 @@
-
+
-
-
+
+
+
@@ -68,14 +69,14 @@
@@ -94,7 +95,7 @@
-
-
+
+
@@ -192,10 +193,10 @@
@@ -204,14 +205,14 @@
@@ -225,7 +226,7 @@
diff --git a/Examples/dsp/dsp_sqrt/Project.nuproject b/Examples/dsp/dsp_sqrt/Project.nuproject
index 0743ed2..0072223 100644
--- a/Examples/dsp/dsp_sqrt/Project.nuproject
+++ b/Examples/dsp/dsp_sqrt/Project.nuproject
@@ -7,7 +7,7 @@ SDK_CONFIG:
cmodel: medlow
extra_commonflags:
abi: ilp32e
- arch: rv32emac
+ arch: rv32ema_zba_zbb_zbs_zca_zcb_zcmp_zcmt_zicond
toolchain: gnu
extra_cflags:
extra_ldflags:
@@ -19,7 +19,7 @@ SDK_CONFIG:
cmodel: medlow
extra_commonflags:
abi: ilp32e
- arch: rv32emac
+ arch: rv32emac_zba_zbb_zbs
toolchain: gnu
extra_cflags:
extra_ldflags:
diff --git a/Examples/flash/flash_prog_erase/.cproject b/Examples/flash/flash_prog_erase/.cproject
index 21d0162..1a0019e 100644
--- a/Examples/flash/flash_prog_erase/.cproject
+++ b/Examples/flash/flash_prog_erase/.cproject
@@ -40,27 +40,28 @@
-
+
-
-
+
+
+
@@ -68,14 +69,14 @@
@@ -94,7 +95,7 @@
-
-
+
+
@@ -192,10 +193,10 @@
@@ -204,14 +205,14 @@
@@ -225,7 +226,7 @@
diff --git a/Examples/flash/flash_prog_erase/Project.nuproject b/Examples/flash/flash_prog_erase/Project.nuproject
index 0743ed2..0072223 100644
--- a/Examples/flash/flash_prog_erase/Project.nuproject
+++ b/Examples/flash/flash_prog_erase/Project.nuproject
@@ -7,7 +7,7 @@ SDK_CONFIG:
cmodel: medlow
extra_commonflags:
abi: ilp32e
- arch: rv32emac
+ arch: rv32ema_zba_zbb_zbs_zca_zcb_zcmp_zcmt_zicond
toolchain: gnu
extra_cflags:
extra_ldflags:
@@ -19,7 +19,7 @@ SDK_CONFIG:
cmodel: medlow
extra_commonflags:
abi: ilp32e
- arch: rv32emac
+ arch: rv32emac_zba_zbb_zbs
toolchain: gnu
extra_cflags:
extra_ldflags:
diff --git a/Examples/flash/flash_prog_erase/inc/main.h b/Examples/flash/flash_prog_erase/inc/main.h
index 4905c06..21ced44 100644
--- a/Examples/flash/flash_prog_erase/inc/main.h
+++ b/Examples/flash/flash_prog_erase/inc/main.h
@@ -27,7 +27,7 @@ extern "C" {
* + 10KB: 0x2800
*/
#define FLASH_PROG_ADDR_START (13ul << 10)
-#define FLASH_PROG_ADDR_END (32ul << 10)
+#define FLASH_PROG_ADDR_END sizeof(EFLASH_MEM_Type)
//=============================================================================
// Macro Definition
//=============================================================================
diff --git a/Examples/flash/flash_prog_erase/readme.md b/Examples/flash/flash_prog_erase/readme.md
index a1e5753..85e3fe9 100644
--- a/Examples/flash/flash_prog_erase/readme.md
+++ b/Examples/flash/flash_prog_erase/readme.md
@@ -1,7 +1,7 @@
flash_prog_erase
---
-This example is a demo project to P/E (Program/Erase) eFlash.
+This example is a demo project to P/E (Program/Erase) main-area of eFlash.
> The execute-bin will occupy front area of eFlash,
as the result P/E the other area of eFlash
@@ -10,28 +10,44 @@ There are 3-case in this example
> + half-word data
> + byte data
-The execute-flow in every case:
+The execute-flow of every case:
-+ Erase eFalsh and verify data is `0xFF` or not
-+ Program **word/hword/byte data** to eFlash and verify the result value of eFlash
++ Erase eFalsh (secotr by sector) and verify word-data is `0xFFFFFFFF` or not
+ > If the word-data is NOT `0xFFFFFFFF`, it will stop procedure and log error message
+
++ Program **word/hword/byte-data** to eFlash and verify the result value of eFlash
+ > If the data is NOT match, it will stop procedure and log error message
It also supports fix/random pattern
-> User should modify `CONFIG_USE_RAND_DATA` as below
-> ```
-> // at main.c
-> /**
-> * Use random data as pattern
-> */
-> #define CONFIG_USE_RAND_DATA 1
-> ```
+
++ Fix pattern is `0x5A5A5A5Aul`
++ Random pattern
+ > User should modify `CONFIG_USE_RAND_DATA` as below
+ > ```
+ > // at main.c
+ > /**
+ > * Use random data as pattern
+ > */
+ > #define CONFIG_USE_RAND_DATA 1
+ > ```
+
+If user wants to get more detail message, unmark `CONFIG_MORE_MESSAGE` definition
+
+```c
+// at main.c
+/**
+ * Get more log message
+ */
+#define CONFIG_MORE_MESSAGE
+```
## Log
Use serial port with baudrate 115200, 8bit, no parity check.
```
-This is a 13:28:12
-This is eFlash Erase/Program/Read (0x00002800 ~ 0x00008000) example
+Oct 13 2025 14:12:47
+This is eFlash Erase/Program/Read (0x00003400 ~ 0x00008000) example
## P/E with word value
done~
## P/E with half-word value
diff --git a/Examples/flash/flash_prog_erase/src/main.c b/Examples/flash/flash_prog_erase/src/main.c
index 4379189..b5c5dca 100644
--- a/Examples/flash/flash_prog_erase/src/main.c
+++ b/Examples/flash/flash_prog_erase/src/main.c
@@ -20,7 +20,7 @@
/**
* Get more log message
*/
-//#define CONFIG_MORE_MESSAGE
+// #define CONFIG_MORE_MESSAGE
/**
* Use random data as pattern
@@ -36,7 +36,10 @@
//=============================================================================
// Macro Definition
//=============================================================================
-
+#if !defined(CONFIG_MORE_MESSAGE)
+#undef dbg
+#define dbg(str, ...)
+#endif
//=============================================================================
// Structure Definition
//=============================================================================
@@ -48,32 +51,6 @@ static uint32_t g_buf[512 >> 2] = {0};
//=============================================================================
// Private Function Definition
//=============================================================================
-static uint32_t __rand(void)
-{
- static uint32_t z1 = 0, z2 = 0, z3 = 0, z4 = 0 ;
-
- if( z1 == 0 && z2 == 0 )
- {
- char *str = __TIME__;
- uint16_t *pCur = (uint16_t*)str;
- z1 = pCur[0];
- z2 = pCur[1];
- z3 = pCur[2];
- z4 = pCur[3];
- }
-
- uint32_t b;
- b = ((z1 << 6) ^ z1) >> 13;
- z1 = ((z1 & 0xFFFFFFFEU) << 18) ^ b;
- b = ((z2 << 2) ^ z2) >> 27;
- z2 = ((z2 & 0xFFFFFFF8U) << 2) ^ b;
- b = ((z3 << 13) ^ z3) >> 21;
- z3 = ((z3 & 0xFFFFFFF0U) << 7) ^ b;
- b = ((z4 << 3) ^ z4) >> 12;
- z4 = ((z4 & 0xFFFFFF80U) << 13) ^ b;
- return (z1 ^ z2 ^ z3 ^ z4);
-}
-
static int
_Run_Flash_Erase(void)
{
@@ -101,9 +78,7 @@ _Run_Flash_Erase(void)
/* break; */
}
- #if defined(CONFIG_MORE_MESSAGE)
- msg("addr(x%08X)= x%08X, pattern= x%08X\n", &pCur[i], pCur[i], 0xFFFFFFFF);
- #endif
+ dbg("addr(x%08X)= x%08X, pattern= x%08X\n", &pCur[i], pCur[i], 0xFFFFFFFF);
}
}
@@ -139,9 +114,7 @@ _Run_Flash_ProgWord(uint32_t pattern)
/* Verify value after program */
for(int i = 0; i < FLASH_1_PAGE_SIZE; i += sizeof(uint32_t))
{
- #if defined(CONFIG_MORE_MESSAGE)
- msg("addr(x%08X)= x%08X, pattern= x%08X\n", addr + i, *(uint32_t*)(addr + i), pattern);
- #endif
+ dbg("addr(x%08X)= x%08X, pattern= x%08X\n", addr + i, *(uint32_t*)(addr + i), pattern);
if( *(uint32_t*)(addr + i) != pattern )
{
@@ -188,9 +161,7 @@ _Run_Flash_ProgHWord(uint16_t pattern)
/* Verify value after program */
for(int i = 0; i < FLASH_1_PAGE_SIZE; i += sizeof(uint16_t))
{
- #if defined(CONFIG_MORE_MESSAGE)
- msg("addr(x%08X)= x%08X, pattern= x%08X\n", addr + i, *(uint16_t*)(addr + i), pattern);
- #endif
+ dbg("addr(x%08X)= x%08X, pattern= x%08X\n", addr + i, *(uint16_t*)(addr + i), pattern);
if( *(uint16_t*)(addr + i) != pattern )
{
@@ -236,9 +207,7 @@ _Run_Flash_ProgByte(uint8_t pattern)
/* Verify value after program */
for(int i = 0; i < FLASH_1_PAGE_SIZE; i += sizeof(uint8_t))
{
- #if defined(CONFIG_MORE_MESSAGE)
- msg("addr(x%08X)= x%08X, pattern= x%08X\n", addr + i, *(uint8_t*)(addr + i), pattern);
- #endif
+ dbg("addr(x%08X)= x%08X, pattern= x%08X\n", addr + i, *(uint8_t*)(addr + i), pattern);
if( *(uint8_t*)(addr + i) != pattern )
{
@@ -292,9 +261,7 @@ _Run_Flash_ProgData(uint32_t pattern)
/* Verify value after program */
for(int i = 0; i < FLASH_1_PAGE_SIZE; i += sizeof(g_buf))
{
- #if defined(CONFIG_MORE_MESSAGE)
- msg("addr(x%08X)= x%08X, pattern= x%08X\n", addr + i, *(uint32_t*)(addr + i), patt_act);
- #endif
+ dbg("addr(x%08X)= x%08X, pattern= x%08X\n", addr + i, *(uint32_t*)(addr + i), patt_act);
if( memcmp((void*)(addr + i), (void*)&g_buf, sizeof(g_buf)) )
{
@@ -324,8 +291,8 @@ int main(void)
syslog_init();
- info("%s\nThis is eFlash Erase/Program/Read (0x%08x ~ 0x%08x) example\n",
- __TIME__, FLASH_PROG_ADDR_START, FLASH_PROG_ADDR_END);
+ info("%s %s\nThis is eFlash Erase/Program/Read (0x%08x ~ 0x%08x) example\n",
+ __DATE__, __TIME__, FLASH_PROG_ADDR_START, FLASH_PROG_ADDR_END);
do {
uint32_t patt_value = 0;
@@ -336,7 +303,7 @@ int main(void)
if( rval ) break;
patt_value = (CONFIG_USE_RAND_DATA)
- ? (__rand() << 16 | __rand())
+ ? (HAL_Rand() << 16 | HAL_Rand())
: CONFIG_PATTERN_WORD_1;
rval = _Run_Flash_ProgWord(patt_value);
@@ -350,7 +317,7 @@ int main(void)
if( rval ) break;
patt_value = (CONFIG_USE_RAND_DATA)
- ? (__rand() & 0xFFFFul)
+ ? (HAL_Rand() & 0xFFFFul)
: CONFIG_PATTERN_HWORD_1;
rval = _Run_Flash_ProgHWord(patt_value);
@@ -364,7 +331,7 @@ int main(void)
if( rval ) break;
patt_value = (CONFIG_USE_RAND_DATA)
- ? ((__rand() & 0xFF00ul) >> 8)
+ ? ((HAL_Rand() & 0xFF00ul) >> 8)
: CONFIG_PATTERN_BYTE_1;
rval = _Run_Flash_ProgByte(patt_value);
@@ -378,7 +345,7 @@ int main(void)
if( rval ) break;
patt_value = (CONFIG_USE_RAND_DATA)
- ? (__rand() << 16 | __rand())
+ ? (HAL_Rand() << 16 | HAL_Rand())
: CONFIG_PATTERN_WORD_1;
rval = _Run_Flash_ProgData(patt_value);
diff --git a/Examples/flash/flash_prog_erase_nvr/component.mk b/Examples/flash/flash_prog_erase_nvr/component.mk
deleted file mode 100644
index b1b2bc6..0000000
--- a/Examples/flash/flash_prog_erase_nvr/component.mk
+++ /dev/null
@@ -1,16 +0,0 @@
-#
-# component Makefile
-#
-
-
-C_SOURCES += \
- $(srctree)/$(PROJ)/src/isr.c \
- $(srctree)/$(PROJ)/src/main.c
-
-C_INCLUDES += -I$(srctree)/$(PROJ)/inc
-
-
-LIBS +=
-CFLAGS +=
-LDFLAGS +=
-LIBDIR +=
diff --git a/Examples/flash/flash_prog_erase_nvr/inc/main.h b/Examples/flash/flash_prog_erase_nvr/inc/main.h
deleted file mode 100644
index 7b07a4c..0000000
--- a/Examples/flash/flash_prog_erase_nvr/inc/main.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file main.h
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/08/29
- * @license
- * @description
- */
-
-#ifndef __main_H_wxBnwdPw_lq7D_H4I5_sHPp_uXof15pFLp4V__
-#define __main_H_wxBnwdPw_lq7D_H4I5_sHPp_uXof15pFLp4V__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-#include "hal_device.h"
-#include "syslog.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-/**
- * + NVR area
- */
-#define FLASH_PROG_NVR_ADDR_START NVR_MEM_BASE
-
-// ignore the last sector (record flash paraments) of NVR
-#define FLASH_PROG_NVR_ADDR_END (NVR_MEM_BASE + sizeof(NVR_MEM_Type) - FLASH_1_SECTOR_SIZE)
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/Examples/flash/flash_prog_erase_nvr/readme.md b/Examples/flash/flash_prog_erase_nvr/readme.md
deleted file mode 100644
index a94016e..0000000
--- a/Examples/flash/flash_prog_erase_nvr/readme.md
+++ /dev/null
@@ -1,126 +0,0 @@
-flash_prog_erase_nvr
----
-
-This example is a demo project to P/E (Program/Erase) NVR area of DUT (execute at main-flash)
-> This example is only for `internal` verification.
- We do NOT expect user to modify data of NVR
-
-
-+ There are 8-KBytes (sector 0 ~ 15) in NVR area
- > A sector size is 512 bytes
-
- - The 15-th sector is recorded the paraments of embedded flash
- - The 14-th sector is recorded the trim-values
-
-+ It supports 3 type (read 8/16/32 bits) to verify data
-
- ```c
- // at main.c
- #define CONFIG_USE_READ_WORD
- /* #define CONFIG_USE_READ_HWORD */
- /* #define CONFIG_USE_READ_BYTE */
- ```
-
-## Log
-
-Use serial port with baudrate 115200, 8bit, no parity check.
-
-```
-14:12:31
-This is NVR Erase/Program/Read (0x00200000 ~ 0x00201e00) example
-## P/E with word value, read 32-bits to verify
-sector-addr: x00200000
- erase this sector
- verify data
- prog data to this sector
- verify data
- done~
-sector-addr: x00200200
- erase this sector
- verify data
- prog data to this sector
- verify data
- done~
-sector-addr: x00200400
- erase this sector
- verify data
- prog data to this sector
- verify data
- done~
-sector-addr: x00200600
- erase this sector
- verify data
- prog data to this sector
- verify data
- done~
-sector-addr: x00200800
- erase this sector
- verify data
- prog data to this sector
- verify data
- done~
-sector-addr: x00200A00
- erase this sector
- verify data
- prog data to this sector
- verify data
- done~
-sector-addr: x00200C00
- erase this sector
- verify data
- prog data to this sector
- verify data
- done~
-sector-addr: x00200E00
- erase this sector
- verify data
- prog data to this sector
- verify data
- done~
-sector-addr: x00201000
- erase this sector
- verify data
- prog data to this sector
- verify data
- done~
-sector-addr: x00201200
- erase this sector
- verify data
- prog data to this sector
- verify data
- done~
-sector-addr: x00201400
- erase this sector
- verify data
- prog data to this sector
- verify data
- done~
-sector-addr: x00201600
- erase this sector
- verify data
- prog data to this sector
- verify data
- done~
-sector-addr: x00201800
- erase this sector
- verify data
- prog data to this sector
- verify data
- done~
-sector-addr: x00201A00
- erase this sector
- verify data
- prog data to this sector
- verify data
- done~
-sector-addr: x00201C00
- erase this sector
- verify data
- prog data to this sector
- verify data
- done~
-Fully verify data
- done~
-done ~~~~~~
-
-```
diff --git a/Examples/flash/flash_prog_erase_nvr/src/main.c b/Examples/flash/flash_prog_erase_nvr/src/main.c
deleted file mode 100644
index 0df6cc9..0000000
--- a/Examples/flash/flash_prog_erase_nvr/src/main.c
+++ /dev/null
@@ -1,310 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file main.c
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/08/29
- * @license
- * @description
- */
-
-#include
-#include
-#include "main.h"
-#include "isr.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-#define CONFIG_USE_READ_WORD
-/* #define CONFIG_USE_READ_HWORD */
-/* #define CONFIG_USE_READ_BYTE */
-
-#define CONFIG_NVR_SECTOR_NUM ((FLASH_PROG_NVR_ADDR_END - FLASH_PROG_NVR_ADDR_START) >> 9)
-
-#define CONFIG_PATTERN_WORD_1 0x5A5A5A5Aul
-#define CONFIG_PATTERN_WORD_2 0xA5A5A5A5ul
-
-#define __SYSINFO_UNLOCK() REG_WRITE(*(volatile uint32_t*)0x4000F82C, 0x5A5A005A)
-#define __SYSINFO_LOCK() REG_WRITE(*(volatile uint32_t*)0x4000F82C, 0x5A5A0000)
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-flash_state_t
-_FLASH_EraseNVRSector(uint32_t nvr_addr)
-{
- flash_state_t rval = FLASH_STATE_OK;
-
- if( nvr_addr < (uint32_t)&NVR_MEM->DATA0 ||
- nvr_addr > (uint32_t)&NVR_MEM->DATA_END )
- {
- return FLASH_STATE_FAIL_ADDR;
- }
-
- REG_WRITE(FLASH->SR, 0xFFFFFFFFul); // clean status flags
-
- REG_WRITE(FLASH->DIV, SYS_HIRC_MHZ);
-
- FLASH->AR = nvr_addr & ~(FLASH_1_SECTOR_SIZE - 1);
-
- if( nvr_addr >= 0x00201C00 && nvr_addr <= 0x00201E00 )
- {
- __SYSINFO_UNLOCK();
- }
-
- REG_WRITE_MASK(FLASH->CMD,
- (FLASH_CMD_KEY_Msk | FLASH_CMD_START_Msk |
- FLASH_CMD_UNLOCK_Msk |
- FLASH_CMD_CMD_Msk),
- (0xA5EC0000ul | FLASH_CMD_START_Msk | \
- (0x1ul << FLASH_CMD_UNLOCK_Pos) | \
- (FLASH_CMD_CMD_ERASE_SECTOR << FLASH_CMD_CMD_Pos)));
-
- /* lock P/E operations */
- REG_WRITE_MASK(FLASH->CMD,
- (FLASH_CMD_KEY_Msk | FLASH_CMD_UNLOCK_Msk),
- FLASH_AUTH_KEY);
-
- __SYSINFO_LOCK();
- return rval;
-}
-
-flash_state_t
-_FLASH_ProgNVRWord(uint32_t addr, uint32_t value)
-{
- flash_state_t rval = FLASH_STATE_OK;
-
- if( addr < (uint32_t)&NVR_MEM->DATA0 ||
- addr > (uint32_t)&NVR_MEM->DATA_END ||
- (addr & 0x3ul) )
- {
- return FLASH_STATE_FAIL_ADDR;
- }
-
- REG_WRITE(FLASH->SR, 0xFFFFFFFFul); // clean status flags
-
- REG_WRITE(FLASH->DIV, SYS_HIRC_MHZ);
-
- FLASH->AR = addr;
- FLASH->DR = value;
-
- if( addr >= 0x00201C00 && addr <= 0x00201E00 )
- {
- __SYSINFO_UNLOCK();
- }
-
- REG_WRITE_MASK(FLASH->CMD,
- (FLASH_CMD_KEY_Msk |
- FLASH_CMD_UNLOCK_Msk |
- FLASH_CMD_CMD_Msk | FLASH_CMD_START_Msk),
- (0xA5EC0000ul | \
- (0x1ul << FLASH_CMD_UNLOCK_Pos) | \
- (FLASH_CMD_CMD_PROG << FLASH_CMD_CMD_Pos) | FLASH_CMD_START_Msk));
-
- /* lock P/E operations */
- REG_WRITE_MASK(FLASH->CMD,
- (FLASH_CMD_KEY_Msk | FLASH_CMD_UNLOCK_Msk),
- FLASH_AUTH_KEY);
-
- __SYSINFO_LOCK();
- return rval;
-}
-
-flash_state_t
-_FLASH_ProgNVRData(uint32_t addr, uint32_t *pData, int length)
-{
- flash_state_t rval = FLASH_STATE_OK;
-
- if( addr < (uint32_t)&NVR_MEM->DATA0 ||
- addr > (uint32_t)&NVR_MEM->DATA_END ||
- addr & 0x3 || length & 0x3 )
- {
- return FLASH_STATE_FAIL_ADDR;
- }
-
- REG_WRITE(FLASH->SR, 0xFFFFFFFFul); // clean status flags
-
- REG_WRITE(FLASH->DIV, SYS_HIRC_MHZ);
-
- FLASH->AR = addr;
-
- do {
- FLASH->AR = addr;
- FLASH->DR = *pData++;
-
- if( addr >= 0x00201C00 && addr <= 0x00201E00 )
- {
- __SYSINFO_UNLOCK();
- }
-
- REG_WRITE_MASK(FLASH->CMD,
- (FLASH_CMD_KEY_Msk |
- FLASH_CMD_UNLOCK_Msk |
- FLASH_CMD_CMD_Msk | FLASH_CMD_START_Msk),
- (0xA5EC0000ul | \
- (0x1ul << FLASH_CMD_UNLOCK_Pos) | \
- (FLASH_CMD_CMD_PROG << FLASH_CMD_CMD_Pos) | FLASH_CMD_START_Msk));
-
- length -= 4;
- addr += 4;
- } while( length > 0 );
-
- /* lock P/E operations */
- REG_WRITE_MASK(FLASH->CMD,
- (FLASH_CMD_KEY_Msk | FLASH_CMD_UNLOCK_Msk),
- FLASH_AUTH_KEY);
-
- __SYSINFO_LOCK();
- return rval;
-}
-
-static int
-_Flash_VerifyData(uint32_t addr_start, uint32_t addr_end, uint32_t patt_value)
-{
- int rval = 0;
- union {
- uint32_t *pWCur;
- uint16_t *pHWCur;
- uint8_t *pBCur;
- } u;
-
- /* uint32_t *pCur = (uint32_t*)addr_start; */
-
- u.pWCur = (uint32_t*)addr_start;
-
- while( (uint32_t)u.pWCur < addr_end )
- {
- #if defined(CONFIG_USE_READ_WORD)
- if( *u.pWCur++ == patt_value )
- continue;
- #elif defined(CONFIG_USE_READ_HWORD)
- if( *u.pHWCur++ == (patt_value & 0xFFFFul) &&
- *u.pHWCur++ == ((patt_value >> 16) & 0xFFFFul) )
- continue;
- #else
- if( *u.pBCur++ == (patt_value & 0xFFul) &&
- *u.pBCur++ == ((patt_value >> 8) & 0xFFul) &&
- *u.pBCur++ == ((patt_value >> 16) & 0xFFul) &&
- *u.pBCur++ == ((patt_value >> 24) & 0xFFul) )
- continue;
- #endif
-
- err("x%08X: x%08X != x%08X\n",
- (uint32_t)(u.pWCur - 1),
- *(u.pWCur - 1), patt_value);
-
- rval = -1;
- }
- return rval;
-}
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-int main(void)
-{
- int rval = 0;
- SYSCFG_ClkInitTypeDef SysClkInit = {0};
-
- SysClkInit.ClkSource = SYSCFG_ClkSrc_HSI;
- SYSCFG_SysClkConfig(&SysClkInit);
-
- sys_config_systick(SYS_TICK_1_MS);
-
- syslog_init();
-
- info("%s\nThis is NVR Erase/Program/Read (0x%08x ~ 0x%08x) example\n",
- __TIME__, FLASH_PROG_NVR_ADDR_START, FLASH_PROG_NVR_ADDR_END);
-
-
- do {
- uint32_t patt_value = CONFIG_PATTERN_WORD_1;
-
- log_color(SLOG_GREEN, "## P/E with word value, read %s to verify\n",
- #if defined(CONFIG_USE_READ_WORD)
- "32-bits"
- #elif defined(CONFIG_USE_READ_HWORD)
- "16-bits"
- #else
- "8-bits"
- #endif
- );
-
-
- for(uint32_t addr_sector = FLASH_PROG_NVR_ADDR_START;
- addr_sector < FLASH_PROG_NVR_ADDR_END;
- addr_sector += FLASH_1_SECTOR_SIZE)
- {
- msg("sector-addr: x%08X\n", addr_sector);
-
- msg(" erase this sector\n");
- /* Erase a sector */
- rval = (int)_FLASH_EraseNVRSector(addr_sector);
- if( rval ) break;
-
- msg(" verify data\n");
- /* Verify data in the sector */
- rval = _Flash_VerifyData(addr_sector, addr_sector + FLASH_1_SECTOR_SIZE, 0xFFFFFFFFul);
- if( rval )
- {
- rval = -__LINE__;
- break;
- }
-
- /* Program data to this sector */
- msg(" prog data to this sector\n");
- for(uint32_t addr_word = addr_sector;
- addr_word < addr_sector + FLASH_1_SECTOR_SIZE;
- addr_word += 4)
- {
- rval = (int)_FLASH_ProgNVRWord(addr_word, patt_value);
- if( rval ) break;
- }
-
- msg(" verify data\n");
- /* Verify data in the sector */
- rval = _Flash_VerifyData(addr_sector, addr_sector + FLASH_1_SECTOR_SIZE, patt_value);
- if( rval )
- {
- rval = -__LINE__;
- break;
- }
-
- msg(" done~\n");
- }
-
- if( rval ) break;
-
- msg("Fully verify data\n");
- /* Verify data in the sector */
- rval = _Flash_VerifyData(FLASH_PROG_NVR_ADDR_START, FLASH_PROG_NVR_ADDR_END, patt_value);
- if( rval )
- {
- rval = -__LINE__;
- break;
- }
-
- msg(" done~\n");
- } while(0);
-
- if(rval) err("!!! fail %d\n", rval);
- else msg("done ~~~~~~\n");
-
- while(1)
- {
- __NOP();
- }
- return 0;
-}
diff --git a/Examples/flash/flash_set_latency/.cproject b/Examples/flash/flash_set_latency/.cproject
deleted file mode 100644
index 21d0162..0000000
--- a/Examples/flash/flash_set_latency/.cproject
+++ /dev/null
@@ -1,293 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Examples/flash/flash_set_latency/.project b/Examples/flash/flash_set_latency/.project
deleted file mode 100644
index 2183c12..0000000
--- a/Examples/flash/flash_set_latency/.project
+++ /dev/null
@@ -1,54 +0,0 @@
-
-
- Project
-
-
-
-
-
- org.eclipse.cdt.managedbuilder.core.genmakebuilder
- clean,full,incremental,
-
-
-
-
- org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
- full,incremental,
-
-
-
-
-
- org.eclipse.cdt.core.cnature
- org.eclipse.cdt.managedbuilder.core.managedBuildNature
- org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
-
-
-
- Common
- 2
- PARENT-3-PROJECT_LOC/Common
-
-
- Drivers
- 2
- PARENT-3-PROJECT_LOC/Drivers
-
-
- Profiles
- 2
- PARENT-3-PROJECT_LOC/Tools/scripts/Profiles
-
-
-
-
- 0
-
- 6
-
- org.eclipse.ui.ide.multiFilter
- 1.0-name-matches-false-false-*.nuproject
-
-
-
-
diff --git a/Examples/flash/flash_set_latency/Project.nuproject b/Examples/flash/flash_set_latency/Project.nuproject
deleted file mode 100644
index 0743ed2..0000000
--- a/Examples/flash/flash_set_latency/Project.nuproject
+++ /dev/null
@@ -1,25 +0,0 @@
-SDK_CONFIG:
- Debug:
- core: N203E
- extra_asmflags:
- archext:
- extra_cxxflags:
- cmodel: medlow
- extra_commonflags:
- abi: ilp32e
- arch: rv32emac
- toolchain: gnu
- extra_cflags:
- extra_ldflags:
- Release:
- core: N203E
- extra_asmflags:
- archext:
- extra_cxxflags:
- cmodel: medlow
- extra_commonflags:
- abi: ilp32e
- arch: rv32emac
- toolchain: gnu
- extra_cflags:
- extra_ldflags:
diff --git a/Examples/flash/flash_set_latency/component.mk b/Examples/flash/flash_set_latency/component.mk
deleted file mode 100644
index b1b2bc6..0000000
--- a/Examples/flash/flash_set_latency/component.mk
+++ /dev/null
@@ -1,16 +0,0 @@
-#
-# component Makefile
-#
-
-
-C_SOURCES += \
- $(srctree)/$(PROJ)/src/isr.c \
- $(srctree)/$(PROJ)/src/main.c
-
-C_INCLUDES += -I$(srctree)/$(PROJ)/inc
-
-
-LIBS +=
-CFLAGS +=
-LDFLAGS +=
-LIBDIR +=
diff --git a/Examples/flash/flash_set_latency/inc/main.h b/Examples/flash/flash_set_latency/inc/main.h
deleted file mode 100644
index 6bc013b..0000000
--- a/Examples/flash/flash_set_latency/inc/main.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file main.h
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/08/29
- * @license
- * @description
- */
-
-#ifndef __main_H_wxBnwdPw_lq7D_H4I5_sHPp_uXof15pFLp4V__
-#define __main_H_wxBnwdPw_lq7D_H4I5_sHPp_uXof15pFLp4V__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-#include "hal_device.h"
-#include "syslog.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/Examples/flash/flash_set_latency/readme.md b/Examples/flash/flash_set_latency/readme.md
deleted file mode 100644
index 08f1e7a..0000000
--- a/Examples/flash/flash_set_latency/readme.md
+++ /dev/null
@@ -1,36 +0,0 @@
-flash_set_latency
----
-
-This example is a demo project to rendom switch latency of eFlash
-> It will set new latency value to FMC and read back the latency value of FMC
-
-## Log
-
-Use serial port with baudrate 115200, 8bit, no parity check.
-
-```
-15:18:36
-This is example of switching flash latency
-
- Set latency= 2
- Get latency= 2
-
- Set latency= 3
- Get latency= 3
-
- Set latency= 1
- Get latency= 1
-
- Set latency= 3
- Get latency= 3
-
- Set latency= 3
- Get latency= 3
-
- Set latency= 1
- Get latency= 1
-
- Set latency= 2
- Get latency= 2
- ...
-```
diff --git a/Examples/flash/flash_set_latency/src/main.c b/Examples/flash/flash_set_latency/src/main.c
deleted file mode 100644
index a36023c..0000000
--- a/Examples/flash/flash_set_latency/src/main.c
+++ /dev/null
@@ -1,111 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file main.c
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/08/29
- * @license
- * @description
- */
-
-#include
-#include
-#include "main.h"
-#include "isr.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-static uint32_t __rand(void)
-{
- static uint32_t z1 = 0, z2 = 0, z3 = 0, z4 = 0 ;
-
- if( z1 == 0 && z2 == 0 )
- {
- char *str = __TIME__;
- uint16_t *pCur = (uint16_t*)str;
- z1 = pCur[0];
- z2 = pCur[1];
- z3 = pCur[2];
- z4 = pCur[3];
- }
-
- uint32_t b;
- b = ((z1 << 6) ^ z1) >> 13;
- z1 = ((z1 & 0xFFFFFFFEU) << 18) ^ b;
- b = ((z2 << 2) ^ z2) >> 27;
- z2 = ((z2 & 0xFFFFFFF8U) << 2) ^ b;
- b = ((z3 << 13) ^ z3) >> 21;
- z3 = ((z3 & 0xFFFFFFF0U) << 7) ^ b;
- b = ((z4 << 3) ^ z4) >> 12;
- z4 = ((z4 & 0xFFFFFF80U) << 13) ^ b;
- return (z1 ^ z2 ^ z3 ^ z4);
-}
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-int main(void)
-{
- int rval = 0;
- SYSCFG_ClkInitTypeDef SysClkInit = {0};
-
- SysClkInit.ClkSource = SYSCFG_ClkSrc_HSI;
- SYSCFG_SysClkConfig(&SysClkInit);
-
- sys_config_systick(SYS_TICK_1_MS);
-
- syslog_init();
-
- info("%s\nThis is example of switching flash latency\n",
- __TIME__);
-
- while(1)
- {
- flash_latency_t wait_cycles = FLASH_LATENCY_1;
-
- rval = __rand() & 0x3ul;
-
- wait_cycles = (rval == 0) ? FLASH_LATENCY_3 :
- (rval == 1) ? FLASH_LATENCY_2 :
- FLASH_LATENCY_1;
-
- msg("\n Set latency= %d\n", (wait_cycles == FLASH_LATENCY_2) ? 2 :
- (wait_cycles == FLASH_LATENCY_3) ? 3 :
- 1);
-
- FLASH_SetLatency(wait_cycles);
-
- __NOP();
- __NOP();
- __NOP();
-
- wait_cycles = FLASH_GetLatency();
-
- msg(" Get latency= %d\n", (wait_cycles == FLASH_LATENCY_2) ? 2 :
- (wait_cycles == FLASH_LATENCY_3) ? 3 :
- 1);
-
- #if 0
- { /* do flash P/E operation */
- }
- #endif
- }
- return 0;
-}
diff --git a/Examples/flash/flash_sram_run/.cproject b/Examples/flash/flash_sram_run/.cproject
deleted file mode 100644
index 21d0162..0000000
--- a/Examples/flash/flash_sram_run/.cproject
+++ /dev/null
@@ -1,293 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Examples/flash/flash_sram_run/.project b/Examples/flash/flash_sram_run/.project
deleted file mode 100644
index 2183c12..0000000
--- a/Examples/flash/flash_sram_run/.project
+++ /dev/null
@@ -1,54 +0,0 @@
-
-
- Project
-
-
-
-
-
- org.eclipse.cdt.managedbuilder.core.genmakebuilder
- clean,full,incremental,
-
-
-
-
- org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
- full,incremental,
-
-
-
-
-
- org.eclipse.cdt.core.cnature
- org.eclipse.cdt.managedbuilder.core.managedBuildNature
- org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
-
-
-
- Common
- 2
- PARENT-3-PROJECT_LOC/Common
-
-
- Drivers
- 2
- PARENT-3-PROJECT_LOC/Drivers
-
-
- Profiles
- 2
- PARENT-3-PROJECT_LOC/Tools/scripts/Profiles
-
-
-
-
- 0
-
- 6
-
- org.eclipse.ui.ide.multiFilter
- 1.0-name-matches-false-false-*.nuproject
-
-
-
-
diff --git a/Examples/flash/flash_sram_run/Project.nuproject b/Examples/flash/flash_sram_run/Project.nuproject
deleted file mode 100644
index 0743ed2..0000000
--- a/Examples/flash/flash_sram_run/Project.nuproject
+++ /dev/null
@@ -1,25 +0,0 @@
-SDK_CONFIG:
- Debug:
- core: N203E
- extra_asmflags:
- archext:
- extra_cxxflags:
- cmodel: medlow
- extra_commonflags:
- abi: ilp32e
- arch: rv32emac
- toolchain: gnu
- extra_cflags:
- extra_ldflags:
- Release:
- core: N203E
- extra_asmflags:
- archext:
- extra_cxxflags:
- cmodel: medlow
- extra_commonflags:
- abi: ilp32e
- arch: rv32emac
- toolchain: gnu
- extra_cflags:
- extra_ldflags:
diff --git a/Examples/flash/flash_sram_run/component.mk b/Examples/flash/flash_sram_run/component.mk
deleted file mode 100644
index b1b2bc6..0000000
--- a/Examples/flash/flash_sram_run/component.mk
+++ /dev/null
@@ -1,16 +0,0 @@
-#
-# component Makefile
-#
-
-
-C_SOURCES += \
- $(srctree)/$(PROJ)/src/isr.c \
- $(srctree)/$(PROJ)/src/main.c
-
-C_INCLUDES += -I$(srctree)/$(PROJ)/inc
-
-
-LIBS +=
-CFLAGS +=
-LDFLAGS +=
-LIBDIR +=
diff --git a/Examples/flash/flash_sram_run/inc/main.h b/Examples/flash/flash_sram_run/inc/main.h
deleted file mode 100644
index 6bc013b..0000000
--- a/Examples/flash/flash_sram_run/inc/main.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file main.h
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/08/29
- * @license
- * @description
- */
-
-#ifndef __main_H_wxBnwdPw_lq7D_H4I5_sHPp_uXof15pFLp4V__
-#define __main_H_wxBnwdPw_lq7D_H4I5_sHPp_uXof15pFLp4V__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-#include "hal_device.h"
-#include "syslog.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/Examples/flash/flash_sram_run/readme.md b/Examples/flash/flash_sram_run/readme.md
deleted file mode 100644
index d140e94..0000000
--- a/Examples/flash/flash_sram_run/readme.md
+++ /dev/null
@@ -1,48 +0,0 @@
-flash_sram_run
----
-
-This example is a demo project to execute bin between eFlash and SRAM.
-> It will log the Program-Counter of CORE to address the memory type
-> + eFlash is addressed from `0x0`
-> + SRAM is addressed from `0x2000_0000`
-
-## Log
-
-Use serial port with baudrate 115200, 8bit, no parity check.
-
-```
-15:52:35
-Run program between Flash and SRAM
-
-
-run main() $pc@00000944
-
-
-run sram0_func() $pc@20000000 <--- run at SRAM
-
-SRAM-0: 20000254 | 00 01 02 03 04 05 06 07 - 08 09 0A 0B 0C 0D 0E 0F
-SRAM-0: 20000264 | 10 11 12 13 14 15 16 17 - 18 19 1A 1B 1C 1D 1E 1F
-
-
-
-run eflash_func() $pc@000008A6 <--- run at eFlash
-
-SRAM: 20000234 | 00 01 02 03 04 05 06 07 - 08 09 0A 0B 0C 0D 0E 0F
-SRAM: 20000244 | 10 11 12 13 14 15 16 17 - 18 19 1A 1B 1C 1D 1E 1F
-
-
-
-run sram0_func() $pc@20000000
-
-SRAM-0: 20000254 | 00 01 02 03 04 05 06 07 - 08 09 0A 0B 0C 0D 0E 0F
-SRAM-0: 20000264 | 10 11 12 13 14 15 16 17 - 18 19 1A 1B 1C 1D 1E 1F
-
-
-
-run eflash_func() $pc@000008A6
-
-SRAM: 20000234 | 00 01 02 03 04 05 06 07 - 08 09 0A 0B 0C 0D 0E 0F
-SRAM: 20000244 | 10 11 12 13 14 15 16 17 - 18 19 1A 1B 1C 1D 1E 1F
-
-...
-```
diff --git a/Examples/flash/flash_sram_run/src/isr.c b/Examples/flash/flash_sram_run/src/isr.c
deleted file mode 100644
index d19995f..0000000
--- a/Examples/flash/flash_sram_run/src/isr.c
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file isr.c
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/09/16
- * @license
- * @description
- */
-
-
-#include "isr.h"
-
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-
diff --git a/Examples/flash/flash_sram_run/src/main.c b/Examples/flash/flash_sram_run/src/main.c
deleted file mode 100644
index 2f3f670..0000000
--- a/Examples/flash/flash_sram_run/src/main.c
+++ /dev/null
@@ -1,104 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file main.c
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/08/29
- * @license
- * @description
- */
-
-#include
-#include
-#include "main.h"
-#include "isr.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-#define CONFIG_BUF_SIZE 32
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-const uint8_t g_src_buf_flash[CONFIG_BUF_SIZE] =
-{
- 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
- 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F,
-};
-
-uint32_t g_dst_buf1[CONFIG_BUF_SIZE >> 2];
-uint32_t g_dst_buf1_sram0[CONFIG_BUF_SIZE >> 2];
-
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-void __FASTCODE sram0_func(void)
-{
- uint8_t *pCur = (uint8_t*)g_dst_buf1_sram0;
-
- memset(g_dst_buf1_sram0, 0xAA, sizeof(g_dst_buf1_sram0));
- for(int i = 0; i < sizeof(g_src_buf_flash); i++)
- pCur[i] = g_src_buf_flash[i];
-
- if( memcmp(g_dst_buf1_sram0, g_src_buf_flash, sizeof(g_src_buf_flash)) )
- err("Run fail ! ...\n");
-
- syslog_dump_mem("SRAM-0: ", (uint32_t*)&g_dst_buf1_sram0, sizeof(g_dst_buf1_sram0), false);
- return;
-}
-
-void eflash_func(void)
-{
- uint8_t *pCur = (uint8_t*)g_dst_buf1;
-
- memset(g_dst_buf1, 0xAA, sizeof(g_dst_buf1));
- for(int i = 0; i < sizeof(g_src_buf_flash); i++)
- pCur[i] = g_src_buf_flash[i];
-
- if( memcmp(g_dst_buf1, g_src_buf_flash, sizeof(g_src_buf_flash)) )
- err("Run fail ! ...\n");
-
- syslog_dump_mem("SRAM: ", (uint32_t*)&g_dst_buf1, sizeof(g_dst_buf1), false);
- return;
-}
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-int main(void)
-{
- SYSCFG_ClkInitTypeDef SysClkInit = {0};
-
- SysClkInit.ClkSource = SYSCFG_ClkSrc_HSI;
- SYSCFG_SysClkConfig(&SysClkInit);
-
- sys_config_systick(SYS_TICK_1_MS);
-
- syslog_init();
-
- info("%s\nRun program between Flash and SRAM\n",
- __TIME__);
-
- log_color(SLOG_YELLOW, "\n\nrun main() $pc@%p\n", &main);
-
- while(1)
- {
- log_color(SLOG_YELLOW, "\n\nrun sram0_func() $pc@%p\n", &sram0_func);
- sram0_func();
-
- log_color(SLOG_YELLOW, "\n\nrun eflash_func() $pc@%p\n", &eflash_func);
- eflash_func();
- }
-
- return 0;
-}
diff --git a/Examples/flash/flash_status_flags/.cproject b/Examples/flash/flash_status_flags/.cproject
deleted file mode 100644
index 21d0162..0000000
--- a/Examples/flash/flash_status_flags/.cproject
+++ /dev/null
@@ -1,293 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Examples/flash/flash_status_flags/.project b/Examples/flash/flash_status_flags/.project
deleted file mode 100644
index 2183c12..0000000
--- a/Examples/flash/flash_status_flags/.project
+++ /dev/null
@@ -1,54 +0,0 @@
-
-
- Project
-
-
-
-
-
- org.eclipse.cdt.managedbuilder.core.genmakebuilder
- clean,full,incremental,
-
-
-
-
- org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
- full,incremental,
-
-
-
-
-
- org.eclipse.cdt.core.cnature
- org.eclipse.cdt.managedbuilder.core.managedBuildNature
- org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
-
-
-
- Common
- 2
- PARENT-3-PROJECT_LOC/Common
-
-
- Drivers
- 2
- PARENT-3-PROJECT_LOC/Drivers
-
-
- Profiles
- 2
- PARENT-3-PROJECT_LOC/Tools/scripts/Profiles
-
-
-
-
- 0
-
- 6
-
- org.eclipse.ui.ide.multiFilter
- 1.0-name-matches-false-false-*.nuproject
-
-
-
-
diff --git a/Examples/flash/flash_status_flags/Project.nuproject b/Examples/flash/flash_status_flags/Project.nuproject
deleted file mode 100644
index 0743ed2..0000000
--- a/Examples/flash/flash_status_flags/Project.nuproject
+++ /dev/null
@@ -1,25 +0,0 @@
-SDK_CONFIG:
- Debug:
- core: N203E
- extra_asmflags:
- archext:
- extra_cxxflags:
- cmodel: medlow
- extra_commonflags:
- abi: ilp32e
- arch: rv32emac
- toolchain: gnu
- extra_cflags:
- extra_ldflags:
- Release:
- core: N203E
- extra_asmflags:
- archext:
- extra_cxxflags:
- cmodel: medlow
- extra_commonflags:
- abi: ilp32e
- arch: rv32emac
- toolchain: gnu
- extra_cflags:
- extra_ldflags:
diff --git a/Examples/flash/flash_status_flags/component.mk b/Examples/flash/flash_status_flags/component.mk
deleted file mode 100644
index b1b2bc6..0000000
--- a/Examples/flash/flash_status_flags/component.mk
+++ /dev/null
@@ -1,16 +0,0 @@
-#
-# component Makefile
-#
-
-
-C_SOURCES += \
- $(srctree)/$(PROJ)/src/isr.c \
- $(srctree)/$(PROJ)/src/main.c
-
-C_INCLUDES += -I$(srctree)/$(PROJ)/inc
-
-
-LIBS +=
-CFLAGS +=
-LDFLAGS +=
-LIBDIR +=
diff --git a/Examples/flash/flash_status_flags/inc/main.h b/Examples/flash/flash_status_flags/inc/main.h
deleted file mode 100644
index 6bc013b..0000000
--- a/Examples/flash/flash_status_flags/inc/main.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file main.h
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/08/29
- * @license
- * @description
- */
-
-#ifndef __main_H_wxBnwdPw_lq7D_H4I5_sHPp_uXof15pFLp4V__
-#define __main_H_wxBnwdPw_lq7D_H4I5_sHPp_uXof15pFLp4V__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-#include "hal_device.h"
-#include "syslog.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/Examples/flash/flash_status_flags/readme.md b/Examples/flash/flash_status_flags/readme.md
deleted file mode 100644
index 6506f2a..0000000
--- a/Examples/flash/flash_status_flags/readme.md
+++ /dev/null
@@ -1,107 +0,0 @@
-flash_status_flags
----
-
-This example is used to observe the staust register of FMC
-> For generating the wrong behavior, directly control the registers of FMC
-
-It observes 4-cases
-> + Normal case with CMD end
-> + Wrong address (over range of device)
-> + Miss unlock sector of flash
-> + Use wrong auth-key to operate flash
-
-
-## Log
-
-Use serial port with baudrate 115200, 8bit, no parity check.
-
-```
-16:17:42
-Observe the error status of FMC with wrong behavior
-
-## Case: CMD end flag
-
-@ target address: x00004000
- ======= FMC Regs ====
- FLASH->CMD = xA5A50123
- FLASH->ISR = x00000000
- FLASH->AR = x00004000
- FLASH->DR = xFFFFFFFF
- FLASH->ACM = x00000000
- FLASH->DIV = x00000030
- --- After FMC idle ----
- FLASH->ISR: 0x00000001, CMD_END= 1, KEY_ERR= 0, ACC_ERR=0, ADDR_ERR= 0
-
-@ target address: x00200800
- ======= FMC Regs ====
- FLASH->CMD = xA5EC0123
- FLASH->ISR = x00000000
- FLASH->AR = x00200800
- FLASH->DR = x11223344
- FLASH->ACM = x00000000
- FLASH->DIV = x00000030
- --- After FMC idle ----
- FLASH->ISR: 0x00000001, CMD_END= 1, KEY_ERR= 0, ACC_ERR=0, ADDR_ERR= 0
-
-## Case: Address error flag
-
-@ target address: x00008200
- ======= FMC Regs ====
- FLASH->CMD = xA5A50123
- FLASH->ISR = x00000008
- FLASH->AR = x00000200
- FLASH->DR = x11223344
- FLASH->ACM = x00000000
- FLASH->DIV = x00000030
- --- After FMC idle ----
- FLASH->ISR: 0x00000008, CMD_END= 0, KEY_ERR= 0, ACC_ERR=0, ADDR_ERR= 1
-
-@ target address: x00202200
- ======= FMC Regs ====
- FLASH->CMD = xA5EC0123
- FLASH->ISR = x00000008
- FLASH->AR = x00202200
- FLASH->DR = x11223344
- FLASH->ACM = x00000000
- FLASH->DIV = x00000030
- --- After FMC idle ----
- FLASH->ISR: 0x00000008, CMD_END= 0, KEY_ERR= 0, ACC_ERR=0, ADDR_ERR= 1
-
-## Case: Access error flag
-
-@ target address: x00004000
- ======= FMC Regs ====
- FLASH->CMD = xA5A50023
- FLASH->ISR = x00000000
- FLASH->AR = x00004000
- FLASH->DR = x11223344
- FLASH->ACM = x00000000
- FLASH->DIV = x00000030
- --- After FMC idle ----
- FLASH->ISR: 0x00000004, CMD_END= 0, KEY_ERR= 0, ACC_ERR=1, ADDR_ERR= 0
-
-## Case: Key error flag
-
-@ target address: x00004000
- ======= FMC Regs ====
- FLASH->CMD = xA5EC0123
- FLASH->ISR = x00000000
- FLASH->AR = x00004000
- FLASH->DR = x11223344
- FLASH->ACM = x00000000
- FLASH->DIV = x00000030
- --- After FMC idle ----
- FLASH->ISR: 0x00000002, CMD_END= 0, KEY_ERR= 1, ACC_ERR=0, ADDR_ERR= 0
-
-@ target address: x00200800
- ======= FMC Regs ====
- FLASH->CMD = xA5A50123
- FLASH->ISR = x00000000
- FLASH->AR = x00200800
- FLASH->DR = x11223344
- FLASH->ACM = x00000000
- FLASH->DIV = x00000030
- --- After FMC idle ----
- FLASH->ISR: 0x00000002, CMD_END= 0, KEY_ERR= 1, ACC_ERR=0, ADDR_ERR= 0
-
-```
diff --git a/Examples/flash/flash_status_flags/src/isr.c b/Examples/flash/flash_status_flags/src/isr.c
deleted file mode 100644
index d19995f..0000000
--- a/Examples/flash/flash_status_flags/src/isr.c
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file isr.c
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/09/16
- * @license
- * @description
- */
-
-
-#include "isr.h"
-
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-
diff --git a/Examples/flash/flash_status_flags/src/main.c b/Examples/flash/flash_status_flags/src/main.c
deleted file mode 100644
index c37d1ae..0000000
--- a/Examples/flash/flash_status_flags/src/main.c
+++ /dev/null
@@ -1,236 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file main.c
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/08/29
- * @license
- * @description
- */
-
-#include
-#include
-#include "main.h"
-#include "isr.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-static void
-_Flash_DumpReg(uint32_t reg_cmd)
-{
- msg(" ======= FMC Regs ====\n");
- msg(" FLASH->CMD = x%08X\n", reg_cmd );
- msg(" FLASH->SR = x%08X\n", FLASH->SR );
- msg(" FLASH->AR = x%08X\n", FLASH->AR );
- msg(" FLASH->DR = x%08X\n", FLASH->DR );
- msg(" FLASH->ACM = x%08X\n", FLASH->ACM );
- msg(" FLASH->DIV = x%08X\n", FLASH->DIV );
- return;
-}
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-int main(void)
-{
- uint32_t value = 0;
-
- {
- SYSCFG_ClkInitTypeDef SysClkInit = {0};
-
- SysClkInit.ClkSource = SYSCFG_ClkSrc_HSI;
- SYSCFG_SysClkConfig(&SysClkInit);
- }
-
- sys_config_systick(SYS_TICK_1_MS);
-
- syslog_init();
-
- info("%s\nObserve the error status of FMC with wrong behavior\n",
- __TIME__);
-
- do { /* Case 1: Normal behavior */
- uint32_t addr_act = 0;
-
- log_color(SLOG_CYAN, "\n## Case: CMD end flag\n");
-
- /* Main-Flash address */
- addr_act = EFLASH_MEM_BASE + (sizeof(EFLASH_MEM_Type) >> 1);
- msg("\n@ target address: x%08X\n", addr_act);
-
- FLASH->SR = 0xFFFFFFFFul;
- FLASH->AR = addr_act;
- value = 0xA5A50020ul | FLASH_CMD_UNLOCK_Msk |
- (FLASH_CMD_CMD_ERASE_SECTOR << FLASH_CMD_CMD_Pos) |
- FLASH_CMD_START_Msk;
- _Flash_DumpReg(value);
-
- FLASH->CMD = value;
-
- msg(" --- After FMC idle ----\n");
- msg(" FLASH->SR: 0x%08X, CMD_END= %d, KEY_ERR= %d, ACC_ERR=%d, ADDR_ERR= %d\n",
- FLASH->SR,
- FLASH->SR_b.CMD_END, FLASH->SR_b.KEY_ERR,
- FLASH->SR_b.ACC_ERR, FLASH->SR_b.ADDR_ERR);
-
- /* NVR address */
- addr_act = NVR_MEM_BASE + (2ul << 10);// (sizeof(NVR_MEM_Type) >> 1);
- msg("\n@ target address: x%08X\n", addr_act);
-
- FLASH->SR = 0xFFFFFFFFul;
- FLASH->AR = addr_act;
- FLASH->DR = 0x11223344;
- value = 0xA5EC0020ul | FLASH_CMD_UNLOCK_Msk |
- (FLASH_CMD_CMD_ERASE_SECTOR << FLASH_CMD_CMD_Pos) |
- FLASH_CMD_START_Msk;
- _Flash_DumpReg(value);
-
- FLASH->CMD = value;
-
- msg(" --- After FMC idle ----\n");
- msg(" FLASH->SR: 0x%08X, CMD_END= %d, KEY_ERR= %d, ACC_ERR=%d, ADDR_ERR= %d\n",
- FLASH->SR,
- FLASH->SR_b.CMD_END, FLASH->SR_b.KEY_ERR,
- FLASH->SR_b.ACC_ERR, FLASH->SR_b.ADDR_ERR);
- } while(0);
-
- do { /* Case 2: Wrong address behavior */
- uint32_t addr_act = 0;
-
- log_color(SLOG_CYAN, "\n## Case: Address error flag\n");
-
- /* Over Main-flash address */
- addr_act = EFLASH_MEM_BASE + sizeof(EFLASH_MEM_Type) + 0x200;
- msg("\n@ target address: x%08X\n", addr_act);
-
- FLASH->SR = 0xFFFFFFFFul;
- FLASH->AR = addr_act;
- FLASH->DR = 0x11223344;
- value = 0xA5A50020ul | FLASH_CMD_UNLOCK_Msk |
- (FLASH_CMD_CMD_ERASE_SECTOR << FLASH_CMD_CMD_Pos) |
- FLASH_CMD_START_Msk;
- _Flash_DumpReg(value);
-
- FLASH->CMD = value;
-
- msg(" --- After FMC idle ----\n");
- msg(" FLASH->SR: 0x%08X, CMD_END= %d, KEY_ERR= %d, ACC_ERR=%d, ADDR_ERR= %d\n",
- FLASH->SR,
- FLASH->SR_b.CMD_END, FLASH->SR_b.KEY_ERR,
- FLASH->SR_b.ACC_ERR, FLASH->SR_b.ADDR_ERR);
-
- /* Over NVR address */
- addr_act = NVR_MEM_BASE + sizeof(NVR_MEM_Type) + 0x200;
- msg("\n@ target address: x%08X\n", addr_act);
-
- FLASH->SR = 0xFFFFFFFFul;
- FLASH->AR = addr_act;
- FLASH->DR = 0x11223344;
- value = 0xA5EC0020ul | FLASH_CMD_UNLOCK_Msk |
- (FLASH_CMD_CMD_ERASE_SECTOR << FLASH_CMD_CMD_Pos) |
- FLASH_CMD_START_Msk;
- _Flash_DumpReg(value);
-
- FLASH->CMD = value;
-
- msg(" --- After FMC idle ----\n");
- msg(" FLASH->SR: 0x%08X, CMD_END= %d, KEY_ERR= %d, ACC_ERR=%d, ADDR_ERR= %d\n",
- FLASH->SR,
- FLASH->SR_b.CMD_END, FLASH->SR_b.KEY_ERR,
- FLASH->SR_b.ACC_ERR, FLASH->SR_b.ADDR_ERR);
- } while(0);
-
- do { /* Case 3: No unlock sectors behavior */
- uint32_t addr_act = 0;
-
- log_color(SLOG_CYAN, "\n## Case: Access error flag\n");
-
- addr_act = EFLASH_MEM_BASE + (sizeof(EFLASH_MEM_Type) >> 1);
- msg("\n@ target address: x%08X\n", addr_act);
-
- FLASH->SR = 0xFFFFFFFFul;
- FLASH->AR = addr_act;
- FLASH->DR = 0x11223344;
- value = 0xA5A50020ul |
- (FLASH_CMD_CMD_ERASE_SECTOR << FLASH_CMD_CMD_Pos) |
- FLASH_CMD_START_Msk;
- _Flash_DumpReg(value);
-
- FLASH->CMD = value;
- msg(" --- After FMC idle ----\n");
- msg(" FLASH->SR: 0x%08X, CMD_END= %d, KEY_ERR= %d, ACC_ERR=%d, ADDR_ERR= %d\n",
- FLASH->SR,
- FLASH->SR_b.CMD_END, FLASH->SR_b.KEY_ERR,
- FLASH->SR_b.ACC_ERR, FLASH->SR_b.ADDR_ERR);
- } while(0);
-
- do { /* Case 4: Wrong key behavior */
- uint32_t addr_act = 0;
-
- log_color(SLOG_CYAN, "\n## Case: Key error flag\n");
-
- /* Wrong Main-flash auth-key */
- addr_act = EFLASH_MEM_BASE + (sizeof(EFLASH_MEM_Type) >> 1);
- msg("\n@ target address: x%08X\n", addr_act);
-
- FLASH->SR = 0xFFFFFFFFul;
- FLASH->AR = addr_act;
- FLASH->DR = 0x11223344;
- value = 0xA5EC0020ul | FLASH_CMD_UNLOCK_Msk |
- (FLASH_CMD_CMD_ERASE_SECTOR << FLASH_CMD_CMD_Pos) |
- FLASH_CMD_START_Msk;
- _Flash_DumpReg(value);
-
- FLASH->CMD = value;
-
- msg(" --- After FMC idle ----\n");
- msg(" FLASH->SR: 0x%08X, CMD_END= %d, KEY_ERR= %d, ACC_ERR=%d, ADDR_ERR= %d\n",
- FLASH->SR,
- FLASH->SR_b.CMD_END, FLASH->SR_b.KEY_ERR,
- FLASH->SR_b.ACC_ERR, FLASH->SR_b.ADDR_ERR);
-
- /* Wrong NVR auth-key */
- addr_act = NVR_MEM_BASE + (2ul << 10); // (sizeof(NVR_MEM_Type) >> 1);
- msg("\n@ target address: x%08X\n", addr_act);
-
- FLASH->SR = 0xFFFFFFFFul;
- FLASH->AR = addr_act;
- FLASH->DR = 0x11223344;
- value = 0xA5A50020ul | FLASH_CMD_UNLOCK_Msk |
- (FLASH_CMD_CMD_ERASE_SECTOR << FLASH_CMD_CMD_Pos) |
- FLASH_CMD_START_Msk;
- _Flash_DumpReg(value);
-
- FLASH->CMD = value;
-
- msg(" --- After FMC idle ----\n");
- msg(" FLASH->SR: 0x%08X, CMD_END= %d, KEY_ERR= %d, ACC_ERR=%d, ADDR_ERR= %d\n",
- FLASH->SR,
- FLASH->SR_b.CMD_END, FLASH->SR_b.KEY_ERR,
- FLASH->SR_b.ACC_ERR, FLASH->SR_b.ADDR_ERR);
- } while(0);
-
-
- while(1)
- {
- __NOP();
- }
- return 0;
-}
diff --git a/Examples/gpio/gpio_interrupt/.cproject b/Examples/gpio/gpio_interrupt/.cproject
index 21d0162..1a0019e 100644
--- a/Examples/gpio/gpio_interrupt/.cproject
+++ b/Examples/gpio/gpio_interrupt/.cproject
@@ -40,27 +40,28 @@
-
+
-
-
+
+
+
@@ -68,14 +69,14 @@
@@ -94,7 +95,7 @@
-
-
+
+
@@ -192,10 +193,10 @@
@@ -204,14 +205,14 @@
@@ -225,7 +226,7 @@
diff --git a/Examples/gpio/gpio_interrupt/Project.nuproject b/Examples/gpio/gpio_interrupt/Project.nuproject
index 0743ed2..0072223 100644
--- a/Examples/gpio/gpio_interrupt/Project.nuproject
+++ b/Examples/gpio/gpio_interrupt/Project.nuproject
@@ -7,7 +7,7 @@ SDK_CONFIG:
cmodel: medlow
extra_commonflags:
abi: ilp32e
- arch: rv32emac
+ arch: rv32ema_zba_zbb_zbs_zca_zcb_zcmp_zcmt_zicond
toolchain: gnu
extra_cflags:
extra_ldflags:
@@ -19,7 +19,7 @@ SDK_CONFIG:
cmodel: medlow
extra_commonflags:
abi: ilp32e
- arch: rv32emac
+ arch: rv32emac_zba_zbb_zbs
toolchain: gnu
extra_cflags:
extra_ldflags:
diff --git a/Examples/gpio/gpio_interrupt/readme.md b/Examples/gpio/gpio_interrupt/readme.md
index 3bcd4b5..7105a79 100644
--- a/Examples/gpio/gpio_interrupt/readme.md
+++ b/Examples/gpio/gpio_interrupt/readme.md
@@ -1,35 +1,46 @@
-gpio_interrupt
----
-This example is used to run gpio interrupt function.
+## GPIO Interrupt
-## Hardware and Software environment
+> This example is used to trig gpio interrupt.
-+ This example runs on PB5700 devices.
++ Select GPIO Port
+ ```
+ // in main.c
+ /**
+ * Select Interrupt pin
+ */
+ #define GPIO_INPUT_PORTx GPIOB
+ #define GPIO_INPUT_PINx GPIO_Pin_00
+ #define CONFIG_GPIO_IRQ GPIOB_IRQn
+ ```
-## How to use it ?
++ Select GPIO interrupt trigger mode
+ ```
+ // in main.c
+ /**
+ * Select Interrupt source
+ */
+ #define GPIO_INTERRUPT_TRIGGER GPIO_Trigger_Level
+ #define GPIO_INTERRUPT_POLARITY GPIO_Polarity_Low_Fall
+ ```
-### In order to make the program work, you must do the following:
-+ Open your preferred toolchain
-+ Rebuild all files and load your image into target memory
-+ Run the example
-+ set PA5 for interrupt
-
-# Log
+## Note-Log
Use serial port with baudrate 115200 8bit, no parity check.
-User can receive log infomation on `PA00->TXD` of DUT.
++ Select UART log pin
+ ```
+ // in syslog.c
+ #define CONFIG_LOG_DEVICE_TX_IO_PORTx GPIOA
+ #define CONFIG_LOG_DEVICE_TX_IO_PINx GPIO_Pin_15
+ #define CONFIG_LOG_DEVICE_TX_IO_AF GPIO_AF_1
+ ```
-11:12:58
-This is a demo project to interrput gpio
-11:12:58
-Interupt even
-11:12:58
-Interupt even
-GPIO Interrupt times is 2
-11:12:58
-Interupt even
-GPIO Interrupt times is 1
-11:12:58
-Interupt even
-GPIO Interrupt times is 1
+* If you want to use `PB1` as an interrupt, set IO to normal IO.(RST pin by default)
+ ```
+ SYSCFG_SetRstPin2NormalIO(true); // set RST IO to normal IO
+ ```
+* If you want to use `PB[2:5]` as an interrupt, set IO to normal IO, and Restore IO to JTAG IO at the end.(JTAG pin by default)
+ ```
+ SYSCFG_SetICEPin2NormalIO(true); // set JTAG IO to normal IO
+ SYSCFG_SetICEPin2NormalIO(false); // set normal IO to JTAG IO
+ ```
\ No newline at end of file
diff --git a/Examples/gpio/gpio_interrupt/src/main.c b/Examples/gpio/gpio_interrupt/src/main.c
index e37bccd..ee93ac2 100644
--- a/Examples/gpio/gpio_interrupt/src/main.c
+++ b/Examples/gpio/gpio_interrupt/src/main.c
@@ -16,10 +16,18 @@
//=============================================================================
// Constant Definition
//=============================================================================
-#define GPIO_INPUT_PORTx GPIOA
-#define GPIO_INPUT_PINx GPIO_Pin_05
-#define CONFIG_GPIO_IRQ GPIOA_IRQn // GPIOB_IRQn
+/**
+ * Select Interrupt pin
+ */
+#define GPIO_INPUT_PORTx GPIOB
+#define GPIO_INPUT_PINx GPIO_Pin_00
+#define CONFIG_GPIO_IRQ GPIOB_IRQn
+/**
+ * Select Interrupt source
+ */
+#define GPIO_INTERRUPT_TRIGGER GPIO_Trigger_Level
+#define GPIO_INTERRUPT_POLARITY GPIO_Polarity_Low_Fall
//=============================================================================
// Macro Definition
//=============================================================================
@@ -38,14 +46,18 @@ static bool g_hasPullLow = false;
//=============================================================================
__INTERRUPT void GPIOx_Handler(void)
{
+ SAVE_IRQ_CSR_CONTEXT(); // Save CSRs
+
if( GPIO_GetITFlag(GPIO_INPUT_PORTx, GPIO_INPUT_PINx) )
{
+ /* Enter interrupt trigger */
GPIO_ClearITFlag(GPIO_INPUT_PORTx, GPIO_INPUT_PINx);
- g_hasPullLow = true;
+ g_hasPullLow = true; // Mark interrupt triggered
g_interrupt_cnt++;
}
+ RESTORE_IRQ_CSR_CONTEXT(); // Restore CSRs
return;
}
//=============================================================================
@@ -53,7 +65,7 @@ __INTERRUPT void GPIOx_Handler(void)
//=============================================================================
int main(void)
{
- GPIO_InitTypeDef GPIO_InitStruct = {0};
+ /* Configure system clock */
SYSCFG_ClkInitTypeDef SysClkInit = {0};
SysClkInit.ClkSource = SYSCFG_ClkSrc_HSI;
@@ -65,29 +77,31 @@ int main(void)
info("%s %s\nThis is a demo project of GPIO interrput\n", __DATE__, __TIME__);
+ /* Configure trig interrupt pin and set interrupt source */
+ GPIO_InitTypeDef GPIO_InitStruct = {0};
GPIO_InitStruct.GPIO_Pin = GPIO_INPUT_PINx;
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IN ;
- GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL;
- GPIO_InitStruct.GPIO_ITInit.GPIO_Trigger = GPIO_Trigger_Level;
- GPIO_InitStruct.GPIO_ITInit.GPIO_Polarity = GPIO_Polarity_Low_Fall;
+ GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_DOWN;
+ GPIO_InitStruct.GPIO_ITInit.GPIO_Trigger = GPIO_INTERRUPT_TRIGGER;
+ GPIO_InitStruct.GPIO_ITInit.GPIO_Polarity = GPIO_INTERRUPT_POLARITY;
+ if(GPIO_InitStruct.GPIO_ITInit.GPIO_Polarity == GPIO_Polarity_High_Rise)
+ GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_DOWN;
+ else
+ GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(GPIO_INPUT_PORTx , &GPIO_InitStruct);
+ /* Configure the interrupt function of GPIO */
+ GPIO_ITConfig(GPIO_INPUT_PORTx, GPIO_INPUT_PINx, &GPIO_InitStruct.GPIO_ITInit);
+ GPIO_ITEnable(GPIO_INPUT_PORTx, GPIO_INPUT_PINx);
sys_irq_attr_t irq_attr = { .trig_mode = SYS_IRQ_TRIGGER_LEVEL, };
sys_register_IRQ(CONFIG_GPIO_IRQ, GPIOx_Handler, &irq_attr);
- /* Configure interrupt type of GPIO */
- GPIO_InitStruct.GPIO_ITInit.GPIO_Trigger = GPIO_Trigger_Level;
- GPIO_InitStruct.GPIO_ITInit.GPIO_Polarity = GPIO_Polarity_Low_Fall;
- GPIO_ITConfig(GPIO_INPUT_PORTx, GPIO_INPUT_PINx, &GPIO_InitStruct.GPIO_ITInit);
-
- /* Enable GPIO interrupt */
- GPIO_ITEnable(GPIO_INPUT_PORTx, GPIO_INPUT_PINx);
-
while(1)
{
+ /* Interrupt triggered behavior */
if( g_hasPullLow == true )
{
- msg("GPIO Interrupt times is %d\n", g_interrupt_cnt);
+ msg("Interrupt times is %d\n", g_interrupt_cnt);
g_hasPullLow = false;
}
diff --git a/Examples/gpio/gpio_toggle/.cproject b/Examples/gpio/gpio_toggle/.cproject
index 21d0162..1a0019e 100644
--- a/Examples/gpio/gpio_toggle/.cproject
+++ b/Examples/gpio/gpio_toggle/.cproject
@@ -40,27 +40,28 @@
-
+
-
-
+
+
+
@@ -68,14 +69,14 @@
@@ -94,7 +95,7 @@
-
-
+
+
@@ -192,10 +193,10 @@
@@ -204,14 +205,14 @@
@@ -225,7 +226,7 @@
diff --git a/Examples/gpio/gpio_toggle/Project.nuproject b/Examples/gpio/gpio_toggle/Project.nuproject
index 0743ed2..0072223 100644
--- a/Examples/gpio/gpio_toggle/Project.nuproject
+++ b/Examples/gpio/gpio_toggle/Project.nuproject
@@ -7,7 +7,7 @@ SDK_CONFIG:
cmodel: medlow
extra_commonflags:
abi: ilp32e
- arch: rv32emac
+ arch: rv32ema_zba_zbb_zbs_zca_zcb_zcmp_zcmt_zicond
toolchain: gnu
extra_cflags:
extra_ldflags:
@@ -19,7 +19,7 @@ SDK_CONFIG:
cmodel: medlow
extra_commonflags:
abi: ilp32e
- arch: rv32emac
+ arch: rv32emac_zba_zbb_zbs
toolchain: gnu
extra_cflags:
extra_ldflags:
diff --git a/Examples/gpio/gpio_toggle/readme.md b/Examples/gpio/gpio_toggle/readme.md
index d672a91..20c0449 100644
--- a/Examples/gpio/gpio_toggle/readme.md
+++ b/Examples/gpio/gpio_toggle/readme.md
@@ -1,17 +1,26 @@
-gpio_toggle
+
+## GPIO toggle
+
+The example is used to toggle gpio.
+
++ Select GPIO Portx
+ ```
+ // at main.c
+ /**
+ * Select toggle pin
+ */
+ #define GPIO_PORTx GPIOA
+ #define GPIO_Pinx GPIO_Pin_00
+ ```
+
+Note:
---
-
-This example is used to run gpio toggle function.
-
-## Hardware and Software environment
-
-+ This example runs on PB5700 devices.
-
-## How to use it ?
-
-### In order to make the program work, you must do the following:
-
-+ Open your preferred toolchain
-+ Rebuild all files and load your image into target memory
-+ Run the example
-+ GPIO Pin will toggle
\ No newline at end of file
+* If you want to toggle `PB1`, set IO to normal IO.(RST pin by default)
+ ```
+ SYSCFG_SetRstPin2NormalIO(true); // set RST IO to normal IO
+ ```
+* If you want to toggle `PB[2:5]`, set IO to normal IO, and Restore IO to JTAG IO at the end.(JTAG pin by default)
+ ```
+ SYSCFG_SetICEPin2NormalIO(true); // set JTAG IO to normal IO
+ SYSCFG_SetICEPin2NormalIO(false); // set normal IO to JTAG IO
+ ```
\ No newline at end of file
diff --git a/Examples/gpio/gpio_toggle/src/main.c b/Examples/gpio/gpio_toggle/src/main.c
index d20649f..52c980f 100644
--- a/Examples/gpio/gpio_toggle/src/main.c
+++ b/Examples/gpio/gpio_toggle/src/main.c
@@ -18,7 +18,11 @@
//=============================================================================
// Constant Definition
//=============================================================================
-#define GPIO_PORTx GPIOA
+/**
+ * Select toggle pin
+ */
+#define GPIO_PORTx GPIOA
+#define GPIO_Pinx GPIO_Pin_00
//=============================================================================
// Macro Definition
//=============================================================================
@@ -40,7 +44,7 @@
//=============================================================================
int main(void)
{
- GPIO_InitTypeDef GPIO_InitStruct = {0};
+ /* Configure system clock */
SYSCFG_ClkInitTypeDef SysClkInit = {0};
SysClkInit.ClkSource = SYSCFG_ClkSrc_HSI;
@@ -52,7 +56,9 @@ int main(void)
info("%s\nThis is a demo project to toggle gpio\n", __TIME__);
- GPIO_InitStruct.GPIO_Pin = GPIO_Pin_03 | GPIO_Pin_04;
+ /* Configure toggle pin */
+ GPIO_InitTypeDef GPIO_InitStruct = {0};
+ GPIO_InitStruct.GPIO_Pin = GPIO_Pinx;
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;
@@ -60,11 +66,11 @@ int main(void)
while(1)
{
- GPIO_TogglePin(GPIO_PORTx, GPIO_Pin_03);
+ /* pin toggle */
+ GPIO_TogglePin(GPIO_PORTx, GPIO_Pinx);
- GPIO_TogglePin(GPIO_PORTx, GPIO_Pin_04);
-
- //__NOP();
+ /* delay 10ms */
+ sys_delay(10);
}
return 0;
}
diff --git a/Examples/adc/adc_single_conv_interrupt/.cproject b/Examples/i2c/i2c_mster_transceiver/.cproject
similarity index 94%
rename from Examples/adc/adc_single_conv_interrupt/.cproject
rename to Examples/i2c/i2c_mster_transceiver/.cproject
index 2f90cfe..1a0019e 100644
--- a/Examples/adc/adc_single_conv_interrupt/.cproject
+++ b/Examples/i2c/i2c_mster_transceiver/.cproject
@@ -40,28 +40,28 @@
-
+
-
-
-
+
+
+
@@ -69,14 +69,14 @@
@@ -95,7 +95,7 @@
-
-
+
+
@@ -193,10 +193,10 @@
@@ -205,14 +205,14 @@
@@ -226,7 +226,7 @@
diff --git a/Examples/adc/adc_single_conv_interrupt/.project b/Examples/i2c/i2c_mster_transceiver/.project
similarity index 100%
rename from Examples/adc/adc_single_conv_interrupt/.project
rename to Examples/i2c/i2c_mster_transceiver/.project
diff --git a/Examples/adc/adc_trigger_src/Project.nuproject b/Examples/i2c/i2c_mster_transceiver/Project.nuproject
similarity index 89%
rename from Examples/adc/adc_trigger_src/Project.nuproject
rename to Examples/i2c/i2c_mster_transceiver/Project.nuproject
index b783ad6..0072223 100644
--- a/Examples/adc/adc_trigger_src/Project.nuproject
+++ b/Examples/i2c/i2c_mster_transceiver/Project.nuproject
@@ -7,7 +7,7 @@ SDK_CONFIG:
cmodel: medlow
extra_commonflags:
abi: ilp32e
- arch: rv32emac_zba_zbb_zbs
+ arch: rv32ema_zba_zbb_zbs_zca_zcb_zcmp_zcmt_zicond
toolchain: gnu
extra_cflags:
extra_ldflags:
diff --git a/Examples/adc/adc_single_conv_interrupt/component.mk b/Examples/i2c/i2c_mster_transceiver/component.mk
similarity index 100%
rename from Examples/adc/adc_single_conv_interrupt/component.mk
rename to Examples/i2c/i2c_mster_transceiver/component.mk
diff --git a/Examples/comp/Compare_for_TI/inc/isr.h b/Examples/i2c/i2c_mster_transceiver/inc/isr.h
similarity index 100%
rename from Examples/comp/Compare_for_TI/inc/isr.h
rename to Examples/i2c/i2c_mster_transceiver/inc/isr.h
diff --git a/Examples/adc/adc_single_conv_interrupt/inc/main.h b/Examples/i2c/i2c_mster_transceiver/inc/main.h
similarity index 100%
rename from Examples/adc/adc_single_conv_interrupt/inc/main.h
rename to Examples/i2c/i2c_mster_transceiver/inc/main.h
diff --git a/Examples/i2c/i2c_mster_transceiver/readme.md b/Examples/i2c/i2c_mster_transceiver/readme.md
new file mode 100644
index 0000000..2bb79a2
--- /dev/null
+++ b/Examples/i2c/i2c_mster_transceiver/readme.md
@@ -0,0 +1,78 @@
+
+## I2C_master_transceiver
+
+> This example is used to transceive data with STM32 I2C-Master
+
+### steps
+> IIC master: `DUT` IIC slave: `STM32`
+1. `DUT` ==> `STM32`(Transmit data action)
+2. `STM32` save the data
+3. `DUT` ==> `STM32`(Receive data action)
+4. `STM32` send the saved data
+5. `DUT` save the read data
+6. `DUT` compare the Transmitted data with the Received data, if consistent, proceed to the next loop, and inconsistent, enter while(1) loop
+
+### Configuration
+
++ select transmit mode
+
+ ```
+ //in main.c
+ /**
+ * if defined, transfer data using interrupt mode
+ * if not, transfer data using polling mode
+ */
+ #define CONFIG_USE_I2C_INTERRUPT
+ ```
+
++ Select IIC DIV Clock
+
+ ```
+ //in main.c
+ #define IIC_DIV_CLOCK I2C_CLK_Div60 // I2C clock division
+ ```
+
++ Select IIC pin
+
+ ```
+ //in main.c
+ /**
+ * Select I2C SCL and SDA pin
+ */
+ #define IIC_SCL_PORT GPIOA
+ #define IIC_SCL_PIN GPIO_Pin_00
+ #define IIC_SCL_AF GPIO_AF_4
+ #define IIC_SDA_PORT GPIOA
+ #define IIC_SDA_PIN GPIO_Pin_01
+ #define IIC_SDA_AF GPIO_AF_4
+ ```
+
+ > SCL_PIN: `PA00` `PA01` `PB02` `PB01` `PB03` `PA15`
+ >
+ > SDA_PIN: `PA01` `PA00` `PB01` `PB02` `PB05` `PB00`
+
+
+---
+Note:
+
++ Select UART log pin
+
+ ```
+ // in syslog.c
+ #define CONFIG_LOG_DEVICE_TX_IO_PORTx GPIOA
+ #define CONFIG_LOG_DEVICE_TX_IO_PINx GPIO_Pin_15
+ #define CONFIG_LOG_DEVICE_TX_IO_AF GPIO_AF_1
+ ```
+
++ If you want to use `PB1` as an I2C pin, set IO to normal IO.(RST pin by default)
+
+ ```
+ SYSCFG_SetRstPin2NormalIO(true); // set RST IO to normal IO
+ ```
+
++ If you want to use `PB[2:5]` as an I2C pin, set IO to normal IO, and Restore IO to JTAG IO at the end.(JTAG pin by default)
+
+ ```
+ SYSCFG_SetICEPin2NormalIO(true); // set JTAG IO to normal IO
+ SYSCFG_SetICEPin2NormalIO(false); // set normal IO to JTAG IO
+ ```
diff --git a/Examples/amisc/dac_test/src/isr.c b/Examples/i2c/i2c_mster_transceiver/src/isr.c
similarity index 100%
rename from Examples/amisc/dac_test/src/isr.c
rename to Examples/i2c/i2c_mster_transceiver/src/isr.c
diff --git a/Examples/i2c/i2c_mster_transceiver/src/main.c b/Examples/i2c/i2c_mster_transceiver/src/main.c
new file mode 100644
index 0000000..a5e68c2
--- /dev/null
+++ b/Examples/i2c/i2c_mster_transceiver/src/main.c
@@ -0,0 +1,211 @@
+/**
+ * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
+ */
+/** @file main.c
+ *
+ * @author Wei-Lun Hsu
+ * @version 0.1
+ * @date 2024/08/29
+ * @license
+ * @description
+ */
+
+#include
+#include "main.h"
+#include "isr.h"
+//=============================================================================
+// Constant Definition
+//=============================================================================
+/**
+ * if defined, transfer data using interrupt mode
+ * if not, transfer data using polling mode
+ */
+#define CONFIG_USE_I2C_INTERRUPT
+
+#define CONFIG_REMOTE_I2C_ADDR 0xB0 // slave address
+#define CONFIG_DATA_BUF_LEN 64 // transmit data of length
+
+#define IIC_DIV_CLOCK I2C_CLK_Div60 // I2C clock division
+
+/**
+ * Select I2C SCL and SDA pin
+ */
+#define IIC_SCL_PORT GPIOA
+#define IIC_SCL_PIN GPIO_Pin_00
+#define IIC_SCL_AF GPIO_AF_4
+#define IIC_SDA_PORT GPIOA
+#define IIC_SDA_PIN GPIO_Pin_01
+#define IIC_SDA_AF GPIO_AF_4
+
+#define I2Cx I2C0
+#define I2Cx_IRQn I2C0_IRQn
+
+#if defined(CONFIG_USE_I2C_INTERRUPT)
+ #define CONFIG_XFER_MODE "Interrupt"
+#else
+ #define CONFIG_XFER_MODE "Polling"
+#endif
+
+//=============================================================================
+// Macro Definition
+//=============================================================================
+
+//=============================================================================
+// Structure Definition
+//=============================================================================
+
+//=============================================================================
+// Global Data Definition
+//=============================================================================
+static uint8_t g_tx_buf[CONFIG_DATA_BUF_LEN] = {0};
+static uint8_t g_rx_buf[CONFIG_DATA_BUF_LEN] = {0};
+
+static I2C_IT_HandleTypeDef g_hI2CIT = {0};
+//=============================================================================
+// Private Function Definition
+//=============================================================================
+__INTERRUPT void I2Cx_Handler(void)
+{
+ SAVE_IRQ_CSR_CONTEXT(); // Save CSRs
+
+ I2C_Master_IRQHandler(&g_hI2CIT);
+
+ RESTORE_IRQ_CSR_CONTEXT(); // Restore CSRs
+ return;
+}
+
+/**
+ * Configure the pin of I2C
+ */
+static void _Config_IO(void)
+{
+ GPIO_InitTypeDef GPIO_InitStruct = {0};
+ GPIO_InitStruct.GPIO_Pin = IIC_SCL_PIN;
+ GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF;
+ GPIO_InitStruct.GPIO_AF_Mode = IIC_SCL_AF;
+ GPIO_InitStruct.GPIO_OType = GPIO_OType_OD;
+ GPIO_Init(IIC_SCL_PORT, &GPIO_InitStruct);
+ GPIO_InitStruct.GPIO_Pin = IIC_SDA_PIN;
+ GPIO_InitStruct.GPIO_AF_Mode = IIC_SDA_AF;
+ GPIO_Init(IIC_SDA_PORT, &GPIO_InitStruct);
+
+ return;
+}
+
+//=============================================================================
+// Public Function Definition
+//=============================================================================
+int main(void)
+{
+ SYSCFG_ClkInitTypeDef SysClkInit = {0};
+ I2C_ErrTypeDef rval = I2C_Err_OK;
+ int data_base = 0x50;
+
+ /* Configure system clock */
+ SysClkInit.ClkSource = SYSCFG_ClkSrc_HSI;
+ SysClkInit.SysClk_Div = SYSCFG_SysClkDiv4;
+ SYSCFG_SysClkConfig(&SysClkInit);
+
+ sys_config_systick(SYS_TICK_1_MS);
+
+ syslog_init();
+
+ info("%s %s\nI2C-Maseter (%s). The Target Slave-Address is 0x%02X\n",
+ __DATE__, __TIME__, CONFIG_XFER_MODE, (CONFIG_REMOTE_I2C_ADDR >> 1));
+
+ /* Configure the pin of I2C */
+ _Config_IO();
+
+ /* Configure the parameters of I2C */
+ I2C_InitTypeDef init = {0};
+ I2C_StructInit(&init);
+ init.Mode = I2C_Mode_MASTER;
+ init.ClockDiv = IIC_DIV_CLOCK;
+ init.BroadAck = I2C_BroadAck_Enable;
+ rval = I2C_Init(I2Cx, &init);
+ if( rval != I2C_Err_OK )
+ {
+ err("I2C init fail !\n");
+ }
+
+#if defined(CONFIG_USE_I2C_INTERRUPT)
+ { /* Setup Interrupt */
+ sys_irq_attr_t irq_attr = { .trig_mode = SYS_IRQ_TRIGGER_LEVEL, };
+ sys_register_IRQ(I2Cx_IRQn, I2Cx_Handler, &irq_attr);
+
+ g_hI2CIT.pHI2C = I2Cx;
+ }
+#endif
+
+ do {
+ sys_delay(500);
+
+ /* prepare data */
+ data_base++;
+ for(int i = 0; i < sizeof(g_tx_buf); i++)
+ {
+ g_tx_buf[i] = (data_base + i) & 0xFF;
+ }
+ log_color(SLOG_GREEN, " @ Start Transmitting...\n");
+ syslog_dump_mem("tx: ", (uint32_t*)&g_tx_buf, sizeof(g_tx_buf), 0);
+
+ /* IIC Master transmit and receive data */
+ #if defined(CONFIG_USE_I2C_INTERRUPT)
+ rval = I2C_Master_Transmit_IT(&g_hI2CIT, CONFIG_REMOTE_I2C_ADDR, (uint8_t*)&g_tx_buf, (uint16_t)sizeof(g_tx_buf));
+ if( rval != I2C_Err_OK )
+ {
+ err("I2C master TX fail !\n");
+ break;
+ }
+
+ while( g_hI2CIT.XferMode != I2C_XferMode_Idle )
+ __NOP();
+
+ rval = I2C_Master_Receive_IT(&g_hI2CIT, CONFIG_REMOTE_I2C_ADDR, (uint8_t*)&g_rx_buf, (uint16_t)sizeof(g_rx_buf));
+ if( rval != I2C_Err_OK )
+ {
+ err("I2C master RX fail !\n");
+ break;
+ }
+
+ while( g_hI2CIT.XferMode != I2C_XferMode_Idle )
+ __NOP();
+
+ #else
+ uint16_t length = 0;
+
+ rval = I2C_Master_Transmit(I2Cx, CONFIG_REMOTE_I2C_ADDR, (uint8_t*)&g_tx_buf, (uint16_t)sizeof(g_tx_buf));
+ if( rval != I2C_Err_OK )
+ {
+ err("I2C master TX fail !\n");
+ break;
+ }
+
+ length = sizeof(g_rx_buf);
+ memset((void*)&g_rx_buf, 0xAA, sizeof(g_rx_buf));
+
+ rval = I2C_Master_Receive(I2Cx, CONFIG_REMOTE_I2C_ADDR, (uint8_t*)&g_rx_buf, &length, 1000);
+ if( rval != I2C_Err_OK )
+ {
+ err("I2C master RX fail !\n");
+ break;
+ }
+ #endif
+
+ /* comparative data */
+ syslog_dump_mem("rx: ", (uint32_t*)&g_rx_buf, sizeof(g_rx_buf), 0);
+
+ if( !memcmp(g_tx_buf, g_rx_buf, sizeof(g_tx_buf)) )
+ msg("done~~ \n\n");
+ else
+ {
+ err("Data is NOT match !\n");
+ break;
+ }
+
+ } while(1);
+
+
+ while(1);
+ return 0;
+}
diff --git a/Examples/i2c/i2c_slave_transceiver/.cproject b/Examples/i2c/i2c_slave_transceiver/.cproject
new file mode 100644
index 0000000..1a0019e
--- /dev/null
+++ b/Examples/i2c/i2c_slave_transceiver/.cproject
@@ -0,0 +1,294 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Examples/adc/adc_trigger_src/.project b/Examples/i2c/i2c_slave_transceiver/.project
similarity index 100%
rename from Examples/adc/adc_trigger_src/.project
rename to Examples/i2c/i2c_slave_transceiver/.project
diff --git a/Examples/adc/adc_for_TI/Project.nuproject b/Examples/i2c/i2c_slave_transceiver/Project.nuproject
similarity index 83%
rename from Examples/adc/adc_for_TI/Project.nuproject
rename to Examples/i2c/i2c_slave_transceiver/Project.nuproject
index 0743ed2..0072223 100644
--- a/Examples/adc/adc_for_TI/Project.nuproject
+++ b/Examples/i2c/i2c_slave_transceiver/Project.nuproject
@@ -7,7 +7,7 @@ SDK_CONFIG:
cmodel: medlow
extra_commonflags:
abi: ilp32e
- arch: rv32emac
+ arch: rv32ema_zba_zbb_zbs_zca_zcb_zcmp_zcmt_zicond
toolchain: gnu
extra_cflags:
extra_ldflags:
@@ -19,7 +19,7 @@ SDK_CONFIG:
cmodel: medlow
extra_commonflags:
abi: ilp32e
- arch: rv32emac
+ arch: rv32emac_zba_zbb_zbs
toolchain: gnu
extra_cflags:
extra_ldflags:
diff --git a/Examples/adc/adc_trigger_src/component.mk b/Examples/i2c/i2c_slave_transceiver/component.mk
similarity index 100%
rename from Examples/adc/adc_trigger_src/component.mk
rename to Examples/i2c/i2c_slave_transceiver/component.mk
diff --git a/Examples/flash/flash_prog_erase_nvr/inc/isr.h b/Examples/i2c/i2c_slave_transceiver/inc/isr.h
similarity index 100%
rename from Examples/flash/flash_prog_erase_nvr/inc/isr.h
rename to Examples/i2c/i2c_slave_transceiver/inc/isr.h
diff --git a/Examples/adc/adc_trigger_src/inc/main.h b/Examples/i2c/i2c_slave_transceiver/inc/main.h
similarity index 100%
rename from Examples/adc/adc_trigger_src/inc/main.h
rename to Examples/i2c/i2c_slave_transceiver/inc/main.h
diff --git a/Examples/i2c/i2c_slave_transceiver/readme.md b/Examples/i2c/i2c_slave_transceiver/readme.md
new file mode 100644
index 0000000..049efac
--- /dev/null
+++ b/Examples/i2c/i2c_slave_transceiver/readme.md
@@ -0,0 +1,67 @@
+
+## i2c_slave_transceiver
+> This example is used to transceive data with I2C-Slave
+
+
+### steps
+> IIC master: `STM32` IIC slave: `DUT`
+1. `STM32` ==> `DUT`(Transmit data action)
+2. `DUT` save the data
+3. `STM32` ==> `DUT`(Receive data action)
+4. `DUT` send data( is consistent with the transmitted data)
+5. `DUT` compare the save send with the send data, if consistent, proceed to the next loop, and inconsistent, enter `while(1)` loop
+
+### Configuration
+
++ select transmit mode
+
+ ```
+ //in main.c
+ /**
+ * if defined, transfer data using interrupt mode
+ * if not, transfer data using polling mode
+ */
+ #define CONFIG_USE_I2C_INTERRUPT
+ ```
+
++ Select IIC pin
+
+ ```
+ //in main.c
+ /**
+ * Select I2C SCL and SDA pin
+ */
+ #define IIC_SCL_PORT GPIOA
+ #define IIC_SCL_PIN GPIO_Pin_00
+ #define IIC_SCL_AF GPIO_AF_4
+ #define IIC_SDA_PORT GPIOA
+ #define IIC_SDA_PIN GPIO_Pin_01
+ #define IIC_SDA_AF GPIO_AF_4
+ ```
+
+ > SCL_PIN: `PA00` `PA01` `PB02` `PB01` `PB03` `PA15`
+ >
+ > SDA_PIN: `PA01` `PA00` `PB01` `PB02` `PB05` `PB00`
+
+
++ Select UART log pin
+
+ ```
+ // in syslog.c
+ #define CONFIG_LOG_DEVICE_TX_IO_PORTx GPIOA
+ #define CONFIG_LOG_DEVICE_TX_IO_PINx GPIO_Pin_15
+ #define CONFIG_LOG_DEVICE_TX_IO_AF GPIO_AF_1
+ ```
+
++ If you want to use `PB1` as an I2C pin, set IO to normal IO.(RST pin by default)
+
+ ```
+ SYSCFG_SetRstPin2NormalIO(true); // set RST IO to normal IO
+ ```
+
++ If you want to use `PB[2:5]` as an I2C pin, set IO to normal IO, and Restore IO to JTAG IO at the end.(JTAG pin by default)
+
+ ```
+ SYSCFG_SetICEPin2NormalIO(true); // set JTAG IO to normal IO
+ SYSCFG_SetICEPin2NormalIO(false); // set normal IO to JTAG IO
+ ```
diff --git a/Examples/comp/Compare_GpioVsVref/src/isr.c b/Examples/i2c/i2c_slave_transceiver/src/isr.c
similarity index 100%
rename from Examples/comp/Compare_GpioVsVref/src/isr.c
rename to Examples/i2c/i2c_slave_transceiver/src/isr.c
diff --git a/Examples/i2c/i2c_slave_transceiver/src/main.c b/Examples/i2c/i2c_slave_transceiver/src/main.c
new file mode 100644
index 0000000..f944e96
--- /dev/null
+++ b/Examples/i2c/i2c_slave_transceiver/src/main.c
@@ -0,0 +1,210 @@
+/**
+ * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
+ */
+/** @file main.c
+ *
+ * @author Wei-Lun Hsu
+ * @version 0.1
+ * @date 2024/08/29
+ * @license
+ * @description
+ */
+
+#include
+#include "main.h"
+#include "isr.h"
+//=============================================================================
+// Constant Definition
+//=============================================================================
+/**
+ * if defined, transfer data using interrupt mode
+ * if not, transfer data using polling mode
+ */
+#define CONFIG_USE_I2C_INTERRUPT
+
+#define CONFIG_REMOTE_I2C_ADDR 0xAA // slave address
+#define CONFIG_DATA_BUF_LEN 64 // transmit data of length
+
+/**
+ * Select I2C SCL and SDA pin
+ */
+#define IIC_SCL_PORT GPIOA
+#define IIC_SCL_PIN GPIO_Pin_00
+#define IIC_SCL_AF GPIO_AF_4
+#define IIC_SDA_PORT GPIOA
+#define IIC_SDA_PIN GPIO_Pin_01
+#define IIC_SDA_AF GPIO_AF_4
+
+#define I2Cx I2C0
+#define I2Cx_IRQn I2C0_IRQn
+
+#if defined(CONFIG_USE_I2C_INTERRUPT)
+ #define CONFIG_XFER_MODE "Interrupt"
+#else
+ #define CONFIG_XFER_MODE "Polling"
+#endif
+//=============================================================================
+// Macro Definition
+//=============================================================================
+
+//=============================================================================
+// Structure Definition
+//=============================================================================
+
+//=============================================================================
+// Global Data Definition
+//=============================================================================
+static uint8_t g_tx_buf[CONFIG_DATA_BUF_LEN] = {0};
+static uint8_t g_rx_buf[CONFIG_DATA_BUF_LEN] = {0};
+
+static I2C_IT_HandleTypeDef g_hI2CIT = {0};
+//=============================================================================
+// Private Function Definition
+//=============================================================================
+__INTERRUPT void I2Cx_Handler(void)
+{
+ SAVE_IRQ_CSR_CONTEXT(); // Save CSRs
+
+ I2C_Slave_IRQHandler(&g_hI2CIT);
+
+ RESTORE_IRQ_CSR_CONTEXT(); // Restore CSRs
+ return;
+}
+
+
+/**
+ * Configure the pin of I2C
+ */
+static void _Config_IO(void)
+{
+ GPIO_InitTypeDef GPIO_InitStruct = {0};
+ GPIO_InitStruct.GPIO_Pin = IIC_SCL_PIN;
+ GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF;
+ GPIO_InitStruct.GPIO_AF_Mode = IIC_SCL_AF;
+ GPIO_InitStruct.GPIO_OType = GPIO_OType_OD;
+ GPIO_Init(IIC_SCL_PORT, &GPIO_InitStruct);
+ GPIO_InitStruct.GPIO_Pin = IIC_SDA_PIN;
+ GPIO_InitStruct.GPIO_AF_Mode = IIC_SDA_AF;
+ GPIO_Init(IIC_SDA_PORT, &GPIO_InitStruct);
+
+ return;
+}
+
+//=============================================================================
+// Public Function Definition
+//=============================================================================
+int main(void)
+{
+ SYSCFG_ClkInitTypeDef SysClkInit = {0};
+ I2C_ErrTypeDef rval = I2C_Err_OK;
+ int data_base = 0x50;
+
+ /* Configure system clock */
+ SysClkInit.ClkSource = SYSCFG_ClkSrc_FreqDiv;
+ SysClkInit.SysClk_Div = SYSCFG_SysClkDiv8;
+ SYSCFG_SysClkConfig(&SysClkInit);
+
+ sys_config_systick(SYS_TICK_1_MS);
+
+ syslog_init();
+
+ info("%s %s\nI2C-Slave (%s). The local Slave-Address is 0x%02X\n",
+ __DATE__, __TIME__, CONFIG_XFER_MODE, (CONFIG_REMOTE_I2C_ADDR >> 1));
+
+ /* Configure the pin of I2C */
+ _Config_IO();
+
+ /* Configure the parameters of I2C */
+ I2C_InitTypeDef init = {0};
+ I2C_StructInit(&init);
+ init.Mode = I2C_Mode_SLAVE;
+ init.OwnAddress = CONFIG_REMOTE_I2C_ADDR >> 1;
+// init.ClockDiv = I2C_CLK_Div960;
+ rval = I2C_Init(I2Cx, &init);
+ if( rval != I2C_Err_OK )
+ {
+ err("I2C init fail !\n");
+ }
+
+
+#if defined(CONFIG_USE_I2C_INTERRUPT)
+ { /* Setup Interrupt */
+ sys_irq_attr_t irq_attr = { .trig_mode = SYS_IRQ_TRIGGER_LEVEL, };
+ sys_register_IRQ(I2Cx_IRQn, I2Cx_Handler, &irq_attr);
+
+ g_hI2CIT.pHI2C = I2Cx;
+ }
+#endif
+
+ do {
+ /* prepare data */
+ data_base++;
+ for(int i = 0; i < sizeof(g_tx_buf); i++)
+ {
+ g_tx_buf[i] = (data_base + i) & 0xFF;
+ }
+
+ log_color(SLOG_GREEN, " @ Start Transmitting...\n");
+ syslog_dump_mem("tx: ", (uint32_t*)&g_tx_buf, sizeof(g_tx_buf), 0);
+
+ /* IIC slave receive and transmit data */
+ #if defined(CONFIG_USE_I2C_INTERRUPT)
+ rval = I2C_Slave_Receive_IT(&g_hI2CIT, (uint8_t*)&g_rx_buf, (uint16_t)sizeof(g_rx_buf));
+ if( rval != I2C_Err_OK )
+ {
+ err("I2C master TX fail !\n");
+ break;
+ }
+
+ while( g_hI2CIT.XferMode != I2C_XferMode_Idle )
+ __NOP();
+
+ rval = I2C_Slave_Transmit_IT(&g_hI2CIT, (uint8_t*)&g_tx_buf, (uint16_t)sizeof(g_tx_buf));
+ if( rval != I2C_Err_OK )
+ {
+ err("I2C master RX fail !\n");
+ break;
+ }
+
+ while( g_hI2CIT.XferMode != I2C_XferMode_Idle )
+ __NOP();
+
+ #else
+ uint16_t length = 0;
+
+ length = sizeof(g_rx_buf);
+
+ memset((void*)&g_rx_buf, 0xAA, sizeof(g_rx_buf));
+
+ rval = I2C_Slave_Receive(I2Cx, (uint8_t*)&g_rx_buf, &length, I2C_BLOCKING);
+ if( rval != I2C_Err_OK )
+ {
+ err("I2C slave RX fail !\n");
+ break;
+ }
+
+ rval = I2C_Slave_Transmit(I2Cx, (uint8_t*)&g_tx_buf, (uint16_t)sizeof(g_tx_buf), I2C_BLOCKING);
+ if( rval != I2C_Err_OK )
+ {
+ err("I2C slave TX fail !\n");
+ break;
+ }
+ #endif
+
+ /* comparative data */
+ syslog_dump_mem("rx: ", (uint32_t*)&g_rx_buf, sizeof(g_rx_buf), 0);
+
+ if( !memcmp(g_tx_buf, g_rx_buf, sizeof(g_tx_buf)) )
+ msg("done~~ \n\n");
+ else
+ {
+ err("Data is NOT match !\n");
+ break;
+ }
+
+ } while(1);
+
+
+ while(1);
+ return 0;
+ }
diff --git a/Examples/lptim/lptim_count/.cproject b/Examples/lptim/lptim_count/.cproject
index 21d0162..1a0019e 100644
--- a/Examples/lptim/lptim_count/.cproject
+++ b/Examples/lptim/lptim_count/.cproject
@@ -40,27 +40,28 @@
-
+
-
-
+
+
+
@@ -68,14 +69,14 @@
@@ -94,7 +95,7 @@
-
-
+
+
@@ -192,10 +193,10 @@
@@ -204,14 +205,14 @@
@@ -225,7 +226,7 @@
diff --git a/Examples/lptim/lptim_count/Project.nuproject b/Examples/lptim/lptim_count/Project.nuproject
index 0743ed2..0072223 100644
--- a/Examples/lptim/lptim_count/Project.nuproject
+++ b/Examples/lptim/lptim_count/Project.nuproject
@@ -7,7 +7,7 @@ SDK_CONFIG:
cmodel: medlow
extra_commonflags:
abi: ilp32e
- arch: rv32emac
+ arch: rv32ema_zba_zbb_zbs_zca_zcb_zcmp_zcmt_zicond
toolchain: gnu
extra_cflags:
extra_ldflags:
@@ -19,7 +19,7 @@ SDK_CONFIG:
cmodel: medlow
extra_commonflags:
abi: ilp32e
- arch: rv32emac
+ arch: rv32emac_zba_zbb_zbs
toolchain: gnu
extra_cflags:
extra_ldflags:
diff --git a/Examples/lptim/lptim_count/readme.md b/Examples/lptim/lptim_count/readme.md
index d8a0c2c..e569424 100644
--- a/Examples/lptim/lptim_count/readme.md
+++ b/Examples/lptim/lptim_count/readme.md
@@ -1,11 +1,11 @@
-tim count
+LPTIM count
---
-This example is used to run tim count function.
+This example is used to run LPTIM count function.
## Hardware and Software environment
-+ This example runs on PB5700 devices.
++ This example runs on PEC930 devices.
## How to use it ?
diff --git a/Examples/lptim/lptim_match_Interrupt/.cproject b/Examples/lptim/lptim_match_Interrupt/.cproject
index 21d0162..1a0019e 100644
--- a/Examples/lptim/lptim_match_Interrupt/.cproject
+++ b/Examples/lptim/lptim_match_Interrupt/.cproject
@@ -40,27 +40,28 @@
-
+
-
-
+
+
+
@@ -68,14 +69,14 @@
@@ -94,7 +95,7 @@
-
-
+
+
@@ -192,10 +193,10 @@
@@ -204,14 +205,14 @@
@@ -225,7 +226,7 @@
diff --git a/Examples/lptim/lptim_match_Interrupt/Project.nuproject b/Examples/lptim/lptim_match_Interrupt/Project.nuproject
index 0743ed2..0072223 100644
--- a/Examples/lptim/lptim_match_Interrupt/Project.nuproject
+++ b/Examples/lptim/lptim_match_Interrupt/Project.nuproject
@@ -7,7 +7,7 @@ SDK_CONFIG:
cmodel: medlow
extra_commonflags:
abi: ilp32e
- arch: rv32emac
+ arch: rv32ema_zba_zbb_zbs_zca_zcb_zcmp_zcmt_zicond
toolchain: gnu
extra_cflags:
extra_ldflags:
@@ -19,7 +19,7 @@ SDK_CONFIG:
cmodel: medlow
extra_commonflags:
abi: ilp32e
- arch: rv32emac
+ arch: rv32emac_zba_zbb_zbs
toolchain: gnu
extra_cflags:
extra_ldflags:
diff --git a/Examples/lptim/lptim_match_Interrupt/readme.md b/Examples/lptim/lptim_match_Interrupt/readme.md
index d6a2794..e97455a 100644
--- a/Examples/lptim/lptim_match_Interrupt/readme.md
+++ b/Examples/lptim/lptim_match_Interrupt/readme.md
@@ -1,11 +1,11 @@
-tim match and interrupt
+LPTIM match and interrupt
---
-This example is used to run tim match and interrupt function.
+This example is used to run LPTIM match and interrupt function.
## Hardware and Software environment
-+ This example runs on PB5700 devices.
++ This example runs on PEC930 devices.
## How to use it ?
diff --git a/Examples/lptim/lptim_match_Interrupt/src/main.c b/Examples/lptim/lptim_match_Interrupt/src/main.c
index 6812df2..1aed9e2 100644
--- a/Examples/lptim/lptim_match_Interrupt/src/main.c
+++ b/Examples/lptim/lptim_match_Interrupt/src/main.c
@@ -55,12 +55,16 @@
//=============================================================================
__INTERRUPT void LPTIMx_Handler(void)
{
+ SAVE_IRQ_CSR_CONTEXT();
+
if( LPTIM_GetFlagStatus(LPTIMx, LPTIM_Flag_Match0) )
{
LPTIM_ClearFlag(LPTIMx, LPTIM_Flag_Match0);
GPIO_TogglePin(CONFIG_TOGGLE_PORT, CONFIG_TOGGLE_PIN);
}
+
+ RESTORE_IRQ_CSR_CONTEXT();
return;
}
diff --git a/Examples/lptim/lptim_prescaler/.cproject b/Examples/lptim/lptim_prescaler/.cproject
deleted file mode 100644
index 21d0162..0000000
--- a/Examples/lptim/lptim_prescaler/.cproject
+++ /dev/null
@@ -1,293 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Examples/lptim/lptim_prescaler/.project b/Examples/lptim/lptim_prescaler/.project
deleted file mode 100644
index 2183c12..0000000
--- a/Examples/lptim/lptim_prescaler/.project
+++ /dev/null
@@ -1,54 +0,0 @@
-
-
- Project
-
-
-
-
-
- org.eclipse.cdt.managedbuilder.core.genmakebuilder
- clean,full,incremental,
-
-
-
-
- org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
- full,incremental,
-
-
-
-
-
- org.eclipse.cdt.core.cnature
- org.eclipse.cdt.managedbuilder.core.managedBuildNature
- org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
-
-
-
- Common
- 2
- PARENT-3-PROJECT_LOC/Common
-
-
- Drivers
- 2
- PARENT-3-PROJECT_LOC/Drivers
-
-
- Profiles
- 2
- PARENT-3-PROJECT_LOC/Tools/scripts/Profiles
-
-
-
-
- 0
-
- 6
-
- org.eclipse.ui.ide.multiFilter
- 1.0-name-matches-false-false-*.nuproject
-
-
-
-
diff --git a/Examples/lptim/lptim_prescaler/Project.nuproject b/Examples/lptim/lptim_prescaler/Project.nuproject
deleted file mode 100644
index 0743ed2..0000000
--- a/Examples/lptim/lptim_prescaler/Project.nuproject
+++ /dev/null
@@ -1,25 +0,0 @@
-SDK_CONFIG:
- Debug:
- core: N203E
- extra_asmflags:
- archext:
- extra_cxxflags:
- cmodel: medlow
- extra_commonflags:
- abi: ilp32e
- arch: rv32emac
- toolchain: gnu
- extra_cflags:
- extra_ldflags:
- Release:
- core: N203E
- extra_asmflags:
- archext:
- extra_cxxflags:
- cmodel: medlow
- extra_commonflags:
- abi: ilp32e
- arch: rv32emac
- toolchain: gnu
- extra_cflags:
- extra_ldflags:
diff --git a/Examples/lptim/lptim_prescaler/component.mk b/Examples/lptim/lptim_prescaler/component.mk
deleted file mode 100644
index b1b2bc6..0000000
--- a/Examples/lptim/lptim_prescaler/component.mk
+++ /dev/null
@@ -1,16 +0,0 @@
-#
-# component Makefile
-#
-
-
-C_SOURCES += \
- $(srctree)/$(PROJ)/src/isr.c \
- $(srctree)/$(PROJ)/src/main.c
-
-C_INCLUDES += -I$(srctree)/$(PROJ)/inc
-
-
-LIBS +=
-CFLAGS +=
-LDFLAGS +=
-LIBDIR +=
diff --git a/Examples/lptim/lptim_prescaler/inc/main.h b/Examples/lptim/lptim_prescaler/inc/main.h
deleted file mode 100644
index 6bc013b..0000000
--- a/Examples/lptim/lptim_prescaler/inc/main.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file main.h
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/08/29
- * @license
- * @description
- */
-
-#ifndef __main_H_wxBnwdPw_lq7D_H4I5_sHPp_uXof15pFLp4V__
-#define __main_H_wxBnwdPw_lq7D_H4I5_sHPp_uXof15pFLp4V__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-#include "hal_device.h"
-#include "syslog.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/Examples/lptim/lptim_prescaler/readme.md b/Examples/lptim/lptim_prescaler/readme.md
deleted file mode 100644
index 0fc3b97..0000000
--- a/Examples/lptim/lptim_prescaler/readme.md
+++ /dev/null
@@ -1,17 +0,0 @@
-tim prescaler
----
-
-This example is used to run tim prescaler function.
-
-## Hardware and Software environment
-
-+ This example runs on PB5700 devices.
-
-## How to use it ?
-
-### In order to make the program work, you must do the following:
-
-+ Open your preferred toolchain
-+ Rebuild all files and load your image into target memory
-+ Adjust the prescaler value to your desired value.
-+ Run the example
\ No newline at end of file
diff --git a/Examples/lptim/lptim_prescaler/src/isr.c b/Examples/lptim/lptim_prescaler/src/isr.c
deleted file mode 100644
index d19995f..0000000
--- a/Examples/lptim/lptim_prescaler/src/isr.c
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file isr.c
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/09/16
- * @license
- * @description
- */
-
-
-#include "isr.h"
-
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-
diff --git a/Examples/lvd_lvr/lvd_lvr/.cproject b/Examples/lvd_lvr/lvd_lvr/.cproject
new file mode 100644
index 0000000..1a0019e
--- /dev/null
+++ b/Examples/lvd_lvr/lvd_lvr/.cproject
@@ -0,0 +1,294 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Examples/adc/adc_verify_wr_rd_reg/.project b/Examples/lvd_lvr/lvd_lvr/.project
similarity index 100%
rename from Examples/adc/adc_verify_wr_rd_reg/.project
rename to Examples/lvd_lvr/lvd_lvr/.project
diff --git a/Examples/adc/adc_verify_wr_rd_reg/Project.nuproject b/Examples/lvd_lvr/lvd_lvr/Project.nuproject
similarity index 83%
rename from Examples/adc/adc_verify_wr_rd_reg/Project.nuproject
rename to Examples/lvd_lvr/lvd_lvr/Project.nuproject
index 0743ed2..0072223 100644
--- a/Examples/adc/adc_verify_wr_rd_reg/Project.nuproject
+++ b/Examples/lvd_lvr/lvd_lvr/Project.nuproject
@@ -7,7 +7,7 @@ SDK_CONFIG:
cmodel: medlow
extra_commonflags:
abi: ilp32e
- arch: rv32emac
+ arch: rv32ema_zba_zbb_zbs_zca_zcb_zcmp_zcmt_zicond
toolchain: gnu
extra_cflags:
extra_ldflags:
@@ -19,7 +19,7 @@ SDK_CONFIG:
cmodel: medlow
extra_commonflags:
abi: ilp32e
- arch: rv32emac
+ arch: rv32emac_zba_zbb_zbs
toolchain: gnu
extra_cflags:
extra_ldflags:
diff --git a/Examples/adc/adc_verify_wr_rd_reg/component.mk b/Examples/lvd_lvr/lvd_lvr/component.mk
similarity index 100%
rename from Examples/adc/adc_verify_wr_rd_reg/component.mk
rename to Examples/lvd_lvr/lvd_lvr/component.mk
diff --git a/Examples/flash/flash_set_latency/inc/isr.h b/Examples/lvd_lvr/lvd_lvr/inc/isr.h
similarity index 100%
rename from Examples/flash/flash_set_latency/inc/isr.h
rename to Examples/lvd_lvr/lvd_lvr/inc/isr.h
diff --git a/Examples/adc/adc_verify_wr_rd_reg/inc/main.h b/Examples/lvd_lvr/lvd_lvr/inc/main.h
similarity index 100%
rename from Examples/adc/adc_verify_wr_rd_reg/inc/main.h
rename to Examples/lvd_lvr/lvd_lvr/inc/main.h
diff --git a/Examples/lvd_lvr/lvd_lvr/readme.md b/Examples/lvd_lvr/lvd_lvr/readme.md
new file mode 100644
index 0000000..5f7e2ed
--- /dev/null
+++ b/Examples/lvd_lvr/lvd_lvr/readme.md
@@ -0,0 +1,21 @@
+## LVD & LVR
+
+> This example is used to run lvd/lvr function.
+
++ Select Test Items
+ ```
+ // in main.c
+ /**
+ * Enable LVD and Select LVD Voltage
+ */
+ #define LVD_TEST_EN
+ #define LVD_VOL_SET AMISC_LVDVoltage_4_3V
+
+ /**
+ * Enable LVR and Select LVR Voltage
+ */
+ //#define LVR_TEST_EN
+ //#define LVR_VOL_SET AMISC_LVRVoltage_3_7V
+ ```
+
+> Run Code,and adjust VDD, then observe the waveform with an oscilloscope
\ No newline at end of file
diff --git a/Examples/comp/Compare_for_TI/src/isr.c b/Examples/lvd_lvr/lvd_lvr/src/isr.c
similarity index 100%
rename from Examples/comp/Compare_for_TI/src/isr.c
rename to Examples/lvd_lvr/lvd_lvr/src/isr.c
diff --git a/Examples/lptim/lptim_prescaler/src/main.c b/Examples/lvd_lvr/lvd_lvr/src/main.c
similarity index 52%
rename from Examples/lptim/lptim_prescaler/src/main.c
rename to Examples/lvd_lvr/lvd_lvr/src/main.c
index 344d077..ef6af4d 100644
--- a/Examples/lptim/lptim_prescaler/src/main.c
+++ b/Examples/lvd_lvr/lvd_lvr/src/main.c
@@ -16,26 +16,17 @@
//=============================================================================
// Constant Definition
//=============================================================================
+/**
+ * Enable LVD and Select LVD Voltage
+ */
+#define LVD_TEST_EN
+#define LVD_VOL_SET AMISC_LVDVoltage_4_3V
-#define CONFIG_USE_LPTIM
-// #define CONFIG_USE_TIM0
-// #define CONFIG_USE_TIM1
-
-#if defined(CONFIG_USE_LPTIM)
- #define LPTIMx LPTIM
- #define CONFIG_PERI_NAME "LpTim"
-#elif defined(CONFIG_USE_TIM0)
- #define LPTIMx TIM0
- #define CONFIG_PERI_NAME "Tim0"
-#elif defined(CONFIG_USE_TIM1)
- #define LPTIMx TIM1
- #define CONFIG_PERI_NAME "Tim1"
-#endif
-
-
-/* Use PA2 to toggle */
-#define CONFIG_TOGGLE_PORT GPIOA
-#define CONFIG_TOGGLE_PIN GPIO_Pin_02
+/**
+ * Enable LVR and Select LVR Voltage
+ */
+//#define LVR_TEST_EN
+//#define LVR_VOL_SET AMISC_LVRVoltage_3_7V
//=============================================================================
// Macro Definition
//=============================================================================
@@ -57,10 +48,11 @@
//=============================================================================
int main(void)
{
- uint32_t set_prescaler = 0;
- LPTIM_InitTypeDef Init = {0};
SYSCFG_ClkInitTypeDef SysClkInit = {0};
+ GPIO_InitTypeDef GPIO_InitStruct = {0};
+ AMISC_LVDRInitTypeDef LVD_LVR_InitStruct = {0};
+ /* Configure system clock */
SysClkInit.ClkSource = SYSCFG_ClkSrc_HSI;
SYSCFG_SysClkConfig(&SysClkInit);
@@ -68,39 +60,46 @@ int main(void)
syslog_init();
- info("This is a demo project to set %s prescaler\n",
- CONFIG_PERI_NAME);
+ /* Enable AMISC Module and enable vbuf */
+ AMISC_Init();
+ AMISC_Vbuf_Enable();
- {// configure I/O to toggle
- GPIO_InitTypeDef GPIO_InitStruct = {0};
- GPIO_InitStruct.GPIO_Pin = CONFIG_TOGGLE_PIN;
- GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT;
- GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL;
- GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;
- GPIO_Init(CONFIG_TOGGLE_PORT, &GPIO_InitStruct);
- }
+ /* Enable and Configure the parameters of LVD/LVR */
+#if defined(LVD_TEST_EN)
+ AMISC_LVD_Enable();
+ LVD_LVR_InitStruct.LVD_Voltage = LVD_VOL_SET;
+#endif
- set_prescaler = 3;//23; //ftim = fsys/(pr+1)
+#if defined(LVR_TEST_EN)
+ AMISC_LVR_Enable();
+ LVD_LVR_InitStruct.LVR_Voltage = LVR_VOL_SET;
+#endif
- Init.LPTIM_Prescaler = set_prescaler;
- Init.LPTIM_ClockSource = LPTIM_CLK_Src_SysClk;
- Init.LPTIM_MatchMode = LPTIM_MatchMode_Normal;
- Init.LPTIM_MatchValue = 2000;
+ AMISC_LVD_LVR_Config(&LVD_LVR_InitStruct);
- LPTIM_Init(LPTIMx, &Init);
+ info("%s %s\nThis is a demo project of LVD/LVR test\n", __DATE__, __TIME__);
- LPTIM_Enable(LPTIMx);
+ /* Configure GPIO, pin is used to display the status of LVD/LVR */
+ GPIO_InitStruct.GPIO_Pin = GPIO_Pin_00 | GPIO_Pin_03;
+ GPIO_InitStruct.GPIO_Pin = GPIO_PIN_All;
+ GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT;
+ GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL;
+ GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;
+ GPIO_Init(GPIOA , &GPIO_InitStruct);
while(1)
{
- if( LPTIM_GetFlagStatus(LPTIMx, LPTIM_Flag_Match0) )
- {
- LPTIM_ClearFlag(LPTIMx, LPTIM_Flag_Match0);
+#if defined(LVR_TEST_EN)
+ /* Observe LVR action through pin */
+ GPIO_TogglePin(GPIOA, GPIO_Pin_00);
+#endif
+
+#if defined(LVD_TEST_EN)
+ /* VDD < LVD: pin out low; VDD > LVD:pin out high */
+ GPIO_WriteBit(GPIOA, GPIO_Pin_03, (AMISC_GetLVDFlagStatus() ? GPIO_PIN_HIGH : GPIO_PIN_LOW));
+#endif
+ sys_delay(1);
- GPIO_TogglePin(CONFIG_TOGGLE_PORT, CONFIG_TOGGLE_PIN);
- }
}
-
-
return 0;
}
diff --git a/Examples/pga/pga_src_internal/.cproject b/Examples/pga/pga_src_internal/.cproject
new file mode 100644
index 0000000..1a0019e
--- /dev/null
+++ b/Examples/pga/pga_src_internal/.cproject
@@ -0,0 +1,294 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Examples/amisc/dac_test/.project b/Examples/pga/pga_src_internal/.project
similarity index 100%
rename from Examples/amisc/dac_test/.project
rename to Examples/pga/pga_src_internal/.project
diff --git a/Examples/pga/pga_src_internal/Project.nuproject b/Examples/pga/pga_src_internal/Project.nuproject
new file mode 100644
index 0000000..0072223
--- /dev/null
+++ b/Examples/pga/pga_src_internal/Project.nuproject
@@ -0,0 +1,25 @@
+SDK_CONFIG:
+ Debug:
+ core: N203E
+ extra_asmflags:
+ archext:
+ extra_cxxflags:
+ cmodel: medlow
+ extra_commonflags:
+ abi: ilp32e
+ arch: rv32ema_zba_zbb_zbs_zca_zcb_zcmp_zcmt_zicond
+ toolchain: gnu
+ extra_cflags:
+ extra_ldflags:
+ Release:
+ core: N203E
+ extra_asmflags:
+ archext:
+ extra_cxxflags:
+ cmodel: medlow
+ extra_commonflags:
+ abi: ilp32e
+ arch: rv32emac_zba_zbb_zbs
+ toolchain: gnu
+ extra_cflags:
+ extra_ldflags:
diff --git a/Examples/amisc/dac_test/component.mk b/Examples/pga/pga_src_internal/component.mk
similarity index 100%
rename from Examples/amisc/dac_test/component.mk
rename to Examples/pga/pga_src_internal/component.mk
diff --git a/Examples/flash/flash_sram_run/inc/isr.h b/Examples/pga/pga_src_internal/inc/isr.h
similarity index 100%
rename from Examples/flash/flash_sram_run/inc/isr.h
rename to Examples/pga/pga_src_internal/inc/isr.h
diff --git a/Examples/amisc/dac_test/inc/main.h b/Examples/pga/pga_src_internal/inc/main.h
similarity index 100%
rename from Examples/amisc/dac_test/inc/main.h
rename to Examples/pga/pga_src_internal/inc/main.h
diff --git a/Examples/pga/pga_src_internal/readme.md b/Examples/pga/pga_src_internal/readme.md
new file mode 100644
index 0000000..425e7ec
--- /dev/null
+++ b/Examples/pga/pga_src_internal/readme.md
@@ -0,0 +1,114 @@
+pga_src_internal
+---
+
+This example is used to demo the PGA module which uses internal signals as input/output
+> Only PGA0 supports internal source
+
++ Configure the amplifier gain
+
+ ```c
+ // at main.c
+ /**
+ * The amplify gain, @ref OPAMP_PGAGainTypeDef
+ * ps. OPAMP_PGAGain_1 ~ OPAMP_PGAGain_16
+ */
+ #define CONFIG_AMP_GAIN OPAMP_PGAGain_1
+ ```
+
++ Configure the reference mVoltage of ADC to convert the sampled value to mVoltage
+
+ ```c
+ // at main.c
+ /**
+ * The reference mVoltage of ADC on board
+ */
+ #define CONFIG_ADC_REF_mVOLTAGE 3300
+ ```
+
+
+## Log
+
+Use serial port with baudrate 115200, 8bit, no parity check.
+
++ Internal signal
+ > + Temperature: Analog signal output to PA8 (0.686 V)
+ > + DAC0 : Analog signal output to PA8 (1.627 V)
+ > + DAC1 : Analog signal output to PA8 (1.659 V)
+ > + VBuf 1.5v : Analog signal output to PA8 (1.511 V)
+ > + VDDL : Analog signal output to PA8 (1.521 V)
+ > + VSS : Analog signal output to PA8 (0.002 V)
+ > + VDD : Analog signal output to PA8 (3.288 V)
+
+ ```
+ Oct 1 2025 15:48:50
+ Run PGA-0 (Programmable Gain Amplifier) internal source
+ The gain 1
+ VinP= Internal signal
+ VinM= GND
+ Vout= ADC AIN0
+
+ Set internal signal: Temperature
+ ADC samples the PGA Vout= 0x00000353 (685 mV)
+
+ Set internal signal: DAC 0
+ ADC samples the PGA Vout= 0x000007D7 (1616 mV)
+
+ Set internal signal: DAC 1
+ ADC samples the PGA Vout= 0x000007F0 (1637 mV)
+
+ Set internal signal: VBuf 1.5
+ ADC samples the PGA Vout= 0x0000074C (1504 mV)
+
+ Set internal signal: VDDL
+ ADC samples the PGA Vout= 0x00000757 (1513 mV)
+
+ Set internal signal: VSS
+ ADC samples the PGA Vout= 0x00000006 (4 mV)
+
+ Set internal signal: VDD
+ ADC samples the PGA Vout= 0x00000FEF (3286 mV)
+
+ Set internal signal: Temperature
+ ADC samples the PGA Vout= 0x0000034F (682 mV)
+
+ Set internal signal: DAC 0
+ ADC samples the PGA Vout= 0x000007CE (1609 mV)
+
+ Set internal signal: DAC 1
+ ADC samples the PGA Vout= 0x00000822 (1677 mV)
+
+ Set internal signal: VBuf 1.5
+ ADC samples the PGA Vout= 0x0000074F (1507 mV)
+
+ Set internal signal: VDDL
+ ADC samples the PGA Vout= 0x0000074C (1504 mV)
+
+ Set internal signal: VSS
+ ADC samples the PGA Vout= 0x00000004 (3 mV)
+
+ Set internal signal: VDD
+ ADC samples the PGA Vout= 0x00000FED (3284 mV)
+
+ Set internal signal: Temperature
+ ADC samples the PGA Vout= 0x0000034F (682 mV)
+
+ Set internal signal: DAC 0
+ ADC samples the PGA Vout= 0x000007E2 (1625 mV)
+
+ Set internal signal: DAC 1
+ ADC samples the PGA Vout= 0x000007F2 (1638 mV)
+
+ Set internal signal: VBuf 1.5
+ ADC samples the PGA Vout= 0x00000747 (1500 mV)
+
+ Set internal signal: VDDL
+ ADC samples the PGA Vout= 0x00000755 (1512 mV)
+
+ Set internal signal: VSS
+ ADC samples the PGA Vout= 0x00000008 (6 mV)
+
+ Set internal signal: VDD
+ ADC samples the PGA Vout= 0x00000FF6 (3291 mV)
+
+ ...
+ ```
diff --git a/Examples/comp/comp_test/src/isr.c b/Examples/pga/pga_src_internal/src/isr.c
similarity index 100%
rename from Examples/comp/comp_test/src/isr.c
rename to Examples/pga/pga_src_internal/src/isr.c
diff --git a/Examples/pga/pga_src_internal/src/main.c b/Examples/pga/pga_src_internal/src/main.c
new file mode 100644
index 0000000..d924cb6
--- /dev/null
+++ b/Examples/pga/pga_src_internal/src/main.c
@@ -0,0 +1,188 @@
+/**
+ * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
+ */
+/** @file main.c
+ *
+ * @author Wei-Lun Hsu
+ * @version 0.1
+ * @date 2024/08/29
+ * @license
+ * @description
+ */
+
+
+#include "main.h"
+#include "isr.h"
+//=============================================================================
+// Constant Definition
+//=============================================================================
+/**
+ * The reference mVoltage of ADC on board
+ */
+#define CONFIG_ADC_REF_mVOLTAGE 3300 // 5000
+
+/**
+ * The amplify gain, @ref OPAMP_PGAGainTypeDef
+ * ps. OPAMP_PGAGain_1 ~ OPAMP_PGAGain_16
+ */
+#define CONFIG_AMP_GAIN OPAMP_PGAGain_1
+
+
+#define OPAMPx OPAMP0
+#define CONFIG_ADC_TARGET_CHANNEL ADC_Channel_OPA0_O
+
+
+typedef enum internal_src
+{
+ INTERNAL_SRC_TEMPERATURE,
+ INTERNAL_SRC_DAC0,
+ INTERNAL_SRC_DAC1,
+ INTERNAL_SRC_VBUF_1P5V,
+ INTERNAL_SRC_VDDL,
+ INTERNAL_SRC_VSS,
+ INTERNAL_SRC_VDD,
+
+} internal_src_t;
+//=============================================================================
+// Macro Definition
+//=============================================================================
+
+//=============================================================================
+// Structure Definition
+//=============================================================================
+
+//=============================================================================
+// Global Data Definition
+//=============================================================================
+
+static AMISC_InternalSrcTypeDef g_VinP_Src = AMISC_InternalSrc_NONE;
+static AMISC_InternalSrcTypeDef g_InternalSrc[] =
+{
+ AMISC_InternalSrc_TEMP,
+ AMISC_InternalSrc_DAC0,
+ AMISC_InternalSrc_DAC1,
+ AMISC_InternalSrc_VBuf_1P5V,
+ AMISC_InternalSrc_VDDL,
+ AMISC_InternalSrc_VSS,
+ AMISC_InternalSrc_VDD,
+};
+
+
+//=============================================================================
+// Private Function Definition
+//=============================================================================
+
+//=============================================================================
+// Public Function Definition
+//=============================================================================
+int main(void)
+{
+ { /* Configure system clock */
+ SYSCFG_ClkInitTypeDef SysClkInit = {0};
+
+ SysClkInit.ClkSource = SYSCFG_ClkSrc_HSI;
+ SYSCFG_SysClkConfig(&SysClkInit);
+ }
+
+ sys_config_systick(SYS_TICK_1_MS);
+
+ syslog_init();
+
+ info("%s %s\nRun PGA-%d (Programmable Gain Amplifier) internal source\n",
+ __DATE__, __TIME__, (OPAMPx == OPAMP0) ? 0 : 1);
+
+ msg(" The gain %d\n",
+ (CONFIG_AMP_GAIN == OPAMP_PGAGain_2 ) ? 2 :
+ (CONFIG_AMP_GAIN == OPAMP_PGAGain_3 ) ? 3 :
+ (CONFIG_AMP_GAIN == OPAMP_PGAGain_4 ) ? 4 :
+ (CONFIG_AMP_GAIN == OPAMP_PGAGain_5 ) ? 5 :
+ (CONFIG_AMP_GAIN == OPAMP_PGAGain_6 ) ? 6 :
+ (CONFIG_AMP_GAIN == OPAMP_PGAGain_7 ) ? 7 :
+ (CONFIG_AMP_GAIN == OPAMP_PGAGain_8 ) ? 8 :
+ (CONFIG_AMP_GAIN == OPAMP_PGAGain_9 ) ? 9 :
+ (CONFIG_AMP_GAIN == OPAMP_PGAGain_10) ? 10 :
+ (CONFIG_AMP_GAIN == OPAMP_PGAGain_11) ? 11 :
+ (CONFIG_AMP_GAIN == OPAMP_PGAGain_12) ? 12 :
+ (CONFIG_AMP_GAIN == OPAMP_PGAGain_13) ? 13 :
+ (CONFIG_AMP_GAIN == OPAMP_PGAGain_14) ? 14 :
+ (CONFIG_AMP_GAIN == OPAMP_PGAGain_15) ? 15 :
+ (CONFIG_AMP_GAIN == OPAMP_PGAGain_16) ? 16 :
+ 1);
+
+ msg(" VinP= Internal signal\n");
+ msg(" VinM= GND\n");
+ msg(" Vout= ADC AIN%d\n", 31ul - HAL_CLZ(CONFIG_ADC_TARGET_CHANNEL));
+
+ { /* Configure ADC */
+ ADC_InitTypeDef init = {0};
+
+ ADC_StructInit(&init);
+
+ init.SelChannels = CONFIG_ADC_TARGET_CHANNEL;
+ init.IsSoftTrig = true;
+ ADC_Init(ADC0, &init);
+ }
+
+ while(1)
+ {
+ static int cnt = 0;
+ OPAMP_InitTypeDef init = {0};
+ uint32_t ConvValue = 0;
+
+ /* Configure OPAMP module */
+ init.OPAMP_VinP = OPAMP_VinP_Internal;
+ init.OPAMP_VinM = OPAMP_VinM_GND;
+ init.OPAMP_Vout = OPAMP_Vout_None;
+ init.OPAMP_Gain = CONFIG_AMP_GAIN;
+
+ if( init.OPAMP_VinP == OPAMP_VinP_Internal )
+ {
+ uint16_t dac_step = 512; // 0 ~ 1023 (10-bits)
+
+ g_VinP_Src = g_InternalSrc[cnt % (sizeof(g_InternalSrc)/sizeof(g_InternalSrc[0]))];
+
+ log_color(SLOG_GREEN, "\nSet internal signal: %s\n",
+ (g_VinP_Src == AMISC_InternalSrc_TEMP ) ? "Temperature" :
+ (g_VinP_Src == AMISC_InternalSrc_DAC0 ) ? "DAC 0" :
+ (g_VinP_Src == AMISC_InternalSrc_DAC1 ) ? "DAC 1" :
+ (g_VinP_Src == AMISC_InternalSrc_VBuf_1P5V) ? "VBuf 1.5" :
+ (g_VinP_Src == AMISC_InternalSrc_VDDL ) ? "VDDL" :
+ (g_VinP_Src == AMISC_InternalSrc_VSS ) ? "VSS" :
+ (g_VinP_Src == AMISC_InternalSrc_VDD ) ? "VDD" :
+ "None");
+
+ /* Select internal source as VinP */
+ AMISC_Sel_PGA_VinP_Src(g_VinP_Src);
+ AMISC_OutInternalSignalToIO(g_VinP_Src, true);
+
+ if( g_VinP_Src == AMISC_InternalSrc_DAC0 )
+ {
+ AMISC_DAC0_Config(dac_step);
+ AMISC_DAC0_Enable();
+ }
+ else if( g_VinP_Src == AMISC_InternalSrc_DAC1 )
+ {
+ AMISC_DAC1_Config(dac_step + 10);
+ AMISC_DAC1_Enable();
+ }
+ }
+
+ OPAMP_Init(OPAMPx, &init);
+
+ OPAMP_Enable(OPAMPx);
+
+ sys_busy_wait(60*1000);
+
+ ADC_Start(ADC0);
+
+ ConvValue = ADC_GetChannelConvValue(ADC0, CONFIG_ADC_TARGET_CHANNEL);
+
+ msg(" ADC samples the PGA Vout= 0x%08X (%d mV)\n",
+ ConvValue, ((ConvValue * CONFIG_ADC_REF_mVOLTAGE) >> 12));
+
+ cnt++;
+
+ sys_delay(1000);
+ }
+ return 0;
+}
diff --git a/Examples/pga/pga_src_io/.cproject b/Examples/pga/pga_src_io/.cproject
new file mode 100644
index 0000000..1a0019e
--- /dev/null
+++ b/Examples/pga/pga_src_io/.cproject
@@ -0,0 +1,294 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Examples/comp/Compare_GpioVsVref/.project b/Examples/pga/pga_src_io/.project
similarity index 100%
rename from Examples/comp/Compare_GpioVsVref/.project
rename to Examples/pga/pga_src_io/.project
diff --git a/Examples/pga/pga_src_io/Project.nuproject b/Examples/pga/pga_src_io/Project.nuproject
new file mode 100644
index 0000000..0072223
--- /dev/null
+++ b/Examples/pga/pga_src_io/Project.nuproject
@@ -0,0 +1,25 @@
+SDK_CONFIG:
+ Debug:
+ core: N203E
+ extra_asmflags:
+ archext:
+ extra_cxxflags:
+ cmodel: medlow
+ extra_commonflags:
+ abi: ilp32e
+ arch: rv32ema_zba_zbb_zbs_zca_zcb_zcmp_zcmt_zicond
+ toolchain: gnu
+ extra_cflags:
+ extra_ldflags:
+ Release:
+ core: N203E
+ extra_asmflags:
+ archext:
+ extra_cxxflags:
+ cmodel: medlow
+ extra_commonflags:
+ abi: ilp32e
+ arch: rv32emac_zba_zbb_zbs
+ toolchain: gnu
+ extra_cflags:
+ extra_ldflags:
diff --git a/Examples/comp/Compare_GpioVsVref/component.mk b/Examples/pga/pga_src_io/component.mk
similarity index 100%
rename from Examples/comp/Compare_GpioVsVref/component.mk
rename to Examples/pga/pga_src_io/component.mk
diff --git a/Examples/flash/flash_status_flags/inc/isr.h b/Examples/pga/pga_src_io/inc/isr.h
similarity index 100%
rename from Examples/flash/flash_status_flags/inc/isr.h
rename to Examples/pga/pga_src_io/inc/isr.h
diff --git a/Examples/comp/Compare_GpioVsVref/inc/main.h b/Examples/pga/pga_src_io/inc/main.h
similarity index 100%
rename from Examples/comp/Compare_GpioVsVref/inc/main.h
rename to Examples/pga/pga_src_io/inc/main.h
diff --git a/Examples/pga/pga_src_io/readme.md b/Examples/pga/pga_src_io/readme.md
new file mode 100644
index 0000000..fe3a0c5
--- /dev/null
+++ b/Examples/pga/pga_src_io/readme.md
@@ -0,0 +1,108 @@
+pga_src_io
+---
+
+This example is used to demo the PGA module which uses GPIO Pins as input/output
+
++ Select PGA0 or PGA1
+
+ ```c
+ // at main.c
+ /**
+ * Select the terget OPAMP module
+ * + unmark CONFIG_USE_OPAMP_0 => OPAMP0
+ * + mark CONFIG_USE_OPAMP_0 => OPAMP1
+ */
+ #define CONFIG_USE_OPAMP_0
+ ```
+
++ Configure the amplifier gain
+
+ ```c
+ // at main.c
+ /**
+ * The amplify gain, @ref OPAMP_PGAGainTypeDef
+ * ps. OPAMP_PGAGain_1 ~ OPAMP_PGAGain_16
+ */
+ #define CONFIG_AMP_GAIN OPAMP_PGAGain_1
+ ```
+
++ Configure the reference mVoltage of ADC to convert the sampled value to mVoltage
+
+ ```c
+ // at main.c
+ /**
+ * The reference mVoltage of ADC on board
+ */
+ #define CONFIG_ADC_REF_mVOLTAGE 3300
+ ```
+
++ Configure VinM to use internal ground
+
+ ```
+ // at main.c
+ #define CONFIG_SET_OPAMP_VINM_GND 1
+ ```
+
+## Log
+
+Use serial port with baudrate 115200, 8bit, no parity check.
+
++ Use OPAmp0 and PA8 links to VDD/VSS
+
+ ```
+ Oct 1 2025 14:25:16
+ Run PGA-0 (Programmable Gain Amplifier)
+ The gain 1
+ VinP= PA8
+ VinM= GND
+ Vout= ADC AIN0 <--- Vout directly links to AIN0
+ ADC samples the PGA Vout= 0x08E6 (1835 mV)
+ ADC samples the PGA Vout= 0x080D (1660 mV)
+ ADC samples the PGA Vout= 0x061F (1262 mV)
+ ADC samples the PGA Vout= 0x0590 (1147 mV)
+ ADC samples the PGA Vout= 0x0E02 (2889 mV)
+ ADC samples the PGA Vout= 0x0FFB (3295 mV) <--- link VinP to VDD
+ ADC samples the PGA Vout= 0x0FFB (3295 mV)
+ ADC samples the PGA Vout= 0x0FFB (3295 mV)
+ ADC samples the PGA Vout= 0x0FFA (3295 mV)
+ ADC samples the PGA Vout= 0x0BB2 (2412 mV)
+ ADC samples the PGA Vout= 0x0003 (2 mV) <--- link VinP to VSS
+ ADC samples the PGA Vout= 0x0001 (0 mV)
+ ADC samples the PGA Vout= 0x0002 (1 mV)
+ ADC samples the PGA Vout= 0x0003 (2 mV)
+ ```
+
++ Use OPAmp0 and PA8 links to VDD/VSS
+ > ADC samples AIN9 (PA7)
+ >> There is an impedance between Vout and AIN9(PA7).
+ As this result, the ADC sample value is difference with `Vout = AIN0` case
+
+ ```
+ Oct 1 2025 14:30:09
+ Run PGA-0 (Programmable Gain Amplifier)
+ The gain 1
+ VinP= PA8
+ VinM= GND
+ Vout= PA7 <--- Vout to PA7
+ ADC samples the PGA Vout= 0x0110 (219 mV)
+ ADC samples the PGA Vout= 0x0056 (69 mV) <--- link VinP to VSS
+ ADC samples the PGA Vout= 0x0058 (70 mV)
+ ADC samples the PGA Vout= 0x0059 (71 mV)
+ ADC samples the PGA Vout= 0x0062 (78 mV)
+ ADC samples the PGA Vout= 0x002B (34 mV)
+ ADC samples the PGA Vout= 0x0038 (45 mV)
+ ADC samples the PGA Vout= 0x0057 (70 mV)
+ ADC samples the PGA Vout= 0x0064 (80 mV)
+ ADC samples the PGA Vout= 0x0029 (33 mV)
+ ADC samples the PGA Vout= 0x0031 (39 mV)
+ ADC samples the PGA Vout= 0x0590 (1147 mV)
+ ADC samples the PGA Vout= 0x0ADB (2238 mV)
+ ADC samples the PGA Vout= 0x0B38 (2313 mV)
+ ADC samples the PGA Vout= 0x0ECA (3050 mV)
+ ADC samples the PGA Vout= 0x0F2F (3131 mV) <--- link VinP to VDD
+ ADC samples the PGA Vout= 0x0F58 (3164 mV)
+ ADC samples the PGA Vout= 0x0F68 (3177 mV)
+ ADC samples the PGA Vout= 0x0F43 (3147 mV)
+ ADC samples the PGA Vout= 0x0F35 (3136 mV)
+ ...
+ ```
\ No newline at end of file
diff --git a/Examples/flash/flash_prog_erase_nvr/src/isr.c b/Examples/pga/pga_src_io/src/isr.c
similarity index 100%
rename from Examples/flash/flash_prog_erase_nvr/src/isr.c
rename to Examples/pga/pga_src_io/src/isr.c
diff --git a/Examples/pga/pga_src_io/src/main.c b/Examples/pga/pga_src_io/src/main.c
new file mode 100644
index 0000000..912567a
--- /dev/null
+++ b/Examples/pga/pga_src_io/src/main.c
@@ -0,0 +1,220 @@
+/**
+ * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
+ */
+/** @file main.c
+ *
+ * @author Wei-Lun Hsu
+ * @version 0.1
+ * @date 2024/08/29
+ * @license
+ * @description
+ */
+
+
+#include "main.h"
+#include "isr.h"
+//=============================================================================
+// Constant Definition
+//=============================================================================
+#define CONFIG_SET_OPAMP_VINM_GND 1
+
+/**
+ * The reference mVoltage of ADC on board
+ */
+#define CONFIG_ADC_REF_mVOLTAGE 3300 // 5000
+
+/**
+ * Select the terget OPAMP module
+ * + unmark CONFIG_USE_OPAMP_0 => OPAMP0
+ * + mark CONFIG_USE_OPAMP_0 => OPAMP1
+ */
+#define CONFIG_USE_OPAMP_0
+
+/**
+ * The amplify gain, @ref OPAMP_PGAGainTypeDef
+ * ps. OPAMP_PGAGain_1 ~ OPAMP_PGAGain_16
+ */
+#define CONFIG_AMP_GAIN OPAMP_PGAGain_1
+
+
+#if defined(CONFIG_USE_OPAMP_0)
+ #define OPAMPx OPAMP0
+
+ #define CONFIG_OPAMPx_VinP_IO_PORT GPIOA
+ #define CONFIG_OPAMPx_VinP_IO_PIN GPIO_Pin_08
+
+ #define CONFIG_OPAMPx_VinM_IO_PORT GPIOA
+ #define CONFIG_OPAMPx_VinM_IO_PIN GPIO_Pin_09
+
+ #define CONFIG_OPAMPx_Vout_IO_PORT GPIOA
+ #define CONFIG_OPAMPx_Vout_IO_PIN GPIO_Pin_07
+
+ #define CONFIG_ADC_TARGET_CHANNEL ADC_Channel_OPA0_O
+ // #define CONFIG_ADC_TARGET_CHANNEL ADC_Channel_09
+#else
+ #define OPAMPx OPAMP1
+
+ #define CONFIG_OPAMPx_VinP_IO_PORT GPIOA
+ #define CONFIG_OPAMPx_VinP_IO_PIN GPIO_Pin_11
+
+ #define CONFIG_OPAMPx_VinM_IO_PORT GPIOA
+ #define CONFIG_OPAMPx_VinM_IO_PIN GPIO_Pin_10
+
+ #define CONFIG_OPAMPx_Vout_IO_PORT GPIOA
+ #define CONFIG_OPAMPx_Vout_IO_PIN GPIO_Pin_13
+
+ #define CONFIG_ADC_TARGET_CHANNEL ADC_Channel_OPA1_O
+ // #define CONFIG_ADC_TARGET_CHANNEL ADC_Channel_07
+#endif
+//=============================================================================
+// Macro Definition
+//=============================================================================
+
+//=============================================================================
+// Structure Definition
+//=============================================================================
+
+//=============================================================================
+// Global Data Definition
+//=============================================================================
+
+//=============================================================================
+// Private Function Definition
+//=============================================================================
+static void
+_Log_IO_Msg(char *pPrefix, GPIO_Type *pHGpio, GPIO_PinTypeDef pin)
+{
+ int pin_idx = 0;
+
+ pin_idx = 31 - HAL_CLZ(pin);
+ msg("%s P%s%d\n", pPrefix,
+ (pHGpio == GPIOB) ? "B" : "A",
+ pin_idx);
+ return;
+}
+
+static int
+_Config_PGA_IO(void)
+{
+ GPIO_InitTypeDef GPIO_InitStruct = {0};
+
+ // VinP
+ GPIO_InitStruct.GPIO_Pin = CONFIG_OPAMPx_VinP_IO_PIN;
+ GPIO_InitStruct.GPIO_Mode = GPIO_Mode_ANAL;
+ GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL;
+ GPIO_Init(CONFIG_OPAMPx_VinP_IO_PORT , &GPIO_InitStruct);
+
+ // VinM
+ GPIO_InitStruct.GPIO_Pin = CONFIG_OPAMPx_VinM_IO_PIN;
+ GPIO_Init(CONFIG_OPAMPx_VinM_IO_PORT , &GPIO_InitStruct);
+
+ // Vout
+ if( CONFIG_ADC_TARGET_CHANNEL != ADC_Channel_OPA0_O &&
+ CONFIG_ADC_TARGET_CHANNEL != ADC_Channel_OPA1_O )
+ {
+ GPIO_InitStruct.GPIO_Pin = CONFIG_OPAMPx_Vout_IO_PIN;
+ GPIO_Init(CONFIG_OPAMPx_Vout_IO_PORT , &GPIO_InitStruct);
+ }
+ return 0;
+}
+//=============================================================================
+// Public Function Definition
+//=============================================================================
+int main(void)
+{
+ { /* Configure system clock */
+ SYSCFG_ClkInitTypeDef SysClkInit = {0};
+
+ SysClkInit.ClkSource = SYSCFG_ClkSrc_HSI;
+ SYSCFG_SysClkConfig(&SysClkInit);
+ }
+
+ sys_config_systick(SYS_TICK_1_MS);
+
+ syslog_init();
+
+ info("%s %s\nRun PGA-%d (Programmable Gain Amplifier)\n",
+ __DATE__, __TIME__, (OPAMPx == OPAMP0) ? 0 : 1);
+
+ msg(" The gain %d\n",
+ (CONFIG_AMP_GAIN == OPAMP_PGAGain_2 ) ? 2 :
+ (CONFIG_AMP_GAIN == OPAMP_PGAGain_3 ) ? 3 :
+ (CONFIG_AMP_GAIN == OPAMP_PGAGain_4 ) ? 4 :
+ (CONFIG_AMP_GAIN == OPAMP_PGAGain_5 ) ? 5 :
+ (CONFIG_AMP_GAIN == OPAMP_PGAGain_6 ) ? 6 :
+ (CONFIG_AMP_GAIN == OPAMP_PGAGain_7 ) ? 7 :
+ (CONFIG_AMP_GAIN == OPAMP_PGAGain_8 ) ? 8 :
+ (CONFIG_AMP_GAIN == OPAMP_PGAGain_9 ) ? 9 :
+ (CONFIG_AMP_GAIN == OPAMP_PGAGain_10) ? 10 :
+ (CONFIG_AMP_GAIN == OPAMP_PGAGain_11) ? 11 :
+ (CONFIG_AMP_GAIN == OPAMP_PGAGain_12) ? 12 :
+ (CONFIG_AMP_GAIN == OPAMP_PGAGain_13) ? 13 :
+ (CONFIG_AMP_GAIN == OPAMP_PGAGain_14) ? 14 :
+ (CONFIG_AMP_GAIN == OPAMP_PGAGain_15) ? 15 :
+ (CONFIG_AMP_GAIN == OPAMP_PGAGain_16) ? 16 :
+ 1);
+
+ _Log_IO_Msg(" VinP=", CONFIG_OPAMPx_VinP_IO_PORT, CONFIG_OPAMPx_VinP_IO_PIN);
+
+ #if defined(CONFIG_SET_OPAMP_VINM_GND) && (CONFIG_SET_OPAMP_VINM_GND)
+ msg(" VinM= GND\n");
+ #else
+ _Log_IO_Msg(" VinM=", CONFIG_OPAMPx_VinM_IO_PORT, CONFIG_OPAMPx_VinM_IO_PIN);
+ #endif
+
+ if( CONFIG_ADC_TARGET_CHANNEL == ADC_Channel_OPA0_O ||
+ CONFIG_ADC_TARGET_CHANNEL == ADC_Channel_OPA1_O )
+ msg(" Vout= ADC AIN%d\n", 31ul - HAL_CLZ(CONFIG_ADC_TARGET_CHANNEL));
+ else
+ _Log_IO_Msg(" Vout=", CONFIG_OPAMPx_Vout_IO_PORT, CONFIG_OPAMPx_Vout_IO_PIN);
+
+ _Config_PGA_IO();
+
+ { /* Configure ADC */
+ ADC_InitTypeDef init = {0};
+
+ ADC_StructInit(&init);
+
+ init.SelChannels = CONFIG_ADC_TARGET_CHANNEL;
+ init.IsSoftTrig = true;
+ ADC_Init(ADC0, &init);
+ }
+
+ { /* Configure OPAMP module */
+ OPAMP_InitTypeDef init = {0};
+
+ init.OPAMP_Gain = CONFIG_AMP_GAIN;
+ init.OPAMP_VinP = OPAMP_VinP_IO;
+
+ #if defined(CONFIG_SET_OPAMP_VINM_GND) && (CONFIG_SET_OPAMP_VINM_GND)
+ init.OPAMP_VinM = OPAMP_VinM_GND;
+ #else
+ init.OPAMP_VinM = OPAMP_VinM_IO;
+ #endif
+
+ if( CONFIG_ADC_TARGET_CHANNEL == ADC_Channel_OPA0_O ||
+ CONFIG_ADC_TARGET_CHANNEL == ADC_Channel_OPA1_O )
+ init.OPAMP_Vout = OPAMP_Vout_None;
+ else
+ init.OPAMP_Vout = OPAMP_Vout_IO;
+
+ OPAMP_Init(OPAMPx, &init);
+
+ OPAMP_Enable(OPAMPx);
+ }
+
+ while(1)
+ {
+ uint32_t ConvValue = 0ul;
+
+ ADC_Start(ADC0);
+
+ ConvValue = ADC_GetChannelConvValue(ADC0, CONFIG_ADC_TARGET_CHANNEL);
+
+ msg("ADC samples the PGA Vout= 0x%04X (%d mV)\n",
+ ConvValue, ((ConvValue * CONFIG_ADC_REF_mVOLTAGE) >> 12));
+
+ sys_delay(1000);
+ }
+ return 0;
+}
diff --git a/Examples/pga/pga_test/.cproject b/Examples/pga/pga_test/.cproject
deleted file mode 100644
index 21d0162..0000000
--- a/Examples/pga/pga_test/.cproject
+++ /dev/null
@@ -1,293 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Examples/pga/pga_test/.project b/Examples/pga/pga_test/.project
deleted file mode 100644
index 2183c12..0000000
--- a/Examples/pga/pga_test/.project
+++ /dev/null
@@ -1,54 +0,0 @@
-
-
- Project
-
-
-
-
-
- org.eclipse.cdt.managedbuilder.core.genmakebuilder
- clean,full,incremental,
-
-
-
-
- org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
- full,incremental,
-
-
-
-
-
- org.eclipse.cdt.core.cnature
- org.eclipse.cdt.managedbuilder.core.managedBuildNature
- org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
-
-
-
- Common
- 2
- PARENT-3-PROJECT_LOC/Common
-
-
- Drivers
- 2
- PARENT-3-PROJECT_LOC/Drivers
-
-
- Profiles
- 2
- PARENT-3-PROJECT_LOC/Tools/scripts/Profiles
-
-
-
-
- 0
-
- 6
-
- org.eclipse.ui.ide.multiFilter
- 1.0-name-matches-false-false-*.nuproject
-
-
-
-
diff --git a/Examples/pga/pga_test/Project.nuproject b/Examples/pga/pga_test/Project.nuproject
deleted file mode 100644
index 0743ed2..0000000
--- a/Examples/pga/pga_test/Project.nuproject
+++ /dev/null
@@ -1,25 +0,0 @@
-SDK_CONFIG:
- Debug:
- core: N203E
- extra_asmflags:
- archext:
- extra_cxxflags:
- cmodel: medlow
- extra_commonflags:
- abi: ilp32e
- arch: rv32emac
- toolchain: gnu
- extra_cflags:
- extra_ldflags:
- Release:
- core: N203E
- extra_asmflags:
- archext:
- extra_cxxflags:
- cmodel: medlow
- extra_commonflags:
- abi: ilp32e
- arch: rv32emac
- toolchain: gnu
- extra_cflags:
- extra_ldflags:
diff --git a/Examples/pga/pga_test/component.mk b/Examples/pga/pga_test/component.mk
deleted file mode 100644
index b1b2bc6..0000000
--- a/Examples/pga/pga_test/component.mk
+++ /dev/null
@@ -1,16 +0,0 @@
-#
-# component Makefile
-#
-
-
-C_SOURCES += \
- $(srctree)/$(PROJ)/src/isr.c \
- $(srctree)/$(PROJ)/src/main.c
-
-C_INCLUDES += -I$(srctree)/$(PROJ)/inc
-
-
-LIBS +=
-CFLAGS +=
-LDFLAGS +=
-LIBDIR +=
diff --git a/Examples/pga/pga_test/inc/main.h b/Examples/pga/pga_test/inc/main.h
deleted file mode 100644
index 6bc013b..0000000
--- a/Examples/pga/pga_test/inc/main.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file main.h
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/08/29
- * @license
- * @description
- */
-
-#ifndef __main_H_wxBnwdPw_lq7D_H4I5_sHPp_uXof15pFLp4V__
-#define __main_H_wxBnwdPw_lq7D_H4I5_sHPp_uXof15pFLp4V__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-#include "hal_device.h"
-#include "syslog.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/Examples/pga/pga_test/src/main.c b/Examples/pga/pga_test/src/main.c
deleted file mode 100644
index f727777..0000000
--- a/Examples/pga/pga_test/src/main.c
+++ /dev/null
@@ -1,121 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file main.c
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/08/29
- * @license
- * @description
- */
-
-
-#include "main.h"
-#include "isr.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-#define GPIO_PORTx GPIOA
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-int main(void)
-{
- GPIO_InitTypeDef Init_GPIO = {0};
- OPAMP_InitTypeDef Init_Pga = {0};
-
-
- {
- SYSCFG_ClkInitTypeDef SysClkInit = {0};
-
-
- SysClkInit.ClkSource = SYSCFG_ClkSrc_HSI;
- SYSCFG_SysClkConfig(&SysClkInit);
- }
-
- sys_config_systick(SYS_TICK_10_MS);
-
- syslog_init();
-
- info("%s\nThis is a demo project to pga0_1 gain\n", __TIME__);
-
- uint32_t sel = (GPIO_ReadOutputData(GPIOA) >> 0) & 0x07; // pa2:pa1:pa0
-
- Init_Pga.OPAMP_VinP = OPAMP_VinP_IO; // pga0_vip=pa8
- Init_Pga.OPAMP_VinM = OPAMP_VinM_GND; // internal gain
- Init_Pga.OPAMP_Gain = OPAMP_PGAGain_5;
- Init_Pga.OPAMP_Vout = OPAMP_Vout_IO ; // pga_out=pa7
- OPAMP_Init(OPAMP0 ,&Init_Pga);
-
- // uint32_t ana2io_en = (0x01 << 4); // pga0_vip=pa8 out enable
- // uint32_t pga_val = ana2io_en;
- // AMISC->VBUF_CR= pga_val;
-
- OPAMP_Enable(OPAMP0);
-
-
- Init_Pga.OPAMP_VinP = OPAMP_VinP_IO; // pga0_vip=pa11
- Init_Pga.OPAMP_VinM = OPAMP_VinM_GND; // internal gain
- Init_Pga.OPAMP_Gain = OPAMP_PGAGain_5;
- Init_Pga.OPAMP_Vout = OPAMP_Vout_IO ; // pga_out=pa13
- OPAMP_Init(OPAMP1 ,&Init_Pga);
-
- OPAMP_Enable(OPAMP1);
-
-
-
- while(1)
- {
- uint32_t sel = (GPIO_ReadOutputData(GPIOA) >> 0) & 0x07; // pa2:pa1:pa0
- switch( sel )
- {
-
- default:
- case 0x00:
- Init_Pga.OPAMP_Gain = OPAMP_PGAGain_1;
- break;
-
- case 0x01:
- Init_Pga.OPAMP_Gain = OPAMP_PGAGain_2;
- break;
-
- case 0x02:
- Init_Pga.OPAMP_Gain = OPAMP_PGAGain_4;
- break;
-
- case 0x03:
- Init_Pga.OPAMP_Gain = OPAMP_PGAGain_8;
- break;
-
- case 0x04:
- Init_Pga.OPAMP_Gain = OPAMP_PGAGain_16;
- break;
-
- }
-
- REG_WRITE_MASK(OPAMP0->PGA_CR, OPAMP_PGA_CR_PGA_GAIN_Msk, Init_Pga.OPAMP_Gain);
- REG_WRITE_MASK(OPAMP1->PGA_CR, OPAMP_PGA_CR_PGA_GAIN_Msk, Init_Pga.OPAMP_Gain);
-
- __asm("nop");
- __asm("nop");
-
- }
-}
diff --git a/Examples/pga/pga_verify_wr_rd_reg/.cproject b/Examples/pga/pga_verify_wr_rd_reg/.cproject
deleted file mode 100644
index 21d0162..0000000
--- a/Examples/pga/pga_verify_wr_rd_reg/.cproject
+++ /dev/null
@@ -1,293 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Examples/pga/pga_verify_wr_rd_reg/.project b/Examples/pga/pga_verify_wr_rd_reg/.project
deleted file mode 100644
index 2183c12..0000000
--- a/Examples/pga/pga_verify_wr_rd_reg/.project
+++ /dev/null
@@ -1,54 +0,0 @@
-
-
- Project
-
-
-
-
-
- org.eclipse.cdt.managedbuilder.core.genmakebuilder
- clean,full,incremental,
-
-
-
-
- org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
- full,incremental,
-
-
-
-
-
- org.eclipse.cdt.core.cnature
- org.eclipse.cdt.managedbuilder.core.managedBuildNature
- org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
-
-
-
- Common
- 2
- PARENT-3-PROJECT_LOC/Common
-
-
- Drivers
- 2
- PARENT-3-PROJECT_LOC/Drivers
-
-
- Profiles
- 2
- PARENT-3-PROJECT_LOC/Tools/scripts/Profiles
-
-
-
-
- 0
-
- 6
-
- org.eclipse.ui.ide.multiFilter
- 1.0-name-matches-false-false-*.nuproject
-
-
-
-
diff --git a/Examples/pga/pga_verify_wr_rd_reg/Project.nuproject b/Examples/pga/pga_verify_wr_rd_reg/Project.nuproject
deleted file mode 100644
index 0743ed2..0000000
--- a/Examples/pga/pga_verify_wr_rd_reg/Project.nuproject
+++ /dev/null
@@ -1,25 +0,0 @@
-SDK_CONFIG:
- Debug:
- core: N203E
- extra_asmflags:
- archext:
- extra_cxxflags:
- cmodel: medlow
- extra_commonflags:
- abi: ilp32e
- arch: rv32emac
- toolchain: gnu
- extra_cflags:
- extra_ldflags:
- Release:
- core: N203E
- extra_asmflags:
- archext:
- extra_cxxflags:
- cmodel: medlow
- extra_commonflags:
- abi: ilp32e
- arch: rv32emac
- toolchain: gnu
- extra_cflags:
- extra_ldflags:
diff --git a/Examples/pga/pga_verify_wr_rd_reg/inc/isr.h b/Examples/pga/pga_verify_wr_rd_reg/inc/isr.h
deleted file mode 100644
index b1ab850..0000000
--- a/Examples/pga/pga_verify_wr_rd_reg/inc/isr.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file isr.h
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/09/16
- * @license
- * @description
- */
-
-#ifndef __isr_H_wuraIpBA_lTJm_HvJw_sNDo_uEd5JnucTReY__
-#define __isr_H_wuraIpBA_lTJm_HvJw_sNDo_uEd5JnucTReY__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-/**
- * ISRs of Internal Interrupt of IRQC
- */
-void irqc_mtip_handler(void);
-void irqc_msip_handler(void);
-
-/**
- * ISRs of External Interrupt of IRQC
- */
-void irqc_uart_handler(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/Examples/pga/pga_verify_wr_rd_reg/inc/main.h b/Examples/pga/pga_verify_wr_rd_reg/inc/main.h
deleted file mode 100644
index 6bc013b..0000000
--- a/Examples/pga/pga_verify_wr_rd_reg/inc/main.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file main.h
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/08/29
- * @license
- * @description
- */
-
-#ifndef __main_H_wxBnwdPw_lq7D_H4I5_sHPp_uXof15pFLp4V__
-#define __main_H_wxBnwdPw_lq7D_H4I5_sHPp_uXof15pFLp4V__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-#include "hal_device.h"
-#include "syslog.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/Examples/pga/pga_verify_wr_rd_reg/readme.md b/Examples/pga/pga_verify_wr_rd_reg/readme.md
deleted file mode 100644
index 0603180..0000000
--- a/Examples/pga/pga_verify_wr_rd_reg/readme.md
+++ /dev/null
@@ -1,44 +0,0 @@
-PGA read/write_registers
----
-
-This example is used to read/write_registers
-
-# Log
-
-Use serial port with baudrate 115200 8bit, no parity check.
-User can receive log infomation on `PA00->TXD` of DUT.
-
-10:30:37
-This is a demo project to PGA Read Write registers
-
-PGA0_CR: Register Default: 0X0, Register Read: 0X0
-Match
-
-PGA1_CR: Register Default: 0X0, Register Read: 0X0
-Match
-
-PGA0_CR: Register Write: 0XFFFFFFFF, Register result value: 0XCFF, Register Read: 0XCFF
-Match
-
-PGA1_CR: Register Write: 0XFFFFFFFF, Register result value: 0XCFF, Register Read: 0XCFF
-Match
-
-PGA0_CR: Register Write: 0X0, Register result value: 0X0, Register Read: 0X0
-Match
-
-PGA1_CR: Register Write: 0X0, Register result value: 0X0, Register Read: 0X0
-Match
-
-PGA0_CR: Register Write: 0X5A5A5A5A, Register result value: 0X85A, Register Read: 0X85A
-Match
-
-PGA1_CR: Register Write: 0X5A5A5A5A, Register result value: 0X85A, Register Read: 0X85A
-Match
-
-PGA0_CR: Register Write: 0XA5A5A5A5, Register result value: 0X4A5, Register Read: 0X4A5
-Match
-
-PGA1_CR: Register Write: 0XA5A5A5A5, Register result value: 0X4A5, Register Read: 0X4A5
-Match
-
-done~~~
\ No newline at end of file
diff --git a/Examples/pga/pga_verify_wr_rd_reg/src/isr.c b/Examples/pga/pga_verify_wr_rd_reg/src/isr.c
deleted file mode 100644
index af63b27..0000000
--- a/Examples/pga/pga_verify_wr_rd_reg/src/isr.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file isr.c
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/09/16
- * @license
- * @description
- */
-
-
-#include "main.h"
-#include "isr.h"
-
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-/**
- * \brief System Software ISR
- *
- * \return None
- */
-__INTERRUPT void irqc_msip_handler(void)
-{
- sys_clear_swi();
-
- return;
-}
-
diff --git a/Examples/pga/pga_verify_wr_rd_reg/src/main.c b/Examples/pga/pga_verify_wr_rd_reg/src/main.c
deleted file mode 100644
index e1da4da..0000000
--- a/Examples/pga/pga_verify_wr_rd_reg/src/main.c
+++ /dev/null
@@ -1,112 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file main.c
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/08/29
- * @license
- * @description
- */
-
-
-#include "main.h"
-#include "isr.h"
-#include
-//=============================================================================
-// Constant Definition
-//=============================================================================
-#define GPIO_PORTx GPIOA
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-int main(void)
-{
-
- uint32_t read_value;
- uint32_t write_value;
- uint32_t result_value;
-
- {
- SYSCFG_ClkInitTypeDef SysClkInit = {0};
-
- SysClkInit.ClkSource = SYSCFG_ClkSrc_HSI;
- SYSCFG_SysClkConfig(&SysClkInit);
- }
-
- sys_config_systick(SYS_TICK_10_MS);
-
- syslog_init();
-
- info("%s\nThis is a demo project to PGA Read Write registers\n", __TIME__);
-
-//-------------------PGA ------------------//
-volatile uint32_t *registers_PGA_CR[]= {&OPAMP0->PGA_CR ,&OPAMP1->PGA_CR};
-uint32_t PGA_CR_default_value = 0x0;
-uint32_t PGA_CR_write_values[] = {0xFFFFFFFF, 0x00000000, 0x5A5A5A5A, 0xA5A5A5A5};
-
- REG_SET_BITS(SYSCFG->PRSTEN, SYSCFG_PCLKEN_AMISC_Msk);
- REG_CLR_BITS(SYSCFG->PRSTEN, SYSCFG_PCLKEN_AMISC_Msk);
-
- __HAL_SYSCFG_AMISC_CLK_ENABLE();
-
- for (int i = 0; i < 2; i++) // READ CHECK REG
- {
- read_value =REG_READ(*registers_PGA_CR[i]);
- printf("\nPGA%d_CR: Register Default: 0X%X, Register Read: 0X%X\n", i, PGA_CR_default_value, read_value);
- if (PGA_CR_default_value == read_value)
- {
- printf("Match\n");
- } else
- {
- err("No Match\n");
- }
- }
-
- for (int j = 0; j < 4; j++) // WRITE & CHECK REG
- {
- for (int i = 0; i < 2; i++)
- {
- write_value = PGA_CR_write_values[j];
- result_value = (write_value & 0x00000CFF);
- REG_WRITE(*registers_PGA_CR[i], write_value);
- read_value = REG_READ(*registers_PGA_CR[i]);
- printf("\nPGA%d_CR: Register Write: 0X%X, Register result value: 0X%X, Register Read: 0X%X\n", i, write_value, result_value, read_value);
- if (result_value == read_value)
- {
- printf("Match\n");
- } else
- {
- err("No Match\n");
- }
- }
- }
-
- msg("\ndone~~~\n");
-
-
- while(1)
- {
-
- __NOP();
-
- }
-}
diff --git a/Examples/pwr/pwr_sleep_mode/.cproject b/Examples/pwr/pwr_sleep_mode/.cproject
index 21d0162..1a0019e 100644
--- a/Examples/pwr/pwr_sleep_mode/.cproject
+++ b/Examples/pwr/pwr_sleep_mode/.cproject
@@ -40,27 +40,28 @@
-
+
-
-
+
+
+
@@ -68,14 +69,14 @@
@@ -94,7 +95,7 @@
-
-
+
+
@@ -192,10 +193,10 @@
@@ -204,14 +205,14 @@
@@ -225,7 +226,7 @@
diff --git a/Examples/pwr/pwr_sleep_mode/Project.nuproject b/Examples/pwr/pwr_sleep_mode/Project.nuproject
index 0743ed2..0072223 100644
--- a/Examples/pwr/pwr_sleep_mode/Project.nuproject
+++ b/Examples/pwr/pwr_sleep_mode/Project.nuproject
@@ -7,7 +7,7 @@ SDK_CONFIG:
cmodel: medlow
extra_commonflags:
abi: ilp32e
- arch: rv32emac
+ arch: rv32ema_zba_zbb_zbs_zca_zcb_zcmp_zcmt_zicond
toolchain: gnu
extra_cflags:
extra_ldflags:
@@ -19,7 +19,7 @@ SDK_CONFIG:
cmodel: medlow
extra_commonflags:
abi: ilp32e
- arch: rv32emac
+ arch: rv32emac_zba_zbb_zbs
toolchain: gnu
extra_cflags:
extra_ldflags:
diff --git a/Examples/pwr/pwr_sleep_mode/readme.md b/Examples/pwr/pwr_sleep_mode/readme.md
index 1e5ce62..947599a 100644
--- a/Examples/pwr/pwr_sleep_mode/readme.md
+++ b/Examples/pwr/pwr_sleep_mode/readme.md
@@ -1,28 +1,93 @@
pwr_sleep_mode
---
-This example is used to enter power mode
+This example is used to enter power mode and wake-up system
+> + In normal mode, it will toggle I/O to notify user
+> + Use Button to enter/leave power-mode function
-+ Sleep mode
+When measure the electric current, user should remove all external device links
+> External device e.g. ICE, log message device (UART), LA (Logic Analyzer), ...etc.
- ```
++ Sleep/Deepsleep mode
+
+ - Sleep mode
+
+ ```
+ // at main.c (Use sleep mode)
+ #define CONFIG_USE_SLEEP_MODE 1
+ ```
+ - Deep-Sleep mode
+
+ ```
+ // at main.c (Use deep-sleep mode)
+ #define CONFIG_USE_SLEEP_MODE 0
+ ```
+
++ The I/O selection of Button
+
+ ```c
// at main.c
- #define CONFIG_USE_SLEEP_MODE 1
+ /* Input Key I/O definitions */
+ #define CONFIG_GPIO_INPUT_PORTx GPIOA
+ #define CONFIG_GPIO_INPUT_PINx GPIO_Pin_03
+ #define CONFIG_GPIO_INPUT_IRQ GPIOA_IRQn
```
-+ Deepsleep mode
++ The toggled I/O selection
- ```
+ ```c
// at main.c
- #define CONFIG_USE_SLEEP_MODE 0
+ /* Toggle I/O when normal App executing */
+ #define CONFIG_IO_TOGGLE_PORTx GPIOA
+ #define CONFIG_IO_TOGGLE_PINx GPIO_Pin_02
```
-+ Set duration of auto-wakeup
++ Wake-up modules selection
+ > + The I/O wake-up case will provide the `minimum current` when deep-sleep mode
+ > + The LpTIM/WDG cases will provide the `lower current` when deep-sleep mode
- ```
- // Set 1000-msec in main.c
- PWR_SetAutoWakeUp(1000);
- ```
+
+ - I/O wake-up
+
+ ```
+ // at main.c
+ /**
+ * The target module to wake-up system
+ * + I/O wake-up case is ultra-low power in DeepSleep mode
+ * + LpTIM/WDG wake-up cases are low power in DeepSleep mode
+ */
+ #define CONFIG_USE_IO_WAKEUP 1
+ #define CONFIG_USE_LPTIN_WAKEUP 0
+ #define CONFIG_USE_WDG_WAKEUP 0
+ ```
+
+ - LpTIM wake-up
+
+ ```
+ // at main.c
+ /**
+ * The target module to wake-up system
+ * + I/O wake-up case is ultra-low power in DeepSleep mode
+ * + LpTIM/WDG wake-up cases are low power in DeepSleep mode
+ */
+ #define CONFIG_USE_IO_WAKEUP 0
+ #define CONFIG_USE_LPTIN_WAKEUP 1
+ #define CONFIG_USE_WDG_WAKEUP 0
+ ```
+
+ - WDG wake-up
+
+ ```
+ // at main.c
+ /**
+ * The target module to wake-up system
+ * + I/O wake-up case is ultra-low power in DeepSleep mode
+ * + LpTIM/WDG wake-up cases are low power in DeepSleep mode
+ */
+ #define CONFIG_USE_IO_WAKEUP 0
+ #define CONFIG_USE_LPTIN_WAKEUP 0
+ #define CONFIG_USE_WDG_WAKEUP 1
+ ```
## Log
@@ -30,25 +95,104 @@ Use serial port with baudrate 115200, 8bit, no parity check.
+ Sleep mode
- ```
- Jan 3 2025,17:06:27
- This is an example of Deepsleep of Power-Mode
- wait 1-second
- -> enter sleep
- _Pre_Proc
- _Post_Proc
- <- wake-up
+ - I/O wake-up
- -> enter sleep
- _Pre_Proc
- _Post_Proc
- <- wake-up
+ ```
+ [2025-11-21 16:54:01.215] Nov 19 2025 16:53:58
+ [2025-11-21 16:54:01.215] This is an example of Power-Mode (Sleep) and wake-up with I/O
+ [2025-11-21 16:54:01.220] Button = PA3
+ [2025-11-21 16:54:01.224] Output I/O = PA2
+ [2025-11-21 16:54:05.020] -> enter sleep
+ [2025-11-21 16:54:05.020] _Pre_Proc <--- manually trigger to enter sleep mode
+ [2025-11-21 16:54:06.462] Output I/O = PA2 <--- manually trigger to leave sleep mode
+ [2025-11-21 16:54:06.462] _Post_Proc
+ [2025-11-21 16:54:06.464] @ Entered None ISR <--- Never enter ISR
+ [2025-11-21 16:54:06.464] <- wake-up
+ [2025-11-21 16:54:06.466]
+ ```
- -> enter sleep
- _Pre_Proc
- _Post_Proc
- <- wake-up
- ...
- ```
+ - LpTIM wake-up
+ > Configure 5 sec wake-up with LpTIM
+
+ ```
+ [2025-11-21 16:47:15.315] Nov 19 2025 16:47:12
+ [2025-11-21 16:47:15.315] This is an example of Power-Mode (Sleep) and wake-up with LpTIM
+ [2025-11-21 16:47:15.321] Button = PA3
+ [2025-11-21 16:47:15.324] Output I/O = PA2
+ [2025-11-21 16:47:19.546] -> enter sleep
+ [2025-11-21 16:47:19.546] _Pre_Proc <--- enter sleep mode
+ [2025-11-21 16:48:26.635] Output I/O = PA2 <--- wake-up with LpTIM
+ [2025-11-21 16:48:26.635] _Post_Proc
+ [2025-11-21 16:48:26.637] @ Entered LpTim ISR <--- enter ISR
+ [2025-11-21 16:48:26.637] <- wake-up
+ [2025-11-21 16:48:26.639]
+ ```
+
+ - WDG wake-up
+ > Configure 1 sec wake-up with WatchDog
+
+ ```
+ [2025-11-21 16:36:30.876] Nov 19 2025 16:35:58
+ [2025-11-21 16:36:30.876] This is an example of Power-Mode (Sleep) and wake-up with WatchDog
+ [2025-11-21 16:36:30.881] Button = PA3
+ [2025-11-21 16:36:30.881] Output I/O = PA2
+ [2025-11-21 16:36:34.050] -> enter sleep
+ [2025-11-21 16:36:34.050] _Pre_Proc <--- enter sleep mode
+ [2025-11-21 16:36:35.098] Output I/O = PA2 <--- wake-up with WDG
+ [2025-11-21 16:36:35.098] _Post_Proc
+ [2025-11-21 16:36:35.101] @ Entered None ISR <--- Never enter ISR
+ [2025-11-21 16:36:35.101] <- wake-up
+ [2025-11-21 16:36:35.102]
+ ```
+ Deepsleep
+
+ - I/O wake-up
+
+ ```
+ [2025-11-21 16:44:10.823] Nov 19 2025 16:44:07
+ [2025-11-21 16:44:10.823] This is an example of Power-Mode (DeepSleep) and wake-up with I/O
+ [2025-11-21 16:44:10.828] Button = PA3
+ [2025-11-21 16:44:10.838] Output I/O = PA2
+ [2025-11-21 16:44:13.727] -> enter deepsleep
+ [2025-11-21 16:44:13.727] _Pre_Proc <--- manually trigger to enter deepsleep mode
+ [2025-11-21 16:44:16.085] Output I/O = PA2 <--- manually trigger to leave deepsleep mode
+ [2025-11-21 16:44:16.085] _Post_Proc
+ [2025-11-21 16:44:16.085] @ Entered None ISR <--- Never enter ISR
+ [2025-11-21 16:44:16.085] <- wake-up
+ [2025-11-21 16:44:16.085]
+ ```
+
+ - LpTIM wake-up
+ > Configure 5 sec wake-up with LpTIM
+
+ ```
+ [2025-11-21 16:40:38.170] Nov 19 2025 16:40:34
+ [2025-11-21 16:40:38.170] This is an example of Power-Mode (DeepSleep) and wake-up with LpTIM
+ [2025-11-21 16:40:38.179] Button = PA3
+ [2025-11-21 16:40:38.179] Output I/O = PA2
+ [2025-11-21 16:40:41.607] -> enter deepsleep
+ [2025-11-21 16:40:41.607] _Pre_Proc <--- enter deepsleep mode
+ [2025-11-21 16:40:46.789] Output I/O = PA2 <--- wake-up with LpTIM
+ [2025-11-21 16:40:46.789] _Post_Proc
+ [2025-11-21 16:40:46.791] @ Entered LpTim ISR <--- enter ISR
+ [2025-11-21 16:40:46.792] <- wake-up
+ [2025-11-21 16:40:46.793]
+ ```
+
+ - WDG wake-up
+ > Configure 1 sec wake-up with WatchDog
+
+ ```
+ [2025-11-21 16:38:56.627] Nov 19 2025 16:38:53
+ [2025-11-21 16:38:56.627] This is an example of Power-Mode (DeepSleep) and wake-up with WatchDog
+ [2025-11-21 16:38:56.635] Button = PA3
+ [2025-11-21 16:38:56.635] Output I/O = PA2
+ [2025-11-21 16:38:59.874] -> enter deepsleep
+ [2025-11-21 16:38:59.874] _Pre_Proc <--- enter deepsleep mode
+ [2025-11-21 16:39:00.911] Output I/O = PA2 <--- wake-up with WDG
+ [2025-11-21 16:39:00.911] _Post_Proc
+ [2025-11-21 16:39:00.914] @ Entered None ISR <--- Never enter ISR
+ [2025-11-21 16:39:00.914] <- wake-up
+ [2025-11-21 16:39:00.914]
+ ```
diff --git a/Examples/pwr/pwr_sleep_mode/src/main.c b/Examples/pwr/pwr_sleep_mode/src/main.c
index ba131c3..a6333a7 100644
--- a/Examples/pwr/pwr_sleep_mode/src/main.c
+++ b/Examples/pwr/pwr_sleep_mode/src/main.c
@@ -16,11 +16,46 @@
//=============================================================================
// Constant Definition
//=============================================================================
-#define CONFIG_USE_SLEEP_MODE 1
+#define CONFIG_USE_SLEEP_MODE 0
+
+/**
+ * The target module to wake-up system
+ * + I/O wake-up case is ultra-low power in DeepSleep mode
+ * + LpTIM/WDG wake-up cases are low power in DeepSleep mode
+ */
+#define CONFIG_USE_IO_WAKEUP 1
+#define CONFIG_USE_LPTIM_WAKEUP 0
+#define CONFIG_USE_WDG_WAKEUP 0
+
+/* Toggle I/O when normal App executing */
+#define CONFIG_IO_TOGGLE_PORTx GPIOA
+#define CONFIG_IO_TOGGLE_PINx GPIO_Pin_02
+
+/* Input Key I/O definitions (Wake-up Key when I/O wakup case) */
+#define CONFIG_GPIO_INPUT_PORTx GPIOA
+#define CONFIG_GPIO_INPUT_PINx GPIO_Pin_03
+#define CONFIG_GPIO_INPUT_IRQn GPIOA_IRQn
+
+
+typedef enum isr_tag
+{
+ ISR_TAG_NONE = 0,
+ ISR_TAG_LPTIM = 0x123,
+ ISR_TAG_WDG = 0x456,
+ ISR_TAG_IO = 0x789,
+} isr_tag_t;
//=============================================================================
// Macro Definition
//=============================================================================
-
+/**
+ * \brief Calculate the ticks of timer from msec
+ *
+ * \param [in] __msec__ the target duration (micro-second), range 0 ~ 999
+ * \param [in] __clk_freq__ the frequency of the clock source
+ * \return
+ * the ticks of timer
+ */
+#define _Calc_WakeUp_Duration(__msec__, __clk_freq__) ((((uint32_t)(__msec__) * (__clk_freq__)) / 1000ul) - 1)
//=============================================================================
// Structure Definition
//=============================================================================
@@ -28,32 +63,217 @@
//=============================================================================
// Global Data Definition
//=============================================================================
-
+static bool g_has_key_event = false;
+static isr_tag_t g_enter_isr_tag = ISR_TAG_NONE;
//=============================================================================
// Private Function Definition
//=============================================================================
-
-static void
-_Pre_Proc(void)
+__INTERRUPT void GPIOx_Handler(void)
{
-#if 0
- /**
- * If user has other ideas to wakeup system,
- * please un-mark this API
- */
- sys_disable_systick();
+ SAVE_IRQ_CSR_CONTEXT();
+
+ if( GPIO_GetITFlag(CONFIG_GPIO_INPUT_PORTx, CONFIG_GPIO_INPUT_PINx) )
+ {
+ GPIO_ClearITFlag(CONFIG_GPIO_INPUT_PORTx, CONFIG_GPIO_INPUT_PINx);
+
+ g_has_key_event = true;
+ }
+
+ g_enter_isr_tag = ISR_TAG_IO;
+ RESTORE_IRQ_CSR_CONTEXT();
+ return;
+}
+
+#if (CONFIG_USE_LPTIM_WAKEUP)
+__INTERRUPT void LPTIM_Handler(void)
+{
+ SAVE_IRQ_CSR_CONTEXT();
+
+ g_enter_isr_tag = ISR_TAG_LPTIM;
+
+ LPTIM_ClearFlag(LPTIM, LPTIM_Flag_Match0);
+
+ RESTORE_IRQ_CSR_CONTEXT();
+ return;
+}
+
+#elif (CONFIG_USE_WDG_WAKEUP)
+__INTERRUPT void WDG_Handler(void)
+{
+ SAVE_IRQ_CSR_CONTEXT();
+
+ g_enter_isr_tag = ISR_TAG_WDG;
+
+ WDG_Clear();
+
+ RESTORE_IRQ_CSR_CONTEXT();
+ return;
+}
#endif
- msg(" %s\n", __func__);
- // ToDo: close peripheral clocks
+static void _Config_ButtonIO(bool has_log)
+{
+ GPIO_InitTypeDef GPIO_InitStruct = {0};
+
+ if( has_log )
+ {
+ msg(" Button = P%s%d\n",
+ (CONFIG_GPIO_INPUT_PORTx == GPIOA) ? "A" : "B",
+ 31ul - HAL_CLZ(CONFIG_GPIO_INPUT_PINx));
+ }
+
+ GPIO_InitStruct.GPIO_Pin = CONFIG_GPIO_INPUT_PINx;
+ GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IN ;
+ GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_UP;
+ GPIO_InitStruct.GPIO_ITInit.GPIO_Trigger = GPIO_Trigger_Level;
+ GPIO_InitStruct.GPIO_ITInit.GPIO_Polarity = GPIO_Polarity_Low_Fall;
+ GPIO_Init(CONFIG_GPIO_INPUT_PORTx , &GPIO_InitStruct);
+
+ GPIO_ITEnable(CONFIG_GPIO_INPUT_PORTx, CONFIG_GPIO_INPUT_PINx);
+
+ sys_irq_attr_t irq_attr = { .disable_vector = false, };
+
+ irq_attr.trig_mode = SYS_IRQ_TRIGGER_LEVEL;
+ irq_attr.level = SYS_IRQ_LEVEL_L;
+ irq_attr.priority = SYS_IRQ_PRIORITY_MIDDEN;
+ sys_register_IRQ(CONFIG_GPIO_INPUT_IRQn, GPIOx_Handler, &irq_attr);
+ return;
+}
+
+static void _Config_ToggleOutput(void)
+{
+ GPIO_InitTypeDef GPIO_InitStruct = {0};
+
+ msg(" Output I/O = P%s%d\n",
+ (CONFIG_IO_TOGGLE_PORTx == GPIOA) ? "A" : "B",
+ 31ul - HAL_CLZ(CONFIG_IO_TOGGLE_PINx));
+
+ GPIO_InitStruct.GPIO_Pin = CONFIG_IO_TOGGLE_PINx;
+ GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT;
+ GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_DOWN;
+ GPIO_Init(CONFIG_IO_TOGGLE_PORTx, &GPIO_InitStruct);
return;
}
static void
-_Post_Proc(void)
+_Pre_Proc(PWR_ModeTypeDef pwr_mode, PWR_WakeupTypeDef *pWakeup_type)
{
- /* Enable peripheral clocks and re-configure peripheral if it is necessary */
msg(" %s\n", __func__);
+
+ { /* User terminates proprietary modules */
+ sys_disable_systick();
+ syslog_deinit();
+ }
+
+ { /* Configure wake-up module */
+ #if (CONFIG_USE_IO_WAKEUP)
+ *pWakeup_type = (CONFIG_GPIO_INPUT_PORTx == GPIOA)
+ ? PWR_Wakeup_IO_PORT_A : PWR_Wakeup_IO_PORT_B;
+
+ #elif (CONFIG_USE_LPTIM_WAKEUP)
+
+ // Configure LpTim to wake-up system
+ LPTIM_InitTypeDef InitStruct = {0};
+ int g_wakeup_sec = 5;
+
+ SYSCFG_SetLSIAlwaysOn(true);
+ *pWakeup_type = PWR_Wakeup_LpTIM;
+
+ InitStruct.LPTIM_Prescaler = 32 - 1;
+ InitStruct.LPTIM_ClockSource = LPTIM_CLK_Src_LSI;
+ InitStruct.LPTIM_MatchMode = LPTIM_MatchMode_IRQ;
+ InitStruct.LPTIM_MatchValue = (g_wakeup_sec * SYS_LIRC_VALUE) / (InitStruct.LPTIM_Prescaler + 1);
+ LPTIM_Init(LPTIM, &InitStruct);
+ LPTIM_Enable(LPTIM);
+
+ #elif (CONFIG_USE_WDG_WAKEUP)
+
+ // Configure WDG to wake-up system
+ WDG_BaseInitTypeDef InitStruct = {0};
+ int g_wakeup_msec = 1000;
+
+ SYSCFG_SetLSIAlwaysOn(true);
+ *pWakeup_type = PWR_Wakeup_WDG;
+
+ InitStruct.Relaod = (g_wakeup_msec * SYS_LIRC_VALUE / 1000ul) - 1;
+ InitStruct.Reset = WDG_Reset_Dis;
+ InitStruct.Debug = WDG_Debug_Dis;
+ WDG_BaseInit(&InitStruct);
+ WDG_Enable();
+
+ #else
+ #error "No wake-up configuration !"
+ #endif
+ }
+
+ g_enter_isr_tag = ISR_TAG_NONE;
+
+ /* Reset Pin Configuration if necessary */
+
+ /* Disable ICE I/O */
+ SYSCFG_SetICEPin2NormalIO(true);
+
+ { /* Configure I/O for Power-Saving mode */
+ GPIO_InitTypeDef GPIO_InitStruct = {0};
+
+ GPIO_InitStruct.GPIO_Mode = GPIO_Mode_PWR_Saving;
+ GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;
+ GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_DOWN;
+
+ GPIO_InitStruct.GPIO_Pin = GPIO_PIN_All;
+ if( GPIOA == CONFIG_GPIO_INPUT_PORTx )
+ {
+ HAL_ClearBits(GPIO_InitStruct.GPIO_Pin, CONFIG_GPIO_INPUT_PINx);
+ }
+
+ GPIO_Init(GPIOA, &GPIO_InitStruct);
+
+ GPIO_InitStruct.GPIO_Pin = GPIO_PIN_All;
+ if( GPIOB == CONFIG_GPIO_INPUT_PORTx )
+ {
+ HAL_ClearBits(GPIO_InitStruct.GPIO_Pin, CONFIG_GPIO_INPUT_PINx);
+ }
+ GPIO_Init(GPIOB, &GPIO_InitStruct);
+ }
+
+ return;
+}
+
+static void
+_Post_Proc(PWR_ModeTypeDef pwr_mode)
+{
+ { /* Recover wake-up module */
+ SYSCFG_SetLSIAlwaysOn(false);
+
+ #if (CONFIG_USE_LPTIM_WAKEUP)
+ LPTIM_Disable(LPTIM);
+
+ #elif (CONFIG_USE_WDG_WAKEUP)
+ WDG_Disable();
+
+ #endif
+ }
+
+ /* Enable ICE I/O */
+ SYSCFG_SetICEPin2NormalIO(false);
+
+ { /* User re-initializes proprietary modules */
+ sys_config_systick(SYS_TICK_1_MS);
+
+ syslog_init();
+
+ _Config_ButtonIO(false);
+ _Config_ToggleOutput();
+
+ g_has_key_event = false;
+ }
+
+ msg(" %s\n", __func__);
+ msg(" @ Entered %s ISR\n",
+ (g_enter_isr_tag == ISR_TAG_WDG) ? "WDG" :
+ (g_enter_isr_tag == ISR_TAG_LPTIM) ? "LpTim" :
+ "None");
+
return;
}
@@ -62,34 +282,66 @@ _Post_Proc(void)
//=============================================================================
int main(void)
{
- SYSCFG_ClkInitTypeDef SysClkInit = {0};
+ HAL_DeviceInit();
- SysClkInit.ClkSource = SYSCFG_ClkSrc_HSI;
- SYSCFG_SysClkConfig(&SysClkInit);
+ { /* Configure system clock */
+ SYSCFG_ClkInitTypeDef SysClkInit = {0};
+ SysClkInit.ClkSource = SYSCFG_ClkSrc_HSI;
+ SYSCFG_SysClkConfig(&SysClkInit);
+ }
sys_config_systick(SYS_TICK_1_MS);
syslog_init();
- info("%s,%s\nThis is an example of Power-Mode\n",
- __DATE__, __TIME__);
+ info("%s %s\nThis is an example of Power-Mode (%s) and wake-up with %s\n",
+ __DATE__, __TIME__,
+ #if (CONFIG_USE_SLEEP_MODE)
+ "Sleep",
+ #else
+ "DeepSleep",
+ #endif
+ #if (CONFIG_USE_IO_WAKEUP)
+ "I/O"
+ #elif (CONFIG_USE_LPTIM_WAKEUP)
+ "LpTIM"
+ #elif (CONFIG_USE_WDG_WAKEUP)
+ "WatchDog"
+ #endif
+ );
- msg(" wait 1-second\n");
- sys_delay(1000);
+ _Config_ButtonIO(true);
+ _Config_ToggleOutput();
+
+#if (CONFIG_USE_LPTIM_WAKEUP)
+ sys_irq_attr_t irq_attr = {.trig_mode = SYS_IRQ_TRIGGER_LEVEL, };
+ sys_register_IRQ(LPTIM_IRQn, LPTIM_Handler, &irq_attr);
+#elif (CONFIG_USE_WDG_WAKEUP)
+ sys_irq_attr_t irq_attr = {.trig_mode = SYS_IRQ_TRIGGER_LEVEL, };
+ sys_register_IRQ(WDG_IRQn, WDG_Handler, &irq_attr);
+#endif
+
+ g_has_key_event = false;
while(1)
{
- PWR_SetAutoWakeUp(1000);
+ if( g_has_key_event == true )
+ {
+ g_has_key_event = false;
- #if (CONFIG_USE_SLEEP_MODE)
- msg("-> enter sleep\n");
- PWR_EnterSleepMode(_Pre_Proc, _Post_Proc);
- #else
- msg("-> enter deepsleep\n");
- PWR_EnterDeepSleepMode(_Pre_Proc, _Post_Proc);
- #endif
+ #if (CONFIG_USE_SLEEP_MODE)
+ msg("-> enter sleep\n");
+ PWR_EnterSleepMode(_Pre_Proc, _Post_Proc);
+ #else
+ msg("-> enter deepsleep\n");
+ PWR_EnterDeepSleepMode(_Pre_Proc, _Post_Proc);
+ #endif
+
+ msg("<- wake-up \n\n");
+ }
+
+ GPIO_TogglePin(CONFIG_IO_TOGGLE_PORTx, CONFIG_IO_TOGGLE_PINx);
- msg("<- wake-up \n\n");
sys_busy_wait(100);
}
diff --git a/Examples/spi/spi_fifo/.cproject b/Examples/spi/spi_fifo/.cproject
deleted file mode 100644
index 21d0162..0000000
--- a/Examples/spi/spi_fifo/.cproject
+++ /dev/null
@@ -1,293 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Examples/spi/spi_fifo/.project b/Examples/spi/spi_fifo/.project
deleted file mode 100644
index 2183c12..0000000
--- a/Examples/spi/spi_fifo/.project
+++ /dev/null
@@ -1,54 +0,0 @@
-
-
- Project
-
-
-
-
-
- org.eclipse.cdt.managedbuilder.core.genmakebuilder
- clean,full,incremental,
-
-
-
-
- org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
- full,incremental,
-
-
-
-
-
- org.eclipse.cdt.core.cnature
- org.eclipse.cdt.managedbuilder.core.managedBuildNature
- org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
-
-
-
- Common
- 2
- PARENT-3-PROJECT_LOC/Common
-
-
- Drivers
- 2
- PARENT-3-PROJECT_LOC/Drivers
-
-
- Profiles
- 2
- PARENT-3-PROJECT_LOC/Tools/scripts/Profiles
-
-
-
-
- 0
-
- 6
-
- org.eclipse.ui.ide.multiFilter
- 1.0-name-matches-false-false-*.nuproject
-
-
-
-
diff --git a/Examples/spi/spi_fifo/Project.nuproject b/Examples/spi/spi_fifo/Project.nuproject
deleted file mode 100644
index 0743ed2..0000000
--- a/Examples/spi/spi_fifo/Project.nuproject
+++ /dev/null
@@ -1,25 +0,0 @@
-SDK_CONFIG:
- Debug:
- core: N203E
- extra_asmflags:
- archext:
- extra_cxxflags:
- cmodel: medlow
- extra_commonflags:
- abi: ilp32e
- arch: rv32emac
- toolchain: gnu
- extra_cflags:
- extra_ldflags:
- Release:
- core: N203E
- extra_asmflags:
- archext:
- extra_cxxflags:
- cmodel: medlow
- extra_commonflags:
- abi: ilp32e
- arch: rv32emac
- toolchain: gnu
- extra_cflags:
- extra_ldflags:
diff --git a/Examples/spi/spi_fifo/component.mk b/Examples/spi/spi_fifo/component.mk
deleted file mode 100644
index b1b2bc6..0000000
--- a/Examples/spi/spi_fifo/component.mk
+++ /dev/null
@@ -1,16 +0,0 @@
-#
-# component Makefile
-#
-
-
-C_SOURCES += \
- $(srctree)/$(PROJ)/src/isr.c \
- $(srctree)/$(PROJ)/src/main.c
-
-C_INCLUDES += -I$(srctree)/$(PROJ)/inc
-
-
-LIBS +=
-CFLAGS +=
-LDFLAGS +=
-LIBDIR +=
diff --git a/Examples/spi/spi_fifo/inc/isr.h b/Examples/spi/spi_fifo/inc/isr.h
deleted file mode 100644
index 2f4d4da..0000000
--- a/Examples/spi/spi_fifo/inc/isr.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file isr.h
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/09/16
- * @license
- * @description
- */
-
-#ifndef __isr_H_wuraIpBA_lTJm_HvJw_sNDo_uEd5JnucTReY__
-#define __isr_H_wuraIpBA_lTJm_HvJw_sNDo_uEd5JnucTReY__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "main.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/Examples/spi/spi_fifo/inc/main.h b/Examples/spi/spi_fifo/inc/main.h
deleted file mode 100644
index 6bc013b..0000000
--- a/Examples/spi/spi_fifo/inc/main.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file main.h
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/08/29
- * @license
- * @description
- */
-
-#ifndef __main_H_wxBnwdPw_lq7D_H4I5_sHPp_uXof15pFLp4V__
-#define __main_H_wxBnwdPw_lq7D_H4I5_sHPp_uXof15pFLp4V__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-#include "hal_device.h"
-#include "syslog.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/Examples/spi/spi_fifo/readme.md b/Examples/spi/spi_fifo/readme.md
deleted file mode 100644
index 86388fd..0000000
--- a/Examples/spi/spi_fifo/readme.md
+++ /dev/null
@@ -1,18 +0,0 @@
-spi tx fifo and rx fifo
----
-
-This example is used to run spi fifo function.
-
-## Hardware and Software environment
-
-+ This example runs on PB5700 devices.
-
-## How to use it ?
-
-### In order to make the program work, you must do the following:
-
-+ Open your preferred toolchain
-+ Rebuild all files and load your image into target memory
-+ Run the example
-
-The tx fifo and rx fifo of spi are 8
\ No newline at end of file
diff --git a/Examples/spi/spi_fifo/src/isr.c b/Examples/spi/spi_fifo/src/isr.c
deleted file mode 100644
index d19995f..0000000
--- a/Examples/spi/spi_fifo/src/isr.c
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file isr.c
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/09/16
- * @license
- * @description
- */
-
-
-#include "isr.h"
-
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-
diff --git a/Examples/spi/spi_fifo/src/main.c b/Examples/spi/spi_fifo/src/main.c
deleted file mode 100644
index d3f1385..0000000
--- a/Examples/spi/spi_fifo/src/main.c
+++ /dev/null
@@ -1,141 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file main.c
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/08/29
- * @license
- * @description
- */
-
-
-#include "main.h"
-#include "isr.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-/* Use PA2 to toggle */
-#define CONFIG_TOGGLE_PORT GPIOA
-#define CONFIG_TOGGLE_PIN GPIO_Pin_01
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-__INTERRUPT void SPIx_Handler(void)
-{
-
- return;
-
-}
-
-void SPI_PinConfg(SPI_Type *spi, uint32_t io_sel)
-{
- GPIO_InitTypeDef GPIO_InitStruct = {0};
-
- if(io_sel == 0)
- {
- /*-----------------------------------
- * spi_clk -- p02
- * spi_do -- p03
- * spi_di -- p04
- * spi_cs -- p05
- * ---------------------------------*/
- GPIO_InitStruct.GPIO_Pin = GPIO_Pin_02 | GPIO_Pin_03 |GPIO_Pin_04|GPIO_Pin_05;
- GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF;
- GPIO_InitStruct.GPIO_AF_Mode = GPIO_AF_1;
- GPIO_Init(GPIOA, &GPIO_InitStruct);
- }
-
-}
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-int main(void)
-{
- SPI_InitTypeDef SPI_InitStruct = {0};
-
- SYSCFG_ClkInitTypeDef SysClkInit = {0};
-
- uint32_t cnt_tx_fifo = 0;
- uint32_t cnt_rx_fifo = 0;
-
- SysClkInit.ClkSource = SYSCFG_ClkSrc_HSI;
- SYSCFG_SysClkConfig(&SysClkInit);
-
- SPI_PinConfg(SPI0, 0);
- SPI_DeInit(SPI0);
-
- {// configure I/O to toggle
- GPIO_InitTypeDef GPIO_InitStruct = {0};
- GPIO_InitStruct.GPIO_Pin = CONFIG_TOGGLE_PIN;
- GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT;
- GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL;
- GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;
- GPIO_Init(CONFIG_TOGGLE_PORT, &GPIO_InitStruct);
- }
-
- SPI_InitStruct.SPI_Mode = SPI_Mode_Master;
- SPI_InitStruct.SPI_CPOL = SPI_CPOL_Low;
- SPI_InitStruct.SPI_CPHA = SPI_CPHA_Effective;
- SPI_InitStruct.SPI_TxDataSize = SPI_TxDataSize_8b;
- SPI_InitStruct.SPI_BaudRatePrescaler = SPI_BaudratePrescaler_256;
- SPI_InitStruct.SPI_FirstBit = SPI_FirstBit_MSB;
- SPI_Init(SPI0, &SPI_InitStruct);
-
- SPI_Enable(SPI0);
- for(int delay=0; delay<10000; delay++);
-
- for(int i=1; ; i++)
- {
- SPI_SendData(SPI0, i);
- if(SPI_GetFlagStatus(SPI0, SPI_STA_TXFUL_Msk) == 1)
- {
- cnt_tx_fifo = i;
- break;
- }
- }
-
-
- SPI_Enable(SPI0);
- for(int delay=0; delay<10000; delay++);
-
- uint32_t rec_dat = 0;
- for(int i=1; i<10; i++)
- {
- rec_dat = SPI_ReceiveData(SPI0);
-
- }
-
- for(int i=1; ; i++)
- {
- SPI_SendData(SPI0, i);
- for(int delay=0; delay<1000; delay++);
-
- if(SPI_GetFlagStatus(SPI0, SPI_STA_RXFUL_Msk) == 1)
- {
- cnt_rx_fifo = i;
- break;
- }
- }
-
- while(1)
- {
- __NOP();
- }
-
-
- return 0;
-}
diff --git a/Examples/spi/spi_interrupt/.cproject b/Examples/spi/spi_interrupt/.cproject
deleted file mode 100644
index 21d0162..0000000
--- a/Examples/spi/spi_interrupt/.cproject
+++ /dev/null
@@ -1,293 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Examples/spi/spi_interrupt/.project b/Examples/spi/spi_interrupt/.project
deleted file mode 100644
index 2183c12..0000000
--- a/Examples/spi/spi_interrupt/.project
+++ /dev/null
@@ -1,54 +0,0 @@
-
-
- Project
-
-
-
-
-
- org.eclipse.cdt.managedbuilder.core.genmakebuilder
- clean,full,incremental,
-
-
-
-
- org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
- full,incremental,
-
-
-
-
-
- org.eclipse.cdt.core.cnature
- org.eclipse.cdt.managedbuilder.core.managedBuildNature
- org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
-
-
-
- Common
- 2
- PARENT-3-PROJECT_LOC/Common
-
-
- Drivers
- 2
- PARENT-3-PROJECT_LOC/Drivers
-
-
- Profiles
- 2
- PARENT-3-PROJECT_LOC/Tools/scripts/Profiles
-
-
-
-
- 0
-
- 6
-
- org.eclipse.ui.ide.multiFilter
- 1.0-name-matches-false-false-*.nuproject
-
-
-
-
diff --git a/Examples/spi/spi_interrupt/Project.nuproject b/Examples/spi/spi_interrupt/Project.nuproject
deleted file mode 100644
index 0743ed2..0000000
--- a/Examples/spi/spi_interrupt/Project.nuproject
+++ /dev/null
@@ -1,25 +0,0 @@
-SDK_CONFIG:
- Debug:
- core: N203E
- extra_asmflags:
- archext:
- extra_cxxflags:
- cmodel: medlow
- extra_commonflags:
- abi: ilp32e
- arch: rv32emac
- toolchain: gnu
- extra_cflags:
- extra_ldflags:
- Release:
- core: N203E
- extra_asmflags:
- archext:
- extra_cxxflags:
- cmodel: medlow
- extra_commonflags:
- abi: ilp32e
- arch: rv32emac
- toolchain: gnu
- extra_cflags:
- extra_ldflags:
diff --git a/Examples/spi/spi_interrupt/component.mk b/Examples/spi/spi_interrupt/component.mk
deleted file mode 100644
index b1b2bc6..0000000
--- a/Examples/spi/spi_interrupt/component.mk
+++ /dev/null
@@ -1,16 +0,0 @@
-#
-# component Makefile
-#
-
-
-C_SOURCES += \
- $(srctree)/$(PROJ)/src/isr.c \
- $(srctree)/$(PROJ)/src/main.c
-
-C_INCLUDES += -I$(srctree)/$(PROJ)/inc
-
-
-LIBS +=
-CFLAGS +=
-LDFLAGS +=
-LIBDIR +=
diff --git a/Examples/spi/spi_interrupt/inc/isr.h b/Examples/spi/spi_interrupt/inc/isr.h
deleted file mode 100644
index 2f4d4da..0000000
--- a/Examples/spi/spi_interrupt/inc/isr.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file isr.h
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/09/16
- * @license
- * @description
- */
-
-#ifndef __isr_H_wuraIpBA_lTJm_HvJw_sNDo_uEd5JnucTReY__
-#define __isr_H_wuraIpBA_lTJm_HvJw_sNDo_uEd5JnucTReY__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "main.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/Examples/spi/spi_interrupt/inc/main.h b/Examples/spi/spi_interrupt/inc/main.h
deleted file mode 100644
index 6bc013b..0000000
--- a/Examples/spi/spi_interrupt/inc/main.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file main.h
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/08/29
- * @license
- * @description
- */
-
-#ifndef __main_H_wxBnwdPw_lq7D_H4I5_sHPp_uXof15pFLp4V__
-#define __main_H_wxBnwdPw_lq7D_H4I5_sHPp_uXof15pFLp4V__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-#include "hal_device.h"
-#include "syslog.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/Examples/spi/spi_interrupt/readme.md b/Examples/spi/spi_interrupt/readme.md
deleted file mode 100644
index 69a7d9d..0000000
--- a/Examples/spi/spi_interrupt/readme.md
+++ /dev/null
@@ -1,17 +0,0 @@
-spi interrupt
----
-
-This example is used to run spi interrupt function.
-
-## Hardware and Software environment
-
-+ This example runs on PB5700 devices.
-
-## How to use it ?
-
-### In order to make the program work, you must do the following:
-
-+ Open your preferred toolchain
-+ Rebuild all files and load your image into target memory
-+ Select the spi interrupt
-+ Run the example
\ No newline at end of file
diff --git a/Examples/spi/spi_interrupt/src/isr.c b/Examples/spi/spi_interrupt/src/isr.c
deleted file mode 100644
index d19995f..0000000
--- a/Examples/spi/spi_interrupt/src/isr.c
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file isr.c
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/09/16
- * @license
- * @description
- */
-
-
-#include "isr.h"
-
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-
diff --git a/Examples/spi/spi_interrupt/src/main.c b/Examples/spi/spi_interrupt/src/main.c
deleted file mode 100644
index fbfb844..0000000
--- a/Examples/spi/spi_interrupt/src/main.c
+++ /dev/null
@@ -1,358 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file main.c
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/08/29
- * @license
- * @description
- */
-
-
-#include "main.h"
-#include "isr.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-uint32_t spi_flag = 0;
-uint32_t it_flag = 0;
-uint32_t spi_clear_flag =0;
-uint32_t spi_tx = 0;
-uint32_t spi_rx = 0;
-uint32_t test_case = 0;
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-__INTERRUPT void SPIx_Handler(void)
-{
- switch(test_case)
- {
- case 0:
- if(SPI_GetFlagStatus(SPI0, SPI_STA_RECVOV_Msk) == 1) //check flag
- {
- spi_flag |= it_flag;
-
- GPIO_TogglePin(GPIOA, GPIO_Pin_07);
-
- for(uint32_t i=0; i<10; i++)
- {
- spi_rx = SPI_ReceiveData(SPI0);
- }
- SPI_ClearFlagStatus(SPI0, SPI_STA_RECVOV_Msk); //check clear flag
-
- if(SPI_GetFlagStatus(SPI0, SPI_STA_RECVOV_Msk) != 1)
- {
- spi_clear_flag |= it_flag;
-
- GPIO_TogglePin(GPIOA, GPIO_Pin_07);
- }
- }
- break;
- case 1:
- if(SPI_GetFlagStatus(SPI0, SPI_STA_MDF_Msk) == 1)
- {
- spi_flag |= it_flag;
-
- GPIO_TogglePin(GPIOA, GPIO_Pin_08);
-
- SPI_ClearFlagStatus(SPI0, SPI_STA_MDF_Msk);
- if(SPI_GetFlagStatus(SPI0, SPI_STA_MDF_Msk) != 1)
- {
- spi_clear_flag |= it_flag;
-
- GPIO_TogglePin(GPIOA, GPIO_Pin_08);
- }
- }
- break;
- case 2:
- if(SPI_GetFlagStatus(SPI0, SPI_STA_TXNFUL_Msk) == 1)
- {
- spi_flag |= it_flag;
-
- GPIO_TogglePin(GPIOA, GPIO_Pin_09);
-
- for(uint32_t i=0; i<4; i++)
- {
- SPI_SendData(SPI0, 0xAA);
- }
- if(SPI_GetFlagStatus(SPI0, SPI_STA_TXNFUL_Msk) != 1)
- {
- spi_clear_flag |= it_flag;
-
- GPIO_TogglePin(GPIOA, GPIO_Pin_09);
- }
- }
- break;
- case 3:
- if(SPI_GetFlagStatus(SPI0, SPI_STA_TXFUL_Msk) == 1)
- {
- spi_flag |= it_flag;
-
- GPIO_TogglePin(GPIOA, GPIO_Pin_10);
-
- SPI_Enable(SPI0);
- for(int i=0; i<100; i++);
- if(SPI_GetFlagStatus(SPI0, SPI_STA_TXFUL_Msk) != 1)
- {
- spi_clear_flag |= it_flag;
-
- GPIO_TogglePin(GPIOA, GPIO_Pin_10);
- }
- }
- break;
- case 4:
- if(SPI_GetFlagStatus(SPI0, SPI_STA_RXNEP_Msk) == 1)
- {
- spi_flag |= it_flag;
-
- GPIO_TogglePin(GPIOA, GPIO_Pin_11);
-
- spi_rx = SPI_ReceiveData(SPI0);
- if(SPI_GetFlagStatus(SPI0, SPI_STA_RXNEP_Msk) != 1)
- {
- spi_clear_flag |= it_flag;
-
- GPIO_TogglePin(GPIOA, GPIO_Pin_11);
- }
- }
- break;
- case 5:
- if(SPI_GetFlagStatus(SPI0, SPI_STA_RXFUL_Msk) == 1)
- {
- spi_flag |= it_flag;
-
- GPIO_TogglePin(GPIOA, GPIO_Pin_12);
-
- spi_rx = SPI_ReceiveData(SPI0);
- if(SPI_GetFlagStatus(SPI0, SPI_STA_RXFUL_Msk) != 1)
- {
- spi_clear_flag |= it_flag;
-
- GPIO_TogglePin(GPIOA, GPIO_Pin_12);
- }
- }
- break;
- case 6:
- if(SPI_GetFlagStatus(SPI0, SPI_STA_TXUFL_Msk) == 1)
- {
- spi_flag |= it_flag;
-
- GPIO_TogglePin(GPIOA, GPIO_Pin_13);
-
- SPI_ClearFlagStatus(SPI0, SPI_STA_TXUFL_Msk);
- if(SPI_GetFlagStatus(SPI0, SPI_STA_TXUFL_Msk) != 1)
- {
- spi_clear_flag |= it_flag;
-
- GPIO_TogglePin(GPIOA, GPIO_Pin_13);
- }
-
- }
- break;
- default :
-
- break;
-
- }
-
- return;
-
-}
-
-
-void SPI_PinConfg(SPI_Type *spi, uint32_t io_sel)
-{
- GPIO_InitTypeDef GPIO_InitStruct = {0};
-
- if(io_sel == 0)
- {
- /*-----------------------------------
- * spi_clk -- p02
- * spi_do -- p03
- * spi_di -- p04
- * spi_cs -- p05
- * ---------------------------------*/
- GPIO_InitStruct.GPIO_Pin = GPIO_Pin_02 | GPIO_Pin_03 |GPIO_Pin_04|GPIO_Pin_05;
- GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF;
- GPIO_InitStruct.GPIO_AF_Mode = GPIO_AF_1;
- GPIO_Init(GPIOA, &GPIO_InitStruct);
-
- }
-}
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-int main(void)
-{
- SPI_InitTypeDef SPI_InitStruct = {0};
-
- SYSCFG_ClkInitTypeDef SysClkInit = {0};
-
- uint32_t tx_data[10] = {0};
- uint32_t rx_data[10] = {0};
-
- SysClkInit.ClkSource = SYSCFG_ClkSrc_HSI;
- SYSCFG_SysClkConfig(&SysClkInit);
-
- {// configure I/O to toggle
- GPIO_InitTypeDef GPIO_InitStruct = {0};
- GPIO_InitStruct.GPIO_Pin = GPIO_Pin_07|GPIO_Pin_08|GPIO_Pin_09|GPIO_Pin_10|GPIO_Pin_11|GPIO_Pin_12|GPIO_Pin_13;
- GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT;
- GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL;
- GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;
- GPIO_Init(GPIOA, &GPIO_InitStruct);
- }
-
- for(uint32_t i=0; i<10; i++)
- {
- tx_data[i] = 0xA1A2A3A4;
- }
-
- SPI_PinConfg(SPI0, 0);
- SPI_DeInit(SPI0);
-
- sys_irq_attr_t irq_attr = { .trig_mode = SYS_IRQ_TRIGGER_LEVEL, };
- sys_register_IRQ(SPI0_IRQn, SPIx_Handler, &irq_attr);
- sys_enable_girq();
-
- SPI_InitStruct.SPI_Mode = SPI_Mode_Master;//SPI_Mode_Slave;
- SPI_InitStruct.SPI_CPOL = SPI_CPOL_Low;
- SPI_InitStruct.SPI_CPHA = SPI_CPHA_Effective;
- SPI_InitStruct.SPI_TxDataSize = SPI_TxDataSize_8b;
- SPI_InitStruct.SPI_BaudRatePrescaler = SPI_BaudratePrescaler_4;
- SPI_InitStruct.SPI_FirstBit = SPI_FirstBit_MSB;
- SPI_Init(SPI0, &SPI_InitStruct);
-
- SPI_SetTXTH(SPI0, 4);
- SPI_SetRXTH(SPI0, 4);
-
- spi_flag = 0;
- spi_clear_flag = 0;
-
- test_case = 5;
- switch(test_case)
- {
- case 0:
-
- it_flag = SPI_STA_RECVOV_Msk;
- SPI_SetInterrupt(SPI0, it_flag);
-
- SPI_Enable(SPI0);
- for(uint32_t i=1; i<10; i++)
- {
- SPI_SendData(SPI0, 0xAA);
- }
-
- break;
-
- case 1:
-
- it_flag = SPI_STA_MDF_Msk;
- SPI_SetInterrupt(SPI0, it_flag);
-
- SPI_SlaveEnable(SPI0);
- SPI_Enable(SPI0);
- for(uint32_t i=1; ; i++) //slave -mdf
- {
- if(SPI_GetFlagStatus(SPI0, SPI_STA_TXNFUL_Msk) == 1)
- {
- SPI_SendData(SPI0, i);
- }
- if(SPI_GetFlagStatus(SPI0, SPI_STA_RXNEP_Msk) == 1)
- {
- rx_data[0] = SPI_ReceiveData(SPI0);
- }
-
- }
-
- break;
-
- case 2:
-
- it_flag = SPI_STA_TXNFUL_Msk;
- SPI_SetInterrupt(SPI0, it_flag);
-
- break;
-
- case 3:
-
- it_flag = SPI_STA_TXFUL_Msk;
- SPI_SetInterrupt(SPI0, it_flag);
-
- for(uint32_t i=0; i<100; i++)
- {
- SPI_SendData(SPI0, i);
- }
-
- break;
-
- case 4:
-
- it_flag = SPI_STA_RXNEP_Msk;
- SPI_SetInterrupt(SPI0, it_flag);
-
- SPI_Enable(SPI0);
- for(uint32_t i=0; i<4; i++)
- {
- SPI_SendData(SPI0, i);
- }
-
- break;
-
- case 5:
-
- it_flag = SPI_STA_RXFUL_Msk;
- SPI_SetInterrupt(SPI0, it_flag);
-
- SPI_Enable(SPI0);
- for(uint32_t i=0; i<8; i++)
- {
- SPI_SendData(SPI0, i);
- }
-
- break;
-
- case 6:
-
- it_flag = SPI_STA_TXUFL_Msk;
- SPI_SetInterrupt(SPI0, it_flag);
-
- SPI_SlaveEnable(SPI0);
- SPI_Enable(SPI0);
- for(uint32_t i=1; ; i++) //slave - txuf
- {
- while(SPI_GetFlagStatus(SPI0, SPI_STA_RXNEP_Msk) == 0);
- rx_data[0] = SPI_ReceiveData(SPI0);
- }
-
- break;
-
-
- default :
- break;
-
-
- }
-
- while(1)
- {
- __NOP();
- }
-
-
- return 0;
-}
diff --git a/Examples/spi/spi_io_af/.cproject b/Examples/spi/spi_io_af/.cproject
deleted file mode 100644
index 21d0162..0000000
--- a/Examples/spi/spi_io_af/.cproject
+++ /dev/null
@@ -1,293 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Examples/spi/spi_io_af/.project b/Examples/spi/spi_io_af/.project
deleted file mode 100644
index 2183c12..0000000
--- a/Examples/spi/spi_io_af/.project
+++ /dev/null
@@ -1,54 +0,0 @@
-
-
- Project
-
-
-
-
-
- org.eclipse.cdt.managedbuilder.core.genmakebuilder
- clean,full,incremental,
-
-
-
-
- org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
- full,incremental,
-
-
-
-
-
- org.eclipse.cdt.core.cnature
- org.eclipse.cdt.managedbuilder.core.managedBuildNature
- org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
-
-
-
- Common
- 2
- PARENT-3-PROJECT_LOC/Common
-
-
- Drivers
- 2
- PARENT-3-PROJECT_LOC/Drivers
-
-
- Profiles
- 2
- PARENT-3-PROJECT_LOC/Tools/scripts/Profiles
-
-
-
-
- 0
-
- 6
-
- org.eclipse.ui.ide.multiFilter
- 1.0-name-matches-false-false-*.nuproject
-
-
-
-
diff --git a/Examples/spi/spi_io_af/Project.nuproject b/Examples/spi/spi_io_af/Project.nuproject
deleted file mode 100644
index 0743ed2..0000000
--- a/Examples/spi/spi_io_af/Project.nuproject
+++ /dev/null
@@ -1,25 +0,0 @@
-SDK_CONFIG:
- Debug:
- core: N203E
- extra_asmflags:
- archext:
- extra_cxxflags:
- cmodel: medlow
- extra_commonflags:
- abi: ilp32e
- arch: rv32emac
- toolchain: gnu
- extra_cflags:
- extra_ldflags:
- Release:
- core: N203E
- extra_asmflags:
- archext:
- extra_cxxflags:
- cmodel: medlow
- extra_commonflags:
- abi: ilp32e
- arch: rv32emac
- toolchain: gnu
- extra_cflags:
- extra_ldflags:
diff --git a/Examples/spi/spi_io_af/component.mk b/Examples/spi/spi_io_af/component.mk
deleted file mode 100644
index b1b2bc6..0000000
--- a/Examples/spi/spi_io_af/component.mk
+++ /dev/null
@@ -1,16 +0,0 @@
-#
-# component Makefile
-#
-
-
-C_SOURCES += \
- $(srctree)/$(PROJ)/src/isr.c \
- $(srctree)/$(PROJ)/src/main.c
-
-C_INCLUDES += -I$(srctree)/$(PROJ)/inc
-
-
-LIBS +=
-CFLAGS +=
-LDFLAGS +=
-LIBDIR +=
diff --git a/Examples/spi/spi_io_af/inc/isr.h b/Examples/spi/spi_io_af/inc/isr.h
deleted file mode 100644
index 2f4d4da..0000000
--- a/Examples/spi/spi_io_af/inc/isr.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file isr.h
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/09/16
- * @license
- * @description
- */
-
-#ifndef __isr_H_wuraIpBA_lTJm_HvJw_sNDo_uEd5JnucTReY__
-#define __isr_H_wuraIpBA_lTJm_HvJw_sNDo_uEd5JnucTReY__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "main.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/Examples/spi/spi_io_af/inc/main.h b/Examples/spi/spi_io_af/inc/main.h
deleted file mode 100644
index 6bc013b..0000000
--- a/Examples/spi/spi_io_af/inc/main.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file main.h
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/08/29
- * @license
- * @description
- */
-
-#ifndef __main_H_wxBnwdPw_lq7D_H4I5_sHPp_uXof15pFLp4V__
-#define __main_H_wxBnwdPw_lq7D_H4I5_sHPp_uXof15pFLp4V__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-#include "hal_device.h"
-#include "syslog.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/Examples/spi/spi_io_af/readme.md b/Examples/spi/spi_io_af/readme.md
deleted file mode 100644
index b90e554..0000000
--- a/Examples/spi/spi_io_af/readme.md
+++ /dev/null
@@ -1,36 +0,0 @@
-SPI io alternate function
----
-
-This example is used to run spi io alternate function.
-
-## Hardware and Software environment
-
-+ This example runs on PB5700 devices.
-
-## How to use it ?
-
-### In order to make the program work, you must do the following:
-
-+ Open your preferred toolchain
-+ Rebuild all files and load your image into target memory
-+ Set the spi io alternate pin
-+ select whether to switch DI DO
-+ Run the example
-
-select 0:
- * spi_clk -- p02
- * spi_do -- p03
- * spi_di -- p04
- * spi_cs -- p05
-
-select 1:
- * spi_clk -- pa14
- * spi_do -- pa15
- * spi_di -- pb00
- * spi_cs -- pb01
-
-select 2:
- * spi_clk -- pb02
- * spi_do -- pb03
- * spi_di -- pb04
- * spi_cs -- pb05
\ No newline at end of file
diff --git a/Examples/spi/spi_io_af/src/isr.c b/Examples/spi/spi_io_af/src/isr.c
deleted file mode 100644
index d19995f..0000000
--- a/Examples/spi/spi_io_af/src/isr.c
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file isr.c
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/09/16
- * @license
- * @description
- */
-
-
-#include "isr.h"
-
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-
diff --git a/Examples/spi/spi_io_af/src/main.c b/Examples/spi/spi_io_af/src/main.c
deleted file mode 100644
index 9fc0b1a..0000000
--- a/Examples/spi/spi_io_af/src/main.c
+++ /dev/null
@@ -1,168 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file main.c
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/08/29
- * @license
- * @description
- */
-
-
-#include "main.h"
-#include "isr.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-#define spi_io_af 1
-//#define SPI_DIDO_SWITCH //SPI_DO and SPI_DI pin switch
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-void SPI_PinConfg(SPI_Type *spi, uint32_t io_sel)
-{
- GPIO_InitTypeDef GPIO_InitStruct = {0};
-
- if(io_sel == 0)
- {
- /*-----------------------------------
- * spi_clk -- p02
- * spi_do -- p03
- * spi_di -- p04
- * spi_cs -- p05
- * ---------------------------------*/
- GPIO_InitStruct.GPIO_Pin = GPIO_Pin_02 | GPIO_Pin_03 |GPIO_Pin_04|GPIO_Pin_05;
- GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF;
- GPIO_InitStruct.GPIO_AF_Mode = GPIO_AF_1;
- GPIO_Init(GPIOA, &GPIO_InitStruct);
-
-#ifdef SPI_DIDO_SWITCH
-
- GPIO_InitStruct.GPIO_Pin = GPIO_Pin_03 |GPIO_Pin_04;
- GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF;
- GPIO_InitStruct.GPIO_AF_Mode = GPIO_AF_2;
- GPIO_Init(GPIOA, &GPIO_InitStruct);
-#endif
-
- }
-
- if(io_sel == 1)
- {
- /*-----------------------------------
- * spi_clk -- pa14
- * spi_do -- pa15
- * spi_di -- pb00
- * spi_cs -- pb01
- * ---------------------------------*/
- SYSCFG->RSTPINCR = 0;
-
- GPIO_InitStruct.GPIO_Pin = GPIO_Pin_14 | GPIO_Pin_15 ;
- GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF;
- GPIO_InitStruct.GPIO_AF_Mode = GPIO_AF_3;
- GPIO_Init(GPIOA, &GPIO_InitStruct);
-
- GPIO_InitStruct.GPIO_Pin = GPIO_Pin_00 | GPIO_Pin_01;
- GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF;
- GPIO_InitStruct.GPIO_AF_Mode = GPIO_AF_3;
- GPIO_Init(GPIOB, &GPIO_InitStruct);
-
-#ifdef SPI_DIDO_SWITCH
-
- GPIO_InitStruct.GPIO_Pin = GPIO_Pin_15;
- GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF;
- GPIO_InitStruct.GPIO_AF_Mode = GPIO_AF_4;
- GPIO_Init(GPIOA, &GPIO_InitStruct);
-
- GPIO_InitStruct.GPIO_Pin = GPIO_Pin_00;
- GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF;
- GPIO_InitStruct.GPIO_AF_Mode = GPIO_AF_4;
- GPIO_Init(GPIOB, &GPIO_InitStruct);
-#endif
-
- }
-
- if(io_sel == 2)
- {
- /*-----------------------------------
- * spi_clk -- pb02
- * spi_do -- pb03
- * spi_di -- pb04
- * spi_cs -- pb05
- * ---------------------------------*/
- SYSCFG_SetICEPin2NormalIO(true);
-
- GPIO_InitStruct.GPIO_Pin = GPIO_Pin_02 | GPIO_Pin_03 | GPIO_Pin_04 | GPIO_Pin_05;
- GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF;
- GPIO_InitStruct.GPIO_AF_Mode = GPIO_AF_3;
- GPIO_Init(GPIOB, &GPIO_InitStruct);
-
-#ifdef SPI_DIDO_SWITCH
-
- GPIO_InitStruct.GPIO_Pin = GPIO_Pin_03 |GPIO_Pin_04;
- GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF;
- GPIO_InitStruct.GPIO_AF_Mode = GPIO_AF_4;
- GPIO_Init(GPIOB, &GPIO_InitStruct);
-#endif
-
- }
-
-}
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-int main(void)
-{
- SPI_InitTypeDef SPI_InitStruct = {0};
- SYSCFG_ClkInitTypeDef SysClkInit = {0};
-
- uint32_t tx_data[10] = {0};
- uint32_t rx_data[10] = {0};
-
- SysClkInit.ClkSource = SYSCFG_ClkSrc_HSI;
- SYSCFG_SysClkConfig(&SysClkInit);
-
- for(int i=0; i<10; i++)
- {
- tx_data[i] = 0xA1A2A3A4 + i;
- }
- SPI_PinConfg(SPI0, spi_io_af);
- SPI_DeInit(SPI0);
-
- SPI_InitStruct.SPI_Mode = SPI_Mode_Master;
- SPI_InitStruct.SPI_CPOL = SPI_CPOL_Low;
- SPI_InitStruct.SPI_CPHA = SPI_CPHA_Effective;
- SPI_InitStruct.SPI_TxDataSize = SPI_TxDataSize_8b;
- SPI_InitStruct.SPI_BaudRatePrescaler = SPI_BaudratePrescaler_256;
- SPI_InitStruct.SPI_FirstBit = SPI_FirstBit_MSB;
- SPI_Init(SPI0, &SPI_InitStruct);
-
- SPI_Enable(SPI0);
- for(int i=0; i<10; i++)
- {
- SPI_SendData(SPI0, tx_data[i]);
- while(SPI_GetFlagStatus(SPI0, SPI_STA_RXNEP_Msk) == 0);
- rx_data[i] = SPI_ReceiveData(SPI0);
- }
-
- while(1)
- {
- __NOP();
- }
-
-
- return 0;
-}
diff --git a/Examples/spi/spi_manual/.cproject b/Examples/spi/spi_manual/.cproject
deleted file mode 100644
index 21d0162..0000000
--- a/Examples/spi/spi_manual/.cproject
+++ /dev/null
@@ -1,293 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Examples/spi/spi_manual/.project b/Examples/spi/spi_manual/.project
deleted file mode 100644
index 2183c12..0000000
--- a/Examples/spi/spi_manual/.project
+++ /dev/null
@@ -1,54 +0,0 @@
-
-
- Project
-
-
-
-
-
- org.eclipse.cdt.managedbuilder.core.genmakebuilder
- clean,full,incremental,
-
-
-
-
- org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
- full,incremental,
-
-
-
-
-
- org.eclipse.cdt.core.cnature
- org.eclipse.cdt.managedbuilder.core.managedBuildNature
- org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
-
-
-
- Common
- 2
- PARENT-3-PROJECT_LOC/Common
-
-
- Drivers
- 2
- PARENT-3-PROJECT_LOC/Drivers
-
-
- Profiles
- 2
- PARENT-3-PROJECT_LOC/Tools/scripts/Profiles
-
-
-
-
- 0
-
- 6
-
- org.eclipse.ui.ide.multiFilter
- 1.0-name-matches-false-false-*.nuproject
-
-
-
-
diff --git a/Examples/spi/spi_manual/Project.nuproject b/Examples/spi/spi_manual/Project.nuproject
deleted file mode 100644
index 0743ed2..0000000
--- a/Examples/spi/spi_manual/Project.nuproject
+++ /dev/null
@@ -1,25 +0,0 @@
-SDK_CONFIG:
- Debug:
- core: N203E
- extra_asmflags:
- archext:
- extra_cxxflags:
- cmodel: medlow
- extra_commonflags:
- abi: ilp32e
- arch: rv32emac
- toolchain: gnu
- extra_cflags:
- extra_ldflags:
- Release:
- core: N203E
- extra_asmflags:
- archext:
- extra_cxxflags:
- cmodel: medlow
- extra_commonflags:
- abi: ilp32e
- arch: rv32emac
- toolchain: gnu
- extra_cflags:
- extra_ldflags:
diff --git a/Examples/spi/spi_manual/component.mk b/Examples/spi/spi_manual/component.mk
deleted file mode 100644
index b1b2bc6..0000000
--- a/Examples/spi/spi_manual/component.mk
+++ /dev/null
@@ -1,16 +0,0 @@
-#
-# component Makefile
-#
-
-
-C_SOURCES += \
- $(srctree)/$(PROJ)/src/isr.c \
- $(srctree)/$(PROJ)/src/main.c
-
-C_INCLUDES += -I$(srctree)/$(PROJ)/inc
-
-
-LIBS +=
-CFLAGS +=
-LDFLAGS +=
-LIBDIR +=
diff --git a/Examples/spi/spi_manual/inc/isr.h b/Examples/spi/spi_manual/inc/isr.h
deleted file mode 100644
index 2f4d4da..0000000
--- a/Examples/spi/spi_manual/inc/isr.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file isr.h
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/09/16
- * @license
- * @description
- */
-
-#ifndef __isr_H_wuraIpBA_lTJm_HvJw_sNDo_uEd5JnucTReY__
-#define __isr_H_wuraIpBA_lTJm_HvJw_sNDo_uEd5JnucTReY__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "main.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/Examples/spi/spi_manual/inc/main.h b/Examples/spi/spi_manual/inc/main.h
deleted file mode 100644
index 6bc013b..0000000
--- a/Examples/spi/spi_manual/inc/main.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file main.h
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/08/29
- * @license
- * @description
- */
-
-#ifndef __main_H_wxBnwdPw_lq7D_H4I5_sHPp_uXof15pFLp4V__
-#define __main_H_wxBnwdPw_lq7D_H4I5_sHPp_uXof15pFLp4V__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-#include "hal_device.h"
-#include "syslog.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/Examples/spi/spi_manual/readme.md b/Examples/spi/spi_manual/readme.md
deleted file mode 100644
index db9a958..0000000
--- a/Examples/spi/spi_manual/readme.md
+++ /dev/null
@@ -1,22 +0,0 @@
-spi manual mode
----
-
-This example is used to run spi manual mode function.
-
-## Hardware and Software environment
-
-+ This example runs on PB5700 devices.
-
-## How to use it ?
-
-### In order to make the program work, you must do the following:
-
-+ Open your preferred toolchain
-+ Set the send manual mode and cs manual
-+ Rebuild all files and load your image into target memory
-+ Run the example
-
- * spi_clk -- p02
- * spi_do -- p03
- * spi_di -- p04
- * spi_cs -- p05
\ No newline at end of file
diff --git a/Examples/spi/spi_manual/src/isr.c b/Examples/spi/spi_manual/src/isr.c
deleted file mode 100644
index d19995f..0000000
--- a/Examples/spi/spi_manual/src/isr.c
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file isr.c
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/09/16
- * @license
- * @description
- */
-
-
-#include "isr.h"
-
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-
diff --git a/Examples/spi/spi_manual/src/main.c b/Examples/spi/spi_manual/src/main.c
deleted file mode 100644
index 84727bb..0000000
--- a/Examples/spi/spi_manual/src/main.c
+++ /dev/null
@@ -1,129 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file main.c
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/08/29
- * @license
- * @description
- */
-
-
-#include "main.h"
-#include "isr.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-/* Use PA2 to toggle */
-#define CONFIG_TOGGLE_PORT GPIOA
-#define CONFIG_TOGGLE_PIN GPIO_Pin_01
-
-#define SPI_CS_MANUAL
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-void SPI_PinConfg(SPI_Type *spi, uint32_t io_sel)
-{
- GPIO_InitTypeDef GPIO_InitStruct = {0};
-
- if(io_sel == 0)
- {
- /*-----------------------------------
- * spi_clk -- p02
- * spi_do -- p03
- * spi_di -- p04
- * spi_cs -- p05
- * ---------------------------------*/
- GPIO_InitStruct.GPIO_Pin = GPIO_Pin_02 | GPIO_Pin_03 |GPIO_Pin_04|GPIO_Pin_05;
- GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF;
- GPIO_InitStruct.GPIO_AF_Mode = GPIO_AF_1;
- GPIO_Init(GPIOA, &GPIO_InitStruct);
- }
-
-}
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-int main(void)
-{
- SPI_InitTypeDef SPI_InitStruct = {0};
-
- SYSCFG_ClkInitTypeDef SysClkInit = {0};
-
- uint32_t tx_data[10] = {0};
- uint32_t rx_data[10] = {0};
-
- SysClkInit.ClkSource = SYSCFG_ClkSrc_HSI;
- SYSCFG_SysClkConfig(&SysClkInit);
-
- for(int i=0; i<10; i++)
- {
- tx_data[i] = 0xA1A2A3A4;
- }
-
- SPI_PinConfg(SPI0, 0);
- SPI_DeInit(SPI0);
-
- {// configure I/O to toggle
- GPIO_InitTypeDef GPIO_InitStruct = {0};
- GPIO_InitStruct.GPIO_Pin = CONFIG_TOGGLE_PIN;
- GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT;
- GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL;
- GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;
- GPIO_Init(CONFIG_TOGGLE_PORT, &GPIO_InitStruct);
- }
-
- SPI_InitStruct.SPI_Mode = SPI_Mode_Master;
- SPI_InitStruct.SPI_CPOL = SPI_CPOL_Low;
- SPI_InitStruct.SPI_CPHA = SPI_CPHA_Effective;
- SPI_InitStruct.SPI_TxDataSize = SPI_TxDataSize_8b;
- SPI_InitStruct.SPI_BaudRatePrescaler = SPI_BaudratePrescaler_4;
- SPI_InitStruct.SPI_FirstBit = SPI_FirstBit_MSB;
- SPI_Init(SPI0, &SPI_InitStruct);
-
- SPI_SetManualMode(SPI0, 1);
-
-#ifdef SPI_CS_MANUAL
- SPI_SetManualChipSelect(SPI0, 1);
-#endif
-
- SPI_Enable(SPI0);
-
- for(int i=0; i<10; i++)
- {
-
-#ifdef SPI_CS_MANUAL
-
- SPI_SetSSOUT(SPI0, 0);
- SPI_ManualSendData(SPI0, tx_data[i]);
- SPI_SetSSOUT(SPI0, 1);
-#else
- SPI_ManualSendData(SPI0, tx_data[i]);
-#endif
-
- while(SPI_GetFlagStatus(SPI0, SPI_STA_RXNEP_Msk) == 0);
- rx_data[i] = SPI_ReceiveData(SPI0);
- }
-
- while(1)
- {
- __NOP();
- }
-
-
- return 0;
-}
diff --git a/Examples/spi/spi_master/.cproject b/Examples/spi/spi_master/.cproject
new file mode 100644
index 0000000..1a0019e
--- /dev/null
+++ b/Examples/spi/spi_master/.cproject
@@ -0,0 +1,294 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Examples/comp/Compare_for_TI/.project b/Examples/spi/spi_master/.project
similarity index 100%
rename from Examples/comp/Compare_for_TI/.project
rename to Examples/spi/spi_master/.project
diff --git a/Examples/spi/spi_master/Project.nuproject b/Examples/spi/spi_master/Project.nuproject
new file mode 100644
index 0000000..0072223
--- /dev/null
+++ b/Examples/spi/spi_master/Project.nuproject
@@ -0,0 +1,25 @@
+SDK_CONFIG:
+ Debug:
+ core: N203E
+ extra_asmflags:
+ archext:
+ extra_cxxflags:
+ cmodel: medlow
+ extra_commonflags:
+ abi: ilp32e
+ arch: rv32ema_zba_zbb_zbs_zca_zcb_zcmp_zcmt_zicond
+ toolchain: gnu
+ extra_cflags:
+ extra_ldflags:
+ Release:
+ core: N203E
+ extra_asmflags:
+ archext:
+ extra_cxxflags:
+ cmodel: medlow
+ extra_commonflags:
+ abi: ilp32e
+ arch: rv32emac_zba_zbb_zbs
+ toolchain: gnu
+ extra_cflags:
+ extra_ldflags:
diff --git a/Examples/comp/Compare_for_TI/component.mk b/Examples/spi/spi_master/component.mk
similarity index 100%
rename from Examples/comp/Compare_for_TI/component.mk
rename to Examples/spi/spi_master/component.mk
diff --git a/Examples/lptim/lptim_prescaler/inc/isr.h b/Examples/spi/spi_master/inc/isr.h
similarity index 100%
rename from Examples/lptim/lptim_prescaler/inc/isr.h
rename to Examples/spi/spi_master/inc/isr.h
diff --git a/Examples/comp/Compare_for_TI/inc/main.h b/Examples/spi/spi_master/inc/main.h
similarity index 100%
rename from Examples/comp/Compare_for_TI/inc/main.h
rename to Examples/spi/spi_master/inc/main.h
diff --git a/Examples/spi/spi_send/readme.md b/Examples/spi/spi_master/readme.md
similarity index 91%
rename from Examples/spi/spi_send/readme.md
rename to Examples/spi/spi_master/readme.md
index 1ce1adb..b9a8b84 100644
--- a/Examples/spi/spi_send/readme.md
+++ b/Examples/spi/spi_master/readme.md
@@ -5,7 +5,7 @@ This example is used to run spi send and receive function.
## Hardware and Software environment
-+ This example runs on PB5700 devices.
++ This example runs on PEC930 devices.
## How to use it ?
diff --git a/Examples/flash/flash_set_latency/src/isr.c b/Examples/spi/spi_master/src/isr.c
similarity index 100%
rename from Examples/flash/flash_set_latency/src/isr.c
rename to Examples/spi/spi_master/src/isr.c
diff --git a/Examples/spi/spi_send/src/main.c b/Examples/spi/spi_master/src/main.c
similarity index 86%
rename from Examples/spi/spi_send/src/main.c
rename to Examples/spi/spi_master/src/main.c
index fd653c5..3c3b314 100644
--- a/Examples/spi/spi_send/src/main.c
+++ b/Examples/spi/spi_master/src/main.c
@@ -16,9 +16,7 @@
//=============================================================================
// Constant Definition
//=============================================================================
-/* Use PA2 to toggle */
-#define CONFIG_TOGGLE_PORT GPIOA
-#define CONFIG_TOGGLE_PIN GPIO_Pin_01
+
//=============================================================================
// Macro Definition
//=============================================================================
@@ -58,35 +56,28 @@ void SPI_PinConfg(SPI_Type *spi, uint32_t io_sel)
//=============================================================================
int main(void)
{
- SPI_InitTypeDef SPI_InitStruct = {0};
-
- SYSCFG_ClkInitTypeDef SysClkInit = {0};
-
uint32_t tx_data[10] = {0};
uint32_t rx_data[10] = {0};
+ SPI_InitTypeDef SPI_InitStruct = {0};
+ SYSCFG_ClkInitTypeDef SysClkInit = {0};
+
+ /* Configure system clock */
SysClkInit.ClkSource = SYSCFG_ClkSrc_HSI;
SYSCFG_SysClkConfig(&SysClkInit);
-
sys_config_systick(SYS_TICK_1_MS);
+ /* set tx data */
for(int i=0; i<10; i++)
{
tx_data[i] = 0xA1A2A3A4;
}
+ /* configure GPIO Pin mux of SPI */
SPI_PinConfg(SPI0, 0);
+
+ /* configure SPI */
SPI_DeInit(SPI0);
-
- {// configure I/O to toggle
- GPIO_InitTypeDef GPIO_InitStruct = {0};
- GPIO_InitStruct.GPIO_Pin = CONFIG_TOGGLE_PIN;
- GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT;
- GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL;
- GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;
- GPIO_Init(CONFIG_TOGGLE_PORT, &GPIO_InitStruct);
- }
-
SPI_InitStruct.SPI_Mode = SPI_Mode_Master;
SPI_InitStruct.SPI_CPOL = SPI_CPOL_Low;
SPI_InitStruct.SPI_CPHA = SPI_CPHA_Effective;
@@ -95,7 +86,10 @@ int main(void)
SPI_InitStruct.SPI_FirstBit = SPI_FirstBit_MSB;
SPI_Init(SPI0, &SPI_InitStruct);
+ /* Enable SPI */
SPI_Enable(SPI0);
+
+ /* SPI Master Send data */
for(int i=0; i<10; i++)
{
SPI_SendData(SPI0, tx_data[i]);
diff --git a/Examples/spi/spi_send/.cproject b/Examples/spi/spi_send/.cproject
deleted file mode 100644
index 21d0162..0000000
--- a/Examples/spi/spi_send/.cproject
+++ /dev/null
@@ -1,293 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Examples/spi/spi_send/.project b/Examples/spi/spi_send/.project
deleted file mode 100644
index 2183c12..0000000
--- a/Examples/spi/spi_send/.project
+++ /dev/null
@@ -1,54 +0,0 @@
-
-
- Project
-
-
-
-
-
- org.eclipse.cdt.managedbuilder.core.genmakebuilder
- clean,full,incremental,
-
-
-
-
- org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
- full,incremental,
-
-
-
-
-
- org.eclipse.cdt.core.cnature
- org.eclipse.cdt.managedbuilder.core.managedBuildNature
- org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
-
-
-
- Common
- 2
- PARENT-3-PROJECT_LOC/Common
-
-
- Drivers
- 2
- PARENT-3-PROJECT_LOC/Drivers
-
-
- Profiles
- 2
- PARENT-3-PROJECT_LOC/Tools/scripts/Profiles
-
-
-
-
- 0
-
- 6
-
- org.eclipse.ui.ide.multiFilter
- 1.0-name-matches-false-false-*.nuproject
-
-
-
-
diff --git a/Examples/spi/spi_send/Project.nuproject b/Examples/spi/spi_send/Project.nuproject
deleted file mode 100644
index 0743ed2..0000000
--- a/Examples/spi/spi_send/Project.nuproject
+++ /dev/null
@@ -1,25 +0,0 @@
-SDK_CONFIG:
- Debug:
- core: N203E
- extra_asmflags:
- archext:
- extra_cxxflags:
- cmodel: medlow
- extra_commonflags:
- abi: ilp32e
- arch: rv32emac
- toolchain: gnu
- extra_cflags:
- extra_ldflags:
- Release:
- core: N203E
- extra_asmflags:
- archext:
- extra_cxxflags:
- cmodel: medlow
- extra_commonflags:
- abi: ilp32e
- arch: rv32emac
- toolchain: gnu
- extra_cflags:
- extra_ldflags:
diff --git a/Examples/spi/spi_send/component.mk b/Examples/spi/spi_send/component.mk
deleted file mode 100644
index b1b2bc6..0000000
--- a/Examples/spi/spi_send/component.mk
+++ /dev/null
@@ -1,16 +0,0 @@
-#
-# component Makefile
-#
-
-
-C_SOURCES += \
- $(srctree)/$(PROJ)/src/isr.c \
- $(srctree)/$(PROJ)/src/main.c
-
-C_INCLUDES += -I$(srctree)/$(PROJ)/inc
-
-
-LIBS +=
-CFLAGS +=
-LDFLAGS +=
-LIBDIR +=
diff --git a/Examples/spi/spi_send/inc/isr.h b/Examples/spi/spi_send/inc/isr.h
deleted file mode 100644
index 2f4d4da..0000000
--- a/Examples/spi/spi_send/inc/isr.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file isr.h
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/09/16
- * @license
- * @description
- */
-
-#ifndef __isr_H_wuraIpBA_lTJm_HvJw_sNDo_uEd5JnucTReY__
-#define __isr_H_wuraIpBA_lTJm_HvJw_sNDo_uEd5JnucTReY__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "main.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/Examples/spi/spi_send/inc/main.h b/Examples/spi/spi_send/inc/main.h
deleted file mode 100644
index 6bc013b..0000000
--- a/Examples/spi/spi_send/inc/main.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file main.h
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/08/29
- * @license
- * @description
- */
-
-#ifndef __main_H_wxBnwdPw_lq7D_H4I5_sHPp_uXof15pFLp4V__
-#define __main_H_wxBnwdPw_lq7D_H4I5_sHPp_uXof15pFLp4V__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-#include "hal_device.h"
-#include "syslog.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/Examples/spi/spi_send/src/isr.c b/Examples/spi/spi_send/src/isr.c
deleted file mode 100644
index d19995f..0000000
--- a/Examples/spi/spi_send/src/isr.c
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file isr.c
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/09/16
- * @license
- * @description
- */
-
-
-#include "isr.h"
-
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-
diff --git a/Examples/spi/spi_slave/.cproject b/Examples/spi/spi_slave/.cproject
index 21d0162..1a0019e 100644
--- a/Examples/spi/spi_slave/.cproject
+++ b/Examples/spi/spi_slave/.cproject
@@ -40,27 +40,28 @@
-
+
-
-
+
+
+
@@ -68,14 +69,14 @@
@@ -94,7 +95,7 @@
-
-
+
+
@@ -192,10 +193,10 @@
@@ -204,14 +205,14 @@
@@ -225,7 +226,7 @@
diff --git a/Examples/spi/spi_slave/Project.nuproject b/Examples/spi/spi_slave/Project.nuproject
index 0743ed2..0072223 100644
--- a/Examples/spi/spi_slave/Project.nuproject
+++ b/Examples/spi/spi_slave/Project.nuproject
@@ -7,7 +7,7 @@ SDK_CONFIG:
cmodel: medlow
extra_commonflags:
abi: ilp32e
- arch: rv32emac
+ arch: rv32ema_zba_zbb_zbs_zca_zcb_zcmp_zcmt_zicond
toolchain: gnu
extra_cflags:
extra_ldflags:
@@ -19,7 +19,7 @@ SDK_CONFIG:
cmodel: medlow
extra_commonflags:
abi: ilp32e
- arch: rv32emac
+ arch: rv32emac_zba_zbb_zbs
toolchain: gnu
extra_cflags:
extra_ldflags:
diff --git a/Examples/spi/spi_slave/readme.md b/Examples/spi/spi_slave/readme.md
index 462faa3..0413f6b 100644
--- a/Examples/spi/spi_slave/readme.md
+++ b/Examples/spi/spi_slave/readme.md
@@ -1,11 +1,11 @@
-spi slave mode
+spi slave mode
---
This example is used to run the function of spi to transmit data in slave mode.
## Hardware and Software environment
-+ This example runs on PB5700 devices.
++ This example runs on PEC930 devices.
## How to use it ?
diff --git a/Examples/spi/spi_slave/src/main.c b/Examples/spi/spi_slave/src/main.c
index f3f62bb..c1a8802 100644
--- a/Examples/spi/spi_slave/src/main.c
+++ b/Examples/spi/spi_slave/src/main.c
@@ -16,9 +16,7 @@
//=============================================================================
// Constant Definition
//=============================================================================
-/* Use PA2 to toggle */
-#define CONFIG_TOGGLE_PORT GPIOA
-#define CONFIG_TOGGLE_PIN GPIO_Pin_01
+
//=============================================================================
// Macro Definition
//=============================================================================
@@ -58,46 +56,43 @@ void SPI_PinConfg(SPI_Type *spi, uint32_t io_sel)
//=============================================================================
int main(void)
{
- SPI_InitTypeDef SPI_InitStruct = {0};
-
- SYSCFG_ClkInitTypeDef SysClkInit = {0};
-
uint32_t tx_data[10] = {0};
uint32_t rx_data[10] = {0};
+ SPI_InitTypeDef SPI_InitStruct = {0};
+ SYSCFG_ClkInitTypeDef SysClkInit = {0};
+
+ /* Configure system clock */
SysClkInit.ClkSource = SYSCFG_ClkSrc_HSI;
SYSCFG_SysClkConfig(&SysClkInit);
+ /* set tx data */
for(int i=0; i<10; i++)
{
tx_data[i] = 0xB1A1 + i*0X101;
}
+ /* configure GPIO Pin mux of SPI */
SPI_PinConfg(SPI0, 0);
+
+ /* configure SPI */
SPI_DeInit(SPI0);
-
- {// configure I/O to toggle
- GPIO_InitTypeDef GPIO_InitStruct = {0};
- GPIO_InitStruct.GPIO_Pin = CONFIG_TOGGLE_PIN;
- GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT;
- GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL;
- GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;
- GPIO_Init(CONFIG_TOGGLE_PORT, &GPIO_InitStruct);
- }
-
SPI_InitStruct.SPI_Mode = SPI_Mode_Slave;
SPI_InitStruct.SPI_CPOL = SPI_CPOL_Low;
SPI_InitStruct.SPI_CPHA = SPI_CPHA_Effective;
- SPI_InitStruct.SPI_TxDataSize = SPI_TxDataSize_16b; //SPI_TxDataSize_8b;
+ SPI_InitStruct.SPI_TxDataSize = SPI_TxDataSize_16b;
SPI_InitStruct.SPI_BaudRatePrescaler = SPI_BaudratePrescaler_4;
SPI_InitStruct.SPI_FirstBit = SPI_FirstBit_MSB;
SPI_Init(SPI0, &SPI_InitStruct);
+ /* Enable SPI */
SPI_Enable(SPI0);
+
while(1)
{
for(int i=0; i<10; i++)
{
+ /* SPI Slave Send data */
SPI_SendData(SPI0, tx_data[i]);
while(SPI_GetFlagStatus(SPI0, SPI_STA_RXNEP_Msk) == 0);
rx_data[i] = SPI_ReceiveData(SPI0);
diff --git a/Examples/system/sys_exception/.cproject b/Examples/system/sys_exception/.cproject
deleted file mode 100644
index 21d0162..0000000
--- a/Examples/system/sys_exception/.cproject
+++ /dev/null
@@ -1,293 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Examples/system/sys_exception/.project b/Examples/system/sys_exception/.project
deleted file mode 100644
index 2183c12..0000000
--- a/Examples/system/sys_exception/.project
+++ /dev/null
@@ -1,54 +0,0 @@
-
-
- Project
-
-
-
-
-
- org.eclipse.cdt.managedbuilder.core.genmakebuilder
- clean,full,incremental,
-
-
-
-
- org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
- full,incremental,
-
-
-
-
-
- org.eclipse.cdt.core.cnature
- org.eclipse.cdt.managedbuilder.core.managedBuildNature
- org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
-
-
-
- Common
- 2
- PARENT-3-PROJECT_LOC/Common
-
-
- Drivers
- 2
- PARENT-3-PROJECT_LOC/Drivers
-
-
- Profiles
- 2
- PARENT-3-PROJECT_LOC/Tools/scripts/Profiles
-
-
-
-
- 0
-
- 6
-
- org.eclipse.ui.ide.multiFilter
- 1.0-name-matches-false-false-*.nuproject
-
-
-
-
diff --git a/Examples/system/sys_exception/Project.nuproject b/Examples/system/sys_exception/Project.nuproject
deleted file mode 100644
index 0743ed2..0000000
--- a/Examples/system/sys_exception/Project.nuproject
+++ /dev/null
@@ -1,25 +0,0 @@
-SDK_CONFIG:
- Debug:
- core: N203E
- extra_asmflags:
- archext:
- extra_cxxflags:
- cmodel: medlow
- extra_commonflags:
- abi: ilp32e
- arch: rv32emac
- toolchain: gnu
- extra_cflags:
- extra_ldflags:
- Release:
- core: N203E
- extra_asmflags:
- archext:
- extra_cxxflags:
- cmodel: medlow
- extra_commonflags:
- abi: ilp32e
- arch: rv32emac
- toolchain: gnu
- extra_cflags:
- extra_ldflags:
diff --git a/Examples/system/sys_exception/component.mk b/Examples/system/sys_exception/component.mk
deleted file mode 100644
index b1b2bc6..0000000
--- a/Examples/system/sys_exception/component.mk
+++ /dev/null
@@ -1,16 +0,0 @@
-#
-# component Makefile
-#
-
-
-C_SOURCES += \
- $(srctree)/$(PROJ)/src/isr.c \
- $(srctree)/$(PROJ)/src/main.c
-
-C_INCLUDES += -I$(srctree)/$(PROJ)/inc
-
-
-LIBS +=
-CFLAGS +=
-LDFLAGS +=
-LIBDIR +=
diff --git a/Examples/system/sys_exception/inc/isr.h b/Examples/system/sys_exception/inc/isr.h
deleted file mode 100644
index 2f4d4da..0000000
--- a/Examples/system/sys_exception/inc/isr.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file isr.h
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/09/16
- * @license
- * @description
- */
-
-#ifndef __isr_H_wuraIpBA_lTJm_HvJw_sNDo_uEd5JnucTReY__
-#define __isr_H_wuraIpBA_lTJm_HvJw_sNDo_uEd5JnucTReY__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "main.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/Examples/system/sys_exception/inc/main.h b/Examples/system/sys_exception/inc/main.h
deleted file mode 100644
index 6bc013b..0000000
--- a/Examples/system/sys_exception/inc/main.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file main.h
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/08/29
- * @license
- * @description
- */
-
-#ifndef __main_H_wxBnwdPw_lq7D_H4I5_sHPp_uXof15pFLp4V__
-#define __main_H_wxBnwdPw_lq7D_H4I5_sHPp_uXof15pFLp4V__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-#include "hal_device.h"
-#include "syslog.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/Examples/system/sys_exception/readme.md b/Examples/system/sys_exception/readme.md
deleted file mode 100644
index e55a346..0000000
--- a/Examples/system/sys_exception/readme.md
+++ /dev/null
@@ -1,26 +0,0 @@
-sys_exception
----
-
-This example is a demo project to trigger exception event with software
-
-+ It will register the exception handlers (ecall) from App layer
-
-+ Trigger exception event with instructions (ecall)
-
- ```c
- // at main.c
- __ECALL();
- ```
-
-## Log
-
-Use serial port with baudrate 115200, 8bit, no parity check.
-
-+ `ecall`
-
- ```
- Jul 17 2025 10:05:43
- Software triggers exception event
- => enter ecall handler (cause= 11)
-
- ```
diff --git a/Examples/system/sys_exception/src/isr.c b/Examples/system/sys_exception/src/isr.c
deleted file mode 100644
index d19995f..0000000
--- a/Examples/system/sys_exception/src/isr.c
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file isr.c
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/09/16
- * @license
- * @description
- */
-
-
-#include "isr.h"
-
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-
diff --git a/Examples/system/sys_mco/.cproject b/Examples/system/sys_mco/.cproject
index 21d0162..1a0019e 100644
--- a/Examples/system/sys_mco/.cproject
+++ b/Examples/system/sys_mco/.cproject
@@ -40,27 +40,28 @@
-
+
-
-
+
+
+
@@ -68,14 +69,14 @@
@@ -94,7 +95,7 @@
-
-
+
+
@@ -192,10 +193,10 @@
@@ -204,14 +205,14 @@
@@ -225,7 +226,7 @@
diff --git a/Examples/system/sys_mco/Project.nuproject b/Examples/system/sys_mco/Project.nuproject
index 0743ed2..0072223 100644
--- a/Examples/system/sys_mco/Project.nuproject
+++ b/Examples/system/sys_mco/Project.nuproject
@@ -7,7 +7,7 @@ SDK_CONFIG:
cmodel: medlow
extra_commonflags:
abi: ilp32e
- arch: rv32emac
+ arch: rv32ema_zba_zbb_zbs_zca_zcb_zcmp_zcmt_zicond
toolchain: gnu
extra_cflags:
extra_ldflags:
@@ -19,7 +19,7 @@ SDK_CONFIG:
cmodel: medlow
extra_commonflags:
abi: ilp32e
- arch: rv32emac
+ arch: rv32emac_zba_zbb_zbs
toolchain: gnu
extra_cflags:
extra_ldflags:
diff --git a/Examples/system/sys_mco/readme.md b/Examples/system/sys_mco/readme.md
index abb049a..5692066 100644
--- a/Examples/system/sys_mco/readme.md
+++ b/Examples/system/sys_mco/readme.md
@@ -5,7 +5,7 @@ This example is used to run system mco function.
## Hardware and Software environment
-+ This example runs on PB5700 devices.
++ This example runs on PEC930 devices.
## How to use it ?
@@ -29,5 +29,5 @@ This is a demo to output MCO signal (SysCLK= 60000000)
MCO output LSI
MCO output HSI-DIV
No Output
-
-```
\ No newline at end of file
+
+```
\ No newline at end of file
diff --git a/Examples/system/sys_mco/src/main.c b/Examples/system/sys_mco/src/main.c
index 5101a80..0544aa8 100644
--- a/Examples/system/sys_mco/src/main.c
+++ b/Examples/system/sys_mco/src/main.c
@@ -66,9 +66,10 @@ static bool g_IsButtonPress = false;
//=============================================================================
// Private Function Definition
//=============================================================================
-
__INTERRUPT void GPIOx_Handler(void)
{
+ SAVE_IRQ_CSR_CONTEXT();
+
if( GPIO_GetITFlag(CONFIG_BUTTON_PORT, CONFIG_BUTTON_PIN) )
{
GPIO_ClearITFlag(CONFIG_BUTTON_PORT, CONFIG_BUTTON_PIN);
@@ -76,6 +77,7 @@ __INTERRUPT void GPIOx_Handler(void)
g_IsButtonPress = true;
}
+ RESTORE_IRQ_CSR_CONTEXT();
return;
}
diff --git a/Examples/system/sys_tick_src/component.mk b/Examples/system/sys_tick_src/component.mk
deleted file mode 100644
index b1b2bc6..0000000
--- a/Examples/system/sys_tick_src/component.mk
+++ /dev/null
@@ -1,16 +0,0 @@
-#
-# component Makefile
-#
-
-
-C_SOURCES += \
- $(srctree)/$(PROJ)/src/isr.c \
- $(srctree)/$(PROJ)/src/main.c
-
-C_INCLUDES += -I$(srctree)/$(PROJ)/inc
-
-
-LIBS +=
-CFLAGS +=
-LDFLAGS +=
-LIBDIR +=
diff --git a/Examples/system/sys_tick_src/inc/isr.h b/Examples/system/sys_tick_src/inc/isr.h
deleted file mode 100644
index 2f4d4da..0000000
--- a/Examples/system/sys_tick_src/inc/isr.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file isr.h
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/09/16
- * @license
- * @description
- */
-
-#ifndef __isr_H_wuraIpBA_lTJm_HvJw_sNDo_uEd5JnucTReY__
-#define __isr_H_wuraIpBA_lTJm_HvJw_sNDo_uEd5JnucTReY__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "main.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/Examples/system/sys_tick_src/inc/main.h b/Examples/system/sys_tick_src/inc/main.h
deleted file mode 100644
index 6bc013b..0000000
--- a/Examples/system/sys_tick_src/inc/main.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file main.h
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/08/29
- * @license
- * @description
- */
-
-#ifndef __main_H_wxBnwdPw_lq7D_H4I5_sHPp_uXof15pFLp4V__
-#define __main_H_wxBnwdPw_lq7D_H4I5_sHPp_uXof15pFLp4V__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-#include "hal_device.h"
-#include "syslog.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/Examples/system/sys_tick_src/readme.md b/Examples/system/sys_tick_src/readme.md
deleted file mode 100644
index b20b22c..0000000
--- a/Examples/system/sys_tick_src/readme.md
+++ /dev/null
@@ -1,54 +0,0 @@
-sys_tick_src
----
-
-This example is used to configure the clock source of systick
-> clock source of systick
-> + LSI
-> + HSI with divider 2/4/8
-
-
-## Log
-
-Use serial port with baudrate 115200, 8bit, no parity check.
-
-```
-Sep 25 2025 13:23:03
-This is a demo projec to configure source of systick
- current tick source: LSI
-SYSCFG->SYSCLKCR_b.SYSTICKCR= 0
-delay 1 sec
- current tick source: HSI/2
-SYSCFG->SYSCLKCR_b.SYSTICKCR= 1
-delay 1 sec
- current tick source: HSI/4
-SYSCFG->SYSCLKCR_b.SYSTICKCR= 2
-delay 1 sec
- current tick source: HSI/8
-SYSCFG->SYSCLKCR_b.SYSTICKCR= 3
-delay 1 sec
- current tick source: LSI
-SYSCFG->SYSCLKCR_b.SYSTICKCR= 0
-delay 1 sec
- current tick source: HSI/2
-SYSCFG->SYSCLKCR_b.SYSTICKCR= 1
-delay 1 sec
- current tick source: HSI/4
-SYSCFG->SYSCLKCR_b.SYSTICKCR= 2
-delay 1 sec
- current tick source: HSI/8
-SYSCFG->SYSCLKCR_b.SYSTICKCR= 3
-delay 1 sec
- current tick source: LSI
-SYSCFG->SYSCLKCR_b.SYSTICKCR= 0
-delay 1 sec
- current tick source: HSI/2
-SYSCFG->SYSCLKCR_b.SYSTICKCR= 1
-delay 1 sec
- current tick source: HSI/4
-SYSCFG->SYSCLKCR_b.SYSTICKCR= 2
-delay 1 sec
- current tick source: HSI/8
-SYSCFG->SYSCLKCR_b.SYSTICKCR= 3
-delay 1 sec
- ...
-```
\ No newline at end of file
diff --git a/Examples/system/sys_tick_src/src/isr.c b/Examples/system/sys_tick_src/src/isr.c
deleted file mode 100644
index d19995f..0000000
--- a/Examples/system/sys_tick_src/src/isr.c
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file isr.c
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/09/16
- * @license
- * @description
- */
-
-
-#include "isr.h"
-
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-
diff --git a/Examples/system/sys_tick_src/src/main.c b/Examples/system/sys_tick_src/src/main.c
deleted file mode 100644
index cb88ce9..0000000
--- a/Examples/system/sys_tick_src/src/main.c
+++ /dev/null
@@ -1,126 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file main.c
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/08/29
- * @license
- * @description
- */
-
-
-#include "main.h"
-#include "isr.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-#define CONFIG_TOGGLE_IO_PORT GPIOA
-#define CONFIG_TOGGLE_IO_PIN GPIO_Pin_00
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-static void _Config_IO(void)
-{
- GPIO_InitTypeDef GPIO_InitStruct = {0};
- GPIO_InitStruct.GPIO_Pin = CONFIG_TOGGLE_IO_PIN;
- GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT;
- GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_DOWN;
- GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;
- GPIO_Init(CONFIG_TOGGLE_IO_PORT, &GPIO_InitStruct);
- return;
-}
-
-__INTERRUPT void _mtim_handler(void)
-{
- SAVE_IRQ_CSR_CONTEXT();
-
- GPIO_TogglePin(CONFIG_TOGGLE_IO_PORT, CONFIG_TOGGLE_IO_PIN);
-
- // Reload Timer Interrupt
- SysTick_Reload(g_SysTickPeriod);
-
- RESTORE_IRQ_CSR_CONTEXT();
- return;
-}
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-int main(void)
-{
- int cnt = 0;
- SYSCFG_ClkInitTypeDef SysClkInit = {0};
-
- #if 1
- SysClkInit.ClkSource = SYSCFG_ClkSrc_HSI;
- #else
- SysClkInit.ClkSource = SYSCFG_ClkSrc_FreqDiv;
- SysClkInit.SysClk_Div = SYSCFG_SysClkDiv2;
- #endif
-
- SYSCFG_SysClkConfig(&SysClkInit);
-
- sys_config_systick(SYS_TICK_1_MS);
-
- syslog_init();
-
- info("%s %s\nThis is a demo projec to configure source of systick\n",
- __DATE__, __TIME__);
-
- while(1)
- {
- SYSCFG_SysTickSrcTypeDef tick_src = SYSCFG_SysTickSrc_LSI;
-
- sys_disable_systick();
-
- switch( cnt & 0x3 )
- {
- default:
- case 0:
- SYSCFG_SetSysTickSrc(SYSCFG_SysTickSrc_LSI);
- break;
- case 1:
- SYSCFG_SetSysTickSrc(SYSCFG_SysTickSrc_HSI_Div2);
- break;
- case 2:
- SYSCFG_SetSysTickSrc(SYSCFG_SysTickSrc_HSI_Div4);
- break;
- case 3:
- SYSCFG_SetSysTickSrc(SYSCFG_SysTickSrc_HSI_Div8);
- break;
- }
-
- cnt++;
-
- sys_config_systick(SYS_TICK_1_MS);
-
- tick_src = SYSCFG_GetSysTickSrc();
-
- msg(" current tick source: %s\n",
- (tick_src == SYSCFG_SysTickSrc_HSI_Div2) ? "HSI/2" :
- (tick_src == SYSCFG_SysTickSrc_HSI_Div4) ? "HSI/4" :
- (tick_src == SYSCFG_SysTickSrc_HSI_Div8) ? "HSI/8" :
- "LSI");
-
- msg("SYSCFG->SYSCLKCR_b.SYSTICKCR= %d\n", SYSCFG->SYSCLKCR_b.SYSTICKCR);
-
- msg("delay 1 sec\n");
- sys_delay(1000);
- }
- return 0;
-}
diff --git a/Examples/system/sys_tick_swi/.cproject b/Examples/system/sys_tick_swi/.cproject
new file mode 100644
index 0000000..1a0019e
--- /dev/null
+++ b/Examples/system/sys_tick_swi/.cproject
@@ -0,0 +1,294 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Examples/comp/comp_test/.project b/Examples/system/sys_tick_swi/.project
similarity index 100%
rename from Examples/comp/comp_test/.project
rename to Examples/system/sys_tick_swi/.project
diff --git a/Examples/system/sys_tick_swi/Project.nuproject b/Examples/system/sys_tick_swi/Project.nuproject
new file mode 100644
index 0000000..0072223
--- /dev/null
+++ b/Examples/system/sys_tick_swi/Project.nuproject
@@ -0,0 +1,25 @@
+SDK_CONFIG:
+ Debug:
+ core: N203E
+ extra_asmflags:
+ archext:
+ extra_cxxflags:
+ cmodel: medlow
+ extra_commonflags:
+ abi: ilp32e
+ arch: rv32ema_zba_zbb_zbs_zca_zcb_zcmp_zcmt_zicond
+ toolchain: gnu
+ extra_cflags:
+ extra_ldflags:
+ Release:
+ core: N203E
+ extra_asmflags:
+ archext:
+ extra_cxxflags:
+ cmodel: medlow
+ extra_commonflags:
+ abi: ilp32e
+ arch: rv32emac_zba_zbb_zbs
+ toolchain: gnu
+ extra_cflags:
+ extra_ldflags:
diff --git a/Examples/systick/systick_count/.cproject b/Examples/systick/systick_count/.cproject
deleted file mode 100644
index 21d0162..0000000
--- a/Examples/systick/systick_count/.cproject
+++ /dev/null
@@ -1,293 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Examples/systick/systick_count/.project b/Examples/systick/systick_count/.project
deleted file mode 100644
index 2183c12..0000000
--- a/Examples/systick/systick_count/.project
+++ /dev/null
@@ -1,54 +0,0 @@
-
-
- Project
-
-
-
-
-
- org.eclipse.cdt.managedbuilder.core.genmakebuilder
- clean,full,incremental,
-
-
-
-
- org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
- full,incremental,
-
-
-
-
-
- org.eclipse.cdt.core.cnature
- org.eclipse.cdt.managedbuilder.core.managedBuildNature
- org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
-
-
-
- Common
- 2
- PARENT-3-PROJECT_LOC/Common
-
-
- Drivers
- 2
- PARENT-3-PROJECT_LOC/Drivers
-
-
- Profiles
- 2
- PARENT-3-PROJECT_LOC/Tools/scripts/Profiles
-
-
-
-
- 0
-
- 6
-
- org.eclipse.ui.ide.multiFilter
- 1.0-name-matches-false-false-*.nuproject
-
-
-
-
diff --git a/Examples/systick/systick_count/Project.nuproject b/Examples/systick/systick_count/Project.nuproject
deleted file mode 100644
index 0743ed2..0000000
--- a/Examples/systick/systick_count/Project.nuproject
+++ /dev/null
@@ -1,25 +0,0 @@
-SDK_CONFIG:
- Debug:
- core: N203E
- extra_asmflags:
- archext:
- extra_cxxflags:
- cmodel: medlow
- extra_commonflags:
- abi: ilp32e
- arch: rv32emac
- toolchain: gnu
- extra_cflags:
- extra_ldflags:
- Release:
- core: N203E
- extra_asmflags:
- archext:
- extra_cxxflags:
- cmodel: medlow
- extra_commonflags:
- abi: ilp32e
- arch: rv32emac
- toolchain: gnu
- extra_cflags:
- extra_ldflags:
diff --git a/Examples/systick/systick_count/component.mk b/Examples/systick/systick_count/component.mk
deleted file mode 100644
index b1b2bc6..0000000
--- a/Examples/systick/systick_count/component.mk
+++ /dev/null
@@ -1,16 +0,0 @@
-#
-# component Makefile
-#
-
-
-C_SOURCES += \
- $(srctree)/$(PROJ)/src/isr.c \
- $(srctree)/$(PROJ)/src/main.c
-
-C_INCLUDES += -I$(srctree)/$(PROJ)/inc
-
-
-LIBS +=
-CFLAGS +=
-LDFLAGS +=
-LIBDIR +=
diff --git a/Examples/systick/systick_count/inc/isr.h b/Examples/systick/systick_count/inc/isr.h
deleted file mode 100644
index 2f4d4da..0000000
--- a/Examples/systick/systick_count/inc/isr.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file isr.h
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/09/16
- * @license
- * @description
- */
-
-#ifndef __isr_H_wuraIpBA_lTJm_HvJw_sNDo_uEd5JnucTReY__
-#define __isr_H_wuraIpBA_lTJm_HvJw_sNDo_uEd5JnucTReY__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "main.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/Examples/systick/systick_count/inc/main.h b/Examples/systick/systick_count/inc/main.h
deleted file mode 100644
index 6bc013b..0000000
--- a/Examples/systick/systick_count/inc/main.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file main.h
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/08/29
- * @license
- * @description
- */
-
-#ifndef __main_H_wxBnwdPw_lq7D_H4I5_sHPp_uXof15pFLp4V__
-#define __main_H_wxBnwdPw_lq7D_H4I5_sHPp_uXof15pFLp4V__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-#include "hal_device.h"
-#include "syslog.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/Examples/systick/systick_count/readme.md b/Examples/systick/systick_count/readme.md
deleted file mode 100644
index b87d917..0000000
--- a/Examples/systick/systick_count/readme.md
+++ /dev/null
@@ -1,17 +0,0 @@
-systick count and relaod
----
-
-This example is used to run systick count function.
-
-## Hardware and Software environment
-
-+ This example runs on PB5700 devices.
-
-## How to use it ?
-
-### In order to make the program work, you must do the following:
-
-+ Open your preferred toolchain
-+ Rebuild all files and load your image into target memory
-+ Set the compare value to reload
-+ Run the example
\ No newline at end of file
diff --git a/Examples/systick/systick_count/src/isr.c b/Examples/systick/systick_count/src/isr.c
deleted file mode 100644
index d19995f..0000000
--- a/Examples/systick/systick_count/src/isr.c
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file isr.c
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/09/16
- * @license
- * @description
- */
-
-
-#include "isr.h"
-
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-
diff --git a/Examples/systick/systick_count/src/main.c b/Examples/systick/systick_count/src/main.c
deleted file mode 100644
index 6653d6c..0000000
--- a/Examples/systick/systick_count/src/main.c
+++ /dev/null
@@ -1,82 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file main.c
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/08/29
- * @license
- * @description
- */
-
-
-#include "main.h"
-#include "isr.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-/* Use PA2 to toggle */
-#define CONFIG_TOGGLE_PORT GPIOA
-#define CONFIG_TOGGLE_PIN GPIO_Pin_02
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-int main(void)
-{
- uint32_t set_cmpvalue = 0;
- uint32_t ir_flag = 0;
-
- SYSCFG_ClkInitTypeDef SysClkInit = {0};
-
- SysClkInit.ClkSource = SYSCFG_ClkSrc_HSI;
- SYSCFG_SysClkConfig(&SysClkInit);
-
- syslog_init();
-
- {// configure I/O to toggle
- GPIO_InitTypeDef GPIO_InitStruct = {0};
- GPIO_InitStruct.GPIO_Pin = CONFIG_TOGGLE_PIN;
- GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT;
- GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL;
- GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;
- GPIO_Init(CONFIG_TOGGLE_PORT, &GPIO_InitStruct);
- }
-
- set_cmpvalue = 48000;
- ir_flag = 0;
-
- SysTimer_SetCompareValue(set_cmpvalue);
- SysTimer_SetLoadValue(0);
- SysTimer_Start();
-
- while(1)
- {
- ir_flag = sys_get_IRQPending(SysTimer_IRQn);
- if( ir_flag )
- {
- ir_flag = 0;
- SysTimer_SetLoadValue(0);
- GPIO_TogglePin(CONFIG_TOGGLE_PORT, CONFIG_TOGGLE_PIN);
- }
- }
-
-
- return 0;
-}
diff --git a/Examples/systick/systick_interrupt/.cproject b/Examples/systick/systick_interrupt/.cproject
deleted file mode 100644
index 21d0162..0000000
--- a/Examples/systick/systick_interrupt/.cproject
+++ /dev/null
@@ -1,293 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Examples/systick/systick_interrupt/.project b/Examples/systick/systick_interrupt/.project
deleted file mode 100644
index 2183c12..0000000
--- a/Examples/systick/systick_interrupt/.project
+++ /dev/null
@@ -1,54 +0,0 @@
-
-
- Project
-
-
-
-
-
- org.eclipse.cdt.managedbuilder.core.genmakebuilder
- clean,full,incremental,
-
-
-
-
- org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
- full,incremental,
-
-
-
-
-
- org.eclipse.cdt.core.cnature
- org.eclipse.cdt.managedbuilder.core.managedBuildNature
- org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
-
-
-
- Common
- 2
- PARENT-3-PROJECT_LOC/Common
-
-
- Drivers
- 2
- PARENT-3-PROJECT_LOC/Drivers
-
-
- Profiles
- 2
- PARENT-3-PROJECT_LOC/Tools/scripts/Profiles
-
-
-
-
- 0
-
- 6
-
- org.eclipse.ui.ide.multiFilter
- 1.0-name-matches-false-false-*.nuproject
-
-
-
-
diff --git a/Examples/systick/systick_interrupt/Project.nuproject b/Examples/systick/systick_interrupt/Project.nuproject
deleted file mode 100644
index 0743ed2..0000000
--- a/Examples/systick/systick_interrupt/Project.nuproject
+++ /dev/null
@@ -1,25 +0,0 @@
-SDK_CONFIG:
- Debug:
- core: N203E
- extra_asmflags:
- archext:
- extra_cxxflags:
- cmodel: medlow
- extra_commonflags:
- abi: ilp32e
- arch: rv32emac
- toolchain: gnu
- extra_cflags:
- extra_ldflags:
- Release:
- core: N203E
- extra_asmflags:
- archext:
- extra_cxxflags:
- cmodel: medlow
- extra_commonflags:
- abi: ilp32e
- arch: rv32emac
- toolchain: gnu
- extra_cflags:
- extra_ldflags:
diff --git a/Examples/systick/systick_interrupt/component.mk b/Examples/systick/systick_interrupt/component.mk
deleted file mode 100644
index b1b2bc6..0000000
--- a/Examples/systick/systick_interrupt/component.mk
+++ /dev/null
@@ -1,16 +0,0 @@
-#
-# component Makefile
-#
-
-
-C_SOURCES += \
- $(srctree)/$(PROJ)/src/isr.c \
- $(srctree)/$(PROJ)/src/main.c
-
-C_INCLUDES += -I$(srctree)/$(PROJ)/inc
-
-
-LIBS +=
-CFLAGS +=
-LDFLAGS +=
-LIBDIR +=
diff --git a/Examples/systick/systick_interrupt/inc/isr.h b/Examples/systick/systick_interrupt/inc/isr.h
deleted file mode 100644
index 2f4d4da..0000000
--- a/Examples/systick/systick_interrupt/inc/isr.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file isr.h
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/09/16
- * @license
- * @description
- */
-
-#ifndef __isr_H_wuraIpBA_lTJm_HvJw_sNDo_uEd5JnucTReY__
-#define __isr_H_wuraIpBA_lTJm_HvJw_sNDo_uEd5JnucTReY__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "main.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/Examples/systick/systick_interrupt/inc/main.h b/Examples/systick/systick_interrupt/inc/main.h
deleted file mode 100644
index 6bc013b..0000000
--- a/Examples/systick/systick_interrupt/inc/main.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file main.h
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/08/29
- * @license
- * @description
- */
-
-#ifndef __main_H_wxBnwdPw_lq7D_H4I5_sHPp_uXof15pFLp4V__
-#define __main_H_wxBnwdPw_lq7D_H4I5_sHPp_uXof15pFLp4V__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-#include "hal_device.h"
-#include "syslog.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/Examples/systick/systick_interrupt/readme.md b/Examples/systick/systick_interrupt/readme.md
deleted file mode 100644
index dba7b0f..0000000
--- a/Examples/systick/systick_interrupt/readme.md
+++ /dev/null
@@ -1,20 +0,0 @@
-systick interrupt and stop
----
-
-This example is used to run tim match and interrupt function.
-
-## Hardware and Software environment
-
-+ This example runs on PB5700 devices.
-
-## How to use it ?
-
-### In order to make the program work, you must do the following:
-
-+ Open your preferred toolchain
-+ Rebuild all files and load your image into target memory
-+ Select the interrupt mode or count stop mode
-+ Run the example
-
-in interrupt mode :will cause interrupt
-in count stop mode :will stop when count is set to number of times
\ No newline at end of file
diff --git a/Examples/systick/systick_interrupt/src/isr.c b/Examples/systick/systick_interrupt/src/isr.c
deleted file mode 100644
index d19995f..0000000
--- a/Examples/systick/systick_interrupt/src/isr.c
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file isr.c
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/09/16
- * @license
- * @description
- */
-
-
-#include "isr.h"
-
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-
diff --git a/Examples/systick/systick_interrupt/src/main.c b/Examples/systick/systick_interrupt/src/main.c
deleted file mode 100644
index 142fd8c..0000000
--- a/Examples/systick/systick_interrupt/src/main.c
+++ /dev/null
@@ -1,124 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file main.c
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/08/29
- * @license
- * @description
- */
-
-
-#include "main.h"
-#include "isr.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-/* Use PA2 to toggle */
-#define CONFIG_TOGGLE_PORT GPIOA
-#define CONFIG_TOGGLE_PIN GPIO_Pin_02
-
-
-#define SYSTICK_INT_EN //systick will be able to generate interrupts
-//#define SYSTICK_COUNT //SYSTICK will stop when the set number of cycles is reached
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-__INTERRUPT void SYSTICK_Handler(void)
-{
- SysTimer_SetLoadValue(0);
- GPIO_TogglePin(CONFIG_TOGGLE_PORT, CONFIG_TOGGLE_PIN);
-
- return;
-
-}
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-int main(void)
-{
- uint32_t set_cmpvalue = 0;
- uint32_t ir_flag = 0;
- uint32_t cnt_time = 0;
-
- SYSCFG_ClkInitTypeDef SysClkInit = {0};
-
- SysClkInit.ClkSource = SYSCFG_ClkSrc_HSI;
- SYSCFG_SysClkConfig(&SysClkInit);
-
- syslog_init();
-
-
- {// configure I/O to toggle
- GPIO_InitTypeDef GPIO_InitStruct = {0};
- GPIO_InitStruct.GPIO_Pin = CONFIG_TOGGLE_PIN;
- GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT;
- GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL;
- GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;
- GPIO_Init(CONFIG_TOGGLE_PORT, &GPIO_InitStruct);
- }
-
-#ifdef SYSTICK_INT_EN
- sys_irq_attr_t irq_attr = { .trig_mode = SYS_IRQ_TRIGGER_LEVEL, };
- sys_register_IRQ(SysTimer_IRQn, SYSTICK_Handler, &irq_attr);
- sys_enable_girq();
-#endif
-
-
- set_cmpvalue = 48000;
- ir_flag = 0;
- cnt_time = 15;
-
- SysTimer_SetCompareValue(set_cmpvalue);
- SysTimer_SetLoadValue(0);
- SysTimer_Start();
-
- while(1)
- {
-
-#ifndef SYSTICK_INT_EN
- ir_flag = IRQC_GetPendingIRQ(SysTimer_IRQn);
- if(ir_flag == 1)
- {
- ir_flag = 0;
- SysTimer_SetLoadValue(0);
- GPIO_TogglePin(CONFIG_TOGGLE_PORT, CONFIG_TOGGLE_PIN);
-
-#ifdef SYSTICK_COUNT
-
- cnt_time--;
- if(cnt_time == 0)
- {
- SysTimer_Stop();
-
- cnt_time = 0;
- }
-#endif
-
- }
-
-
-
-#endif
-
- __NOP();
- }
-
-
- return 0;
-}
diff --git a/Examples/systick/systick_soft_interrupt/.cproject b/Examples/systick/systick_soft_interrupt/.cproject
deleted file mode 100644
index 21d0162..0000000
--- a/Examples/systick/systick_soft_interrupt/.cproject
+++ /dev/null
@@ -1,293 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Examples/systick/systick_soft_interrupt/.project b/Examples/systick/systick_soft_interrupt/.project
deleted file mode 100644
index 2183c12..0000000
--- a/Examples/systick/systick_soft_interrupt/.project
+++ /dev/null
@@ -1,54 +0,0 @@
-
-
- Project
-
-
-
-
-
- org.eclipse.cdt.managedbuilder.core.genmakebuilder
- clean,full,incremental,
-
-
-
-
- org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
- full,incremental,
-
-
-
-
-
- org.eclipse.cdt.core.cnature
- org.eclipse.cdt.managedbuilder.core.managedBuildNature
- org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
-
-
-
- Common
- 2
- PARENT-3-PROJECT_LOC/Common
-
-
- Drivers
- 2
- PARENT-3-PROJECT_LOC/Drivers
-
-
- Profiles
- 2
- PARENT-3-PROJECT_LOC/Tools/scripts/Profiles
-
-
-
-
- 0
-
- 6
-
- org.eclipse.ui.ide.multiFilter
- 1.0-name-matches-false-false-*.nuproject
-
-
-
-
diff --git a/Examples/systick/systick_soft_interrupt/Project.nuproject b/Examples/systick/systick_soft_interrupt/Project.nuproject
deleted file mode 100644
index 0743ed2..0000000
--- a/Examples/systick/systick_soft_interrupt/Project.nuproject
+++ /dev/null
@@ -1,25 +0,0 @@
-SDK_CONFIG:
- Debug:
- core: N203E
- extra_asmflags:
- archext:
- extra_cxxflags:
- cmodel: medlow
- extra_commonflags:
- abi: ilp32e
- arch: rv32emac
- toolchain: gnu
- extra_cflags:
- extra_ldflags:
- Release:
- core: N203E
- extra_asmflags:
- archext:
- extra_cxxflags:
- cmodel: medlow
- extra_commonflags:
- abi: ilp32e
- arch: rv32emac
- toolchain: gnu
- extra_cflags:
- extra_ldflags:
diff --git a/Examples/systick/systick_soft_interrupt/component.mk b/Examples/systick/systick_soft_interrupt/component.mk
deleted file mode 100644
index b1b2bc6..0000000
--- a/Examples/systick/systick_soft_interrupt/component.mk
+++ /dev/null
@@ -1,16 +0,0 @@
-#
-# component Makefile
-#
-
-
-C_SOURCES += \
- $(srctree)/$(PROJ)/src/isr.c \
- $(srctree)/$(PROJ)/src/main.c
-
-C_INCLUDES += -I$(srctree)/$(PROJ)/inc
-
-
-LIBS +=
-CFLAGS +=
-LDFLAGS +=
-LIBDIR +=
diff --git a/Examples/systick/systick_soft_interrupt/inc/isr.h b/Examples/systick/systick_soft_interrupt/inc/isr.h
deleted file mode 100644
index 2f4d4da..0000000
--- a/Examples/systick/systick_soft_interrupt/inc/isr.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file isr.h
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/09/16
- * @license
- * @description
- */
-
-#ifndef __isr_H_wuraIpBA_lTJm_HvJw_sNDo_uEd5JnucTReY__
-#define __isr_H_wuraIpBA_lTJm_HvJw_sNDo_uEd5JnucTReY__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "main.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/Examples/systick/systick_soft_interrupt/inc/main.h b/Examples/systick/systick_soft_interrupt/inc/main.h
deleted file mode 100644
index 6bc013b..0000000
--- a/Examples/systick/systick_soft_interrupt/inc/main.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file main.h
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/08/29
- * @license
- * @description
- */
-
-#ifndef __main_H_wxBnwdPw_lq7D_H4I5_sHPp_uXof15pFLp4V__
-#define __main_H_wxBnwdPw_lq7D_H4I5_sHPp_uXof15pFLp4V__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-#include "hal_device.h"
-#include "syslog.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/Examples/systick/systick_soft_interrupt/readme.md b/Examples/systick/systick_soft_interrupt/readme.md
deleted file mode 100644
index 6033511..0000000
--- a/Examples/systick/systick_soft_interrupt/readme.md
+++ /dev/null
@@ -1,16 +0,0 @@
-systick Software interrupt
----
-
-This example is used to run interrupt function.
-
-## Hardware and Software environment
-
-+ This example runs on PB5700 devices.
-
-## How to use it ?
-
-### In order to make the program work, you must do the following:
-
-+ Open your preferred toolchain
-+ Rebuild all files and load your image into target memory
-+ Run the example
\ No newline at end of file
diff --git a/Examples/systick/systick_soft_interrupt/src/isr.c b/Examples/systick/systick_soft_interrupt/src/isr.c
deleted file mode 100644
index d19995f..0000000
--- a/Examples/systick/systick_soft_interrupt/src/isr.c
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file isr.c
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/09/16
- * @license
- * @description
- */
-
-
-#include "isr.h"
-
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-
diff --git a/Examples/systick/systick_soft_interrupt/src/main.c b/Examples/systick/systick_soft_interrupt/src/main.c
deleted file mode 100644
index f6aabb8..0000000
--- a/Examples/systick/systick_soft_interrupt/src/main.c
+++ /dev/null
@@ -1,87 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file main.c
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/08/29
- * @license
- * @description
- */
-
-
-#include "main.h"
-#include "isr.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-/* Use PA2 to toggle */
-#define CONFIG_TOGGLE_PORT GPIOA
-#define CONFIG_TOGGLE_PIN GPIO_Pin_02
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-__INTERRUPT void MSIP_Handler(void)
-{
- SysTimer_ClearSWIRQ();
- GPIO_TogglePin(CONFIG_TOGGLE_PORT, CONFIG_TOGGLE_PIN);
-
- return;
-
-}
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-int main(void)
-{
- uint32_t cnt_time = 48000;
-
- SYSCFG_ClkInitTypeDef SysClkInit = {0};
-
- SysClkInit.ClkSource = SYSCFG_ClkSrc_HSI;
- SYSCFG_SysClkConfig(&SysClkInit);
-
- syslog_init();
-
-
- {// configure I/O to toggle
- GPIO_InitTypeDef GPIO_InitStruct = {0};
- GPIO_InitStruct.GPIO_Pin = CONFIG_TOGGLE_PIN;
- GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT;
- GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL;
- GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;
- GPIO_Init(CONFIG_TOGGLE_PORT, &GPIO_InitStruct);
- }
-
- sys_irq_attr_t irq_attr = { .trig_mode = SYS_IRQ_TRIGGER_LEVEL, };
- sys_register_IRQ(SysSW_IRQn, MSIP_Handler, &irq_attr);
- sys_enable_girq();
-
-
- //SysTimer_SetSWIRQ();
-
- while(1)
- {
- while(cnt_time--);
- cnt_time = 48000;
- SysTimer_SetSWIRQ();
- }
-
-
- return 0;
-}
diff --git a/Examples/template/demo_project/.cproject b/Examples/template/demo_project/.cproject
index d9ac06f..1a0019e 100644
--- a/Examples/template/demo_project/.cproject
+++ b/Examples/template/demo_project/.cproject
@@ -45,23 +45,23 @@
-
-
-
+
+
+
@@ -69,14 +69,14 @@
@@ -95,7 +95,7 @@
-
-
+
+
@@ -193,10 +193,10 @@
@@ -205,14 +205,14 @@
@@ -226,7 +226,7 @@
diff --git a/Examples/template/demo_project/readme.md b/Examples/template/demo_project/readme.md
index b4f1dcd..a718da5 100644
--- a/Examples/template/demo_project/readme.md
+++ b/Examples/template/demo_project/readme.md
@@ -1,10 +1,8 @@
demo_project
---
-This example is a demo project to descript
-> + How to log message
+This example is a demo project to descript `how to log message`
## Log
Use serial port with baudrate 115200, 8bit, no parity check.
-
diff --git a/Examples/tim/tim_6StepOutput/.cproject b/Examples/tim/tim_6StepOutput/.cproject
index 21d0162..1a0019e 100644
--- a/Examples/tim/tim_6StepOutput/.cproject
+++ b/Examples/tim/tim_6StepOutput/.cproject
@@ -40,27 +40,28 @@
-
+
-
-
+
+
+
@@ -68,14 +69,14 @@
@@ -94,7 +95,7 @@
-
-
+
+
@@ -192,10 +193,10 @@
@@ -204,14 +205,14 @@
@@ -225,7 +226,7 @@
diff --git a/Examples/tim/tim_6StepOutput/Project.nuproject b/Examples/tim/tim_6StepOutput/Project.nuproject
index 0743ed2..0072223 100644
--- a/Examples/tim/tim_6StepOutput/Project.nuproject
+++ b/Examples/tim/tim_6StepOutput/Project.nuproject
@@ -7,7 +7,7 @@ SDK_CONFIG:
cmodel: medlow
extra_commonflags:
abi: ilp32e
- arch: rv32emac
+ arch: rv32ema_zba_zbb_zbs_zca_zcb_zcmp_zcmt_zicond
toolchain: gnu
extra_cflags:
extra_ldflags:
@@ -19,7 +19,7 @@ SDK_CONFIG:
cmodel: medlow
extra_commonflags:
abi: ilp32e
- arch: rv32emac
+ arch: rv32emac_zba_zbb_zbs
toolchain: gnu
extra_cflags:
extra_ldflags:
diff --git a/Examples/tim/tim_6StepOutput/readme.md b/Examples/tim/tim_6StepOutput/readme.md
index 29cf801..5c72b54 100644
--- a/Examples/tim/tim_6StepOutput/readme.md
+++ b/Examples/tim/tim_6StepOutput/readme.md
@@ -5,7 +5,7 @@ This example is a demo project to TIM 6StepOutput
## Hardware and Software environment
-+ This example runs on PB5700 devices.
++ This example runs on PEC930 devices.
## Log
diff --git a/Examples/tim/tim_ETRFClearOCxREF/.cproject b/Examples/tim/tim_ETRFClearOCxREF/.cproject
deleted file mode 100644
index 21d0162..0000000
--- a/Examples/tim/tim_ETRFClearOCxREF/.cproject
+++ /dev/null
@@ -1,293 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Examples/tim/tim_ETRFClearOCxREF/.project b/Examples/tim/tim_ETRFClearOCxREF/.project
deleted file mode 100644
index 2183c12..0000000
--- a/Examples/tim/tim_ETRFClearOCxREF/.project
+++ /dev/null
@@ -1,54 +0,0 @@
-
-
- Project
-
-
-
-
-
- org.eclipse.cdt.managedbuilder.core.genmakebuilder
- clean,full,incremental,
-
-
-
-
- org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
- full,incremental,
-
-
-
-
-
- org.eclipse.cdt.core.cnature
- org.eclipse.cdt.managedbuilder.core.managedBuildNature
- org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
-
-
-
- Common
- 2
- PARENT-3-PROJECT_LOC/Common
-
-
- Drivers
- 2
- PARENT-3-PROJECT_LOC/Drivers
-
-
- Profiles
- 2
- PARENT-3-PROJECT_LOC/Tools/scripts/Profiles
-
-
-
-
- 0
-
- 6
-
- org.eclipse.ui.ide.multiFilter
- 1.0-name-matches-false-false-*.nuproject
-
-
-
-
diff --git a/Examples/tim/tim_ETRFClearOCxREF/Project.nuproject b/Examples/tim/tim_ETRFClearOCxREF/Project.nuproject
deleted file mode 100644
index 0743ed2..0000000
--- a/Examples/tim/tim_ETRFClearOCxREF/Project.nuproject
+++ /dev/null
@@ -1,25 +0,0 @@
-SDK_CONFIG:
- Debug:
- core: N203E
- extra_asmflags:
- archext:
- extra_cxxflags:
- cmodel: medlow
- extra_commonflags:
- abi: ilp32e
- arch: rv32emac
- toolchain: gnu
- extra_cflags:
- extra_ldflags:
- Release:
- core: N203E
- extra_asmflags:
- archext:
- extra_cxxflags:
- cmodel: medlow
- extra_commonflags:
- abi: ilp32e
- arch: rv32emac
- toolchain: gnu
- extra_cflags:
- extra_ldflags:
diff --git a/Examples/tim/tim_ETRFClearOCxREF/component.mk b/Examples/tim/tim_ETRFClearOCxREF/component.mk
deleted file mode 100644
index b1b2bc6..0000000
--- a/Examples/tim/tim_ETRFClearOCxREF/component.mk
+++ /dev/null
@@ -1,16 +0,0 @@
-#
-# component Makefile
-#
-
-
-C_SOURCES += \
- $(srctree)/$(PROJ)/src/isr.c \
- $(srctree)/$(PROJ)/src/main.c
-
-C_INCLUDES += -I$(srctree)/$(PROJ)/inc
-
-
-LIBS +=
-CFLAGS +=
-LDFLAGS +=
-LIBDIR +=
diff --git a/Examples/tim/tim_ETRFClearOCxREF/inc/isr.h b/Examples/tim/tim_ETRFClearOCxREF/inc/isr.h
deleted file mode 100644
index 2f4d4da..0000000
--- a/Examples/tim/tim_ETRFClearOCxREF/inc/isr.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file isr.h
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/09/16
- * @license
- * @description
- */
-
-#ifndef __isr_H_wuraIpBA_lTJm_HvJw_sNDo_uEd5JnucTReY__
-#define __isr_H_wuraIpBA_lTJm_HvJw_sNDo_uEd5JnucTReY__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "main.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/Examples/tim/tim_ETRFClearOCxREF/inc/main.h b/Examples/tim/tim_ETRFClearOCxREF/inc/main.h
deleted file mode 100644
index 6bc013b..0000000
--- a/Examples/tim/tim_ETRFClearOCxREF/inc/main.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file main.h
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/08/29
- * @license
- * @description
- */
-
-#ifndef __main_H_wxBnwdPw_lq7D_H4I5_sHPp_uXof15pFLp4V__
-#define __main_H_wxBnwdPw_lq7D_H4I5_sHPp_uXof15pFLp4V__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-#include "hal_device.h"
-#include "syslog.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/Examples/tim/tim_ETRFClearOCxREF/readme.md b/Examples/tim/tim_ETRFClearOCxREF/readme.md
deleted file mode 100644
index aeea203..0000000
--- a/Examples/tim/tim_ETRFClearOCxREF/readme.md
+++ /dev/null
@@ -1,14 +0,0 @@
-TIM_ETRFClearOCxREF_project
----
-
-This example is a demo project to TIM ETRFClearOCxREF
-
-## Hardware and Software environment
-
-+ This example runs on PB5700 devices.
-
-## Log
-
-+ Enable OC1CE
-+ ETRF input high level ,set OC1REF = 0
-
diff --git a/Examples/tim/tim_ETRFClearOCxREF/src/isr.c b/Examples/tim/tim_ETRFClearOCxREF/src/isr.c
deleted file mode 100644
index d19995f..0000000
--- a/Examples/tim/tim_ETRFClearOCxREF/src/isr.c
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file isr.c
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/09/16
- * @license
- * @description
- */
-
-
-#include "isr.h"
-
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-
diff --git a/Examples/tim/tim_ETRFClearOCxREF/src/main.c b/Examples/tim/tim_ETRFClearOCxREF/src/main.c
deleted file mode 100644
index d3f3599..0000000
--- a/Examples/tim/tim_ETRFClearOCxREF/src/main.c
+++ /dev/null
@@ -1,113 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file main.c
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/08/29
- * @license
- * @description
- */
-
-
-#include "main.h"
-#include "isr.h"
-#include "hal_tim.h"
-#include "hal_gpio.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-#define CONFIG_USE_TIM2
-//#define CONFIG_USE_EPWM
-
-#if defined(CONFIG_USE_TIM2)
- #define TIMx TIM2
- #define CONFIG_IRQ_ID TIM2_IRQn
-#elif defined(CONFIG_USE_EPWM)
- #define TIMx EPWM
- #define CONFIG_IRQ_ID EPWM_IRQn
-#endif
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-int main(void)
-{
- SYSCFG_ClkInitTypeDef SysClkInit = {0};
-
- SysClkInit.ClkSource = SYSCFG_ClkSrc_HSI;
- SYSCFG_SysClkConfig(&SysClkInit);
-
-#if defined(CONFIG_USE_TIM2)
- GPIO_InitTypeDef GPIO_InitStruct;
- GPIO_InitStruct.GPIO_Pin = GPIO_Pin_02 | GPIO_Pin_03 | GPIO_Pin_04 | GPIO_Pin_05;
- GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF;
- GPIO_InitStruct.GPIO_AF_Mode = GPIO_AF_5;
- GPIO_Init(GPIOA, &GPIO_InitStruct);
- /*TIM2_ETR -> PA15*/
- GPIO_PeriAFConfig(GPIOA,GPIO_Peri_T2ETR,GPIO_PeriAF_2);
-#elif defined(CONFIG_USE_EPWM)
- GPIO_InitTypeDef GPIO_InitStruct;
- GPIO_InitStruct.GPIO_Pin = GPIO_Pin_00 | GPIO_Pin_02 | GPIO_Pin_04;
- GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF;
- GPIO_InitStruct.GPIO_AF_Mode = GPIO_AF_6;
- GPIO_Init(GPIOA, &GPIO_InitStruct);
- /*EPWM_ETR -> PA15*/
- GPIO_PeriAFConfig(GPIOA,GPIO_Peri_EPETR,GPIO_PeriAF_2);
-#endif
-
- GPIO_InitStruct.GPIO_Pin = GPIO_Pin_06 | GPIO_Pin_07;
- GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT;
- GPIO_Init(GPIOA, &GPIO_InitStruct);
-
- /* Resets the TIMx */
- TIM_DeInit(TIMx);
-
- TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
- /* Time Base configuration */
- TIM_TimeBaseStructure.TIM_Prescaler = 48 - 1;
- TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
- TIM_TimeBaseStructure.TIM_Period = 1000 - 1;
- TIM_TimeBaseStructure.TIM_ClockDivision = 0;
- TIM_TimeBaseStructure.TIM_RepetitionCounter = 0;
- TIM_TimeBaseInit(TIMx, &TIM_TimeBaseStructure);
-
- TIM_SetCompare1(TIMx,800);//CH1 DUTY:80%
- TIM_SelectOCxM(TIMx,TIM_Channel_1,TIM_OCMode_PWM1);
- TIM_CCxCmd(TIMx,TIM_Channel_1,TIM_CCx_Enable);
-
- TIM_SetCompare2(TIMx,400);//CH2 DUTY:40%
- TIM_SelectOCxM(TIMx,TIM_Channel_2,TIM_OCMode_PWM1);
- TIM_CCxCmd(TIMx,TIM_Channel_2,TIM_CCx_Enable);
-
- TIM_SetCompare3(TIMx,250);//CH3 DUTY:25%
- TIM_SelectOCxM(TIMx,TIM_Channel_3,TIM_OCMode_PWM1);
- TIM_CCxCmd(TIMx,TIM_Channel_3,TIM_CCx_Enable);
-
- REG_WRITE_MASK(TIMx->CCMR1_OUTPUT, TIM_CCMR1_OUTPUT_OC1CE_Msk, 1 << TIM_CCMR1_OUTPUT_OC1CE_Pos);
- /* TIM1 counter enable */
- TIM_Cmd(TIMx, ENABLE);
- /* Main Output Enable */
- TIM_CtrlPWMOutputs(TIMx, ENABLE);
-
- while(1)
- {
-
- }
-}
diff --git a/Examples/tim/tim_InputCapture/.cproject b/Examples/tim/tim_InputCapture/.cproject
index 21d0162..1a0019e 100644
--- a/Examples/tim/tim_InputCapture/.cproject
+++ b/Examples/tim/tim_InputCapture/.cproject
@@ -40,27 +40,28 @@
-
+
-
-
+
+
+
@@ -68,14 +69,14 @@
@@ -94,7 +95,7 @@
-
-
+
+
@@ -192,10 +193,10 @@
@@ -204,14 +205,14 @@
@@ -225,7 +226,7 @@
diff --git a/Examples/tim/tim_InputCapture/Project.nuproject b/Examples/tim/tim_InputCapture/Project.nuproject
index 0743ed2..0072223 100644
--- a/Examples/tim/tim_InputCapture/Project.nuproject
+++ b/Examples/tim/tim_InputCapture/Project.nuproject
@@ -7,7 +7,7 @@ SDK_CONFIG:
cmodel: medlow
extra_commonflags:
abi: ilp32e
- arch: rv32emac
+ arch: rv32ema_zba_zbb_zbs_zca_zcb_zcmp_zcmt_zicond
toolchain: gnu
extra_cflags:
extra_ldflags:
@@ -19,7 +19,7 @@ SDK_CONFIG:
cmodel: medlow
extra_commonflags:
abi: ilp32e
- arch: rv32emac
+ arch: rv32emac_zba_zbb_zbs
toolchain: gnu
extra_cflags:
extra_ldflags:
diff --git a/Examples/tim/tim_InputCapture/readme.md b/Examples/tim/tim_InputCapture/readme.md
index 9aa9700..eecff10 100644
--- a/Examples/tim/tim_InputCapture/readme.md
+++ b/Examples/tim/tim_InputCapture/readme.md
@@ -5,7 +5,7 @@ This example is a demo project to TIM inputCapture
## Hardware and Software environment
-+ This example runs on PB5700 devices.
++ This example runs on PEC930 devices.
## Log
diff --git a/Examples/tim/tim_InputCapture/src/main.c b/Examples/tim/tim_InputCapture/src/main.c
index 12cd455..9d77cf6 100644
--- a/Examples/tim/tim_InputCapture/src/main.c
+++ b/Examples/tim/tim_InputCapture/src/main.c
@@ -55,10 +55,15 @@ void TIMx_handler(void);
//=============================================================================
int main(void)
{
+ TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure = {0};
+ TIM_ICInitTypeDef TIM_ICInitStruct;
SYSCFG_ClkInitTypeDef SysClkInit = {0};
+ /* Configure system clock */
SysClkInit.ClkSource = SYSCFG_ClkSrc_HSI;
SYSCFG_SysClkConfig(&SysClkInit);
+
+ /* configure GPIO Pin mux of TIM capture */
#if defined(CONFIG_USE_TIM2)
/* SET TCAP1 -> PA15*/
GPIO_PeriAFConfig(GPIOA,GPIO_Peri_TCAP1,GPIO_PeriAF_2);
@@ -67,12 +72,10 @@ int main(void)
GPIO_PeriAFConfig(GPIOA,GPIO_Peri_ECAP1,GPIO_PeriAF_2);
#endif
+ /* configure TIM */
TIM_DeInit(TIMx);
-
- TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure = {0};
TIM_TimeBaseInit(TIMx,&TIM_TimeBaseStructure);
- TIM_ICInitTypeDef TIM_ICInitStruct;
TIM_ICInitStruct.TIM_Channel = TIM_Channel_2;
TIM_ICInitStruct.TIM_ICPolarity = TIM_ICPolarity_Rising;
TIM_ICInitStruct.TIM_ICSelection = TIM_ICSelection_DirectTI;
@@ -82,12 +85,14 @@ int main(void)
/* Enable the CC2 Interrupt Request */
TIM_ITConfig(TIMx, TIM_IT_CC2, ENABLE);
- __enable_irq();
-
+
sys_irq_attr_t irq_attr = { .trig_mode = SYS_IRQ_TRIGGER_LEVEL, };
sys_register_IRQ(CONFIG_IRQ_ID, TIMx_handler, &irq_attr);
+ sys_enable_girq();
+ /* Sets the tim Counter Register value */
TIM_SetAutoreload(TIMx,0xFFFF);
+
/* TIM enable counter */
TIM_Cmd(TIMx, ENABLE);
while(1)
@@ -99,6 +104,8 @@ int main(void)
__INTERRUPT void TIMx_handler(void)
{
+ SAVE_IRQ_CSR_CONTEXT(); // Save CSRs
+
if(TIM_GetITStatus(TIMx, TIM_IT_CC2) == SET)
{
/* Clear TIM3 Capture compare interrupt pending bit */
@@ -121,8 +128,12 @@ __INTERRUPT void TIMx_handler(void)
{
Capture = ((0xFFFF - IC2ReadValue1) + IC2ReadValue2);
}
+ /* get frequency */
TIMFreq = (uint32_t) SystemClock / Capture;
CaptureNumber = 0;
}
}
+
+ RESTORE_IRQ_CSR_CONTEXT(); // Restore CSRs
+ return;
}
diff --git a/Examples/tim/tim_Synchro/.cproject b/Examples/tim/tim_Synchro/.cproject
deleted file mode 100644
index 21d0162..0000000
--- a/Examples/tim/tim_Synchro/.cproject
+++ /dev/null
@@ -1,293 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Examples/tim/tim_Synchro/.project b/Examples/tim/tim_Synchro/.project
deleted file mode 100644
index 2183c12..0000000
--- a/Examples/tim/tim_Synchro/.project
+++ /dev/null
@@ -1,54 +0,0 @@
-
-
- Project
-
-
-
-
-
- org.eclipse.cdt.managedbuilder.core.genmakebuilder
- clean,full,incremental,
-
-
-
-
- org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
- full,incremental,
-
-
-
-
-
- org.eclipse.cdt.core.cnature
- org.eclipse.cdt.managedbuilder.core.managedBuildNature
- org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
-
-
-
- Common
- 2
- PARENT-3-PROJECT_LOC/Common
-
-
- Drivers
- 2
- PARENT-3-PROJECT_LOC/Drivers
-
-
- Profiles
- 2
- PARENT-3-PROJECT_LOC/Tools/scripts/Profiles
-
-
-
-
- 0
-
- 6
-
- org.eclipse.ui.ide.multiFilter
- 1.0-name-matches-false-false-*.nuproject
-
-
-
-
diff --git a/Examples/tim/tim_Synchro/Project.nuproject b/Examples/tim/tim_Synchro/Project.nuproject
deleted file mode 100644
index 0743ed2..0000000
--- a/Examples/tim/tim_Synchro/Project.nuproject
+++ /dev/null
@@ -1,25 +0,0 @@
-SDK_CONFIG:
- Debug:
- core: N203E
- extra_asmflags:
- archext:
- extra_cxxflags:
- cmodel: medlow
- extra_commonflags:
- abi: ilp32e
- arch: rv32emac
- toolchain: gnu
- extra_cflags:
- extra_ldflags:
- Release:
- core: N203E
- extra_asmflags:
- archext:
- extra_cxxflags:
- cmodel: medlow
- extra_commonflags:
- abi: ilp32e
- arch: rv32emac
- toolchain: gnu
- extra_cflags:
- extra_ldflags:
diff --git a/Examples/tim/tim_Synchro/component.mk b/Examples/tim/tim_Synchro/component.mk
deleted file mode 100644
index b1b2bc6..0000000
--- a/Examples/tim/tim_Synchro/component.mk
+++ /dev/null
@@ -1,16 +0,0 @@
-#
-# component Makefile
-#
-
-
-C_SOURCES += \
- $(srctree)/$(PROJ)/src/isr.c \
- $(srctree)/$(PROJ)/src/main.c
-
-C_INCLUDES += -I$(srctree)/$(PROJ)/inc
-
-
-LIBS +=
-CFLAGS +=
-LDFLAGS +=
-LIBDIR +=
diff --git a/Examples/tim/tim_Synchro/inc/isr.h b/Examples/tim/tim_Synchro/inc/isr.h
deleted file mode 100644
index 2f4d4da..0000000
--- a/Examples/tim/tim_Synchro/inc/isr.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file isr.h
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/09/16
- * @license
- * @description
- */
-
-#ifndef __isr_H_wuraIpBA_lTJm_HvJw_sNDo_uEd5JnucTReY__
-#define __isr_H_wuraIpBA_lTJm_HvJw_sNDo_uEd5JnucTReY__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "main.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/Examples/tim/tim_Synchro/inc/main.h b/Examples/tim/tim_Synchro/inc/main.h
deleted file mode 100644
index 6bc013b..0000000
--- a/Examples/tim/tim_Synchro/inc/main.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file main.h
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/08/29
- * @license
- * @description
- */
-
-#ifndef __main_H_wxBnwdPw_lq7D_H4I5_sHPp_uXof15pFLp4V__
-#define __main_H_wxBnwdPw_lq7D_H4I5_sHPp_uXof15pFLp4V__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-#include "hal_device.h"
-#include "syslog.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/Examples/tim/tim_Synchro/readme.md b/Examples/tim/tim_Synchro/readme.md
deleted file mode 100644
index b79032d..0000000
--- a/Examples/tim/tim_Synchro/readme.md
+++ /dev/null
@@ -1,19 +0,0 @@
-TIM_Synchro_project
----
-
-This example is a demo project to TIM Synchro
-
-## Hardware and Software environment
-
-+ This example runs on PB5700 devices.
-
-## Log
-
-+ TIM Synchronize with a trigger signal
-+ CONFIG_SYNCHRO_EXT External pins
-+ CONFIG_SYNCHRO_ITR1 TIM0
-+ Reset mode: After the rising edge, the counter will reset to zero and start counting again
-+ Gate control mode: PWM has output at high level and no output at low level
-+ Trigger mode: The counter only starts after the rising edge arrives
-
-
diff --git a/Examples/tim/tim_Synchro/src/isr.c b/Examples/tim/tim_Synchro/src/isr.c
deleted file mode 100644
index d19995f..0000000
--- a/Examples/tim/tim_Synchro/src/isr.c
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file isr.c
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/09/16
- * @license
- * @description
- */
-
-
-#include "isr.h"
-
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-
diff --git a/Examples/tim/tim_Synchro/src/main.c b/Examples/tim/tim_Synchro/src/main.c
deleted file mode 100644
index ac9e90e..0000000
--- a/Examples/tim/tim_Synchro/src/main.c
+++ /dev/null
@@ -1,137 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file main.c
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/08/29
- * @license
- * @description
- */
-
-
-#include "main.h"
-#include "isr.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-#define CONFIG_USE_TIM2
-//#define CONFIG_USE_EPWM
-
-#define CONFIG_SYNCHRO_EXT
-//#define CONFIG_SYNCHRO_ITR1
-
-
-#if defined(CONFIG_USE_TIM2)
- #define TIMx TIM2
- #define CONFIG_IRQ_ID TIM2_IRQn
-#elif defined(CONFIG_USE_EPWM)
- #define TIMx EPWM
- #define CONFIG_IRQ_ID EPWM_IRQn
-#endif
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-void TIM0_Handler(void);
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-int main(void)
-{
- SYSCFG_ClkInitTypeDef SysClkInit = {0};
-
- SysClkInit.ClkSource = SYSCFG_ClkSrc_HSI;
- SYSCFG_SysClkConfig(&SysClkInit);
-
-#if defined(CONFIG_USE_TIM2)
- GPIO_InitTypeDef GPIO_InitStruct;
- GPIO_InitStruct.GPIO_Pin = GPIO_Pin_02 | GPIO_Pin_03 | GPIO_Pin_04 | GPIO_Pin_05;
- GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF;
- GPIO_InitStruct.GPIO_AF_Mode = GPIO_AF_5;
- GPIO_Init(GPIOA, &GPIO_InitStruct);
- /*TIM2_ETR -> PA15*/
- GPIO_PeriAFConfig(GPIOA,GPIO_Peri_T2ETR,GPIO_PeriAF_2);
-#elif defined(CONFIG_USE_EPWM)
- GPIO_InitTypeDef GPIO_InitStruct;
- GPIO_InitStruct.GPIO_Pin = GPIO_Pin_00 | GPIO_Pin_02 | GPIO_Pin_04;
- GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF;
- GPIO_InitStruct.GPIO_AF_Mode = GPIO_AF_6;
- GPIO_Init(GPIOA, &GPIO_InitStruct);
- /*EPWM_ETR -> PA15*/
- GPIO_PeriAFConfig(GPIOA,GPIO_Peri_EPETR,GPIO_PeriAF_2);
-#endif
-
- GPIO_InitStruct.GPIO_Pin = GPIO_Pin_06 ;
- GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT;
- GPIO_Init(GPIOA, &GPIO_InitStruct);
-
- TIM_DeInit(TIMx);
- TIM_TimeBaseInitTypeDef TIM_TimeBaseInitStruct;
- TIM_TimeBaseStructInit(&TIM_TimeBaseInitStruct);
- TIM_TimeBaseInitStruct.TIM_Prescaler = 48 - 1;
- TIM_TimeBaseInitStruct.TIM_CounterMode = TIM_CounterMode_Up;
- TIM_TimeBaseInitStruct.TIM_Period = 1000 - 1;//1ms
- TIM_TimeBaseInitStruct.TIM_ClockDivision = TIM_CKD_Div1;
- TIM_TimeBaseInitStruct.TIM_RepetitionCounter = 0;
- TIM_TimeBaseInit(TIMx, &TIM_TimeBaseInitStruct);
- TIM_SetCompare1(TIMx,800);//CH1 DUTY:40%
- TIM_SelectOCxM(TIMx,TIM_Channel_1,TIM_OCMode_PWM1);
- TIM_CCxCmd(TIMx,TIM_Channel_1,TIM_CCx_Enable);
-
- TIM_SetCompare3(TIMx,250);//CH3 DUTY:25%
- TIM_SelectOCxM(TIMx,TIM_Channel_3,TIM_OCMode_PWM1);
- TIM_CCxCmd(TIMx,TIM_Channel_3,TIM_CCx_Enable);
-
-#if defined(CONFIG_SYNCHRO_EXT)
- TIM_ITRxExternalClockConfig(TIMx,TIM_TS_ETRF);
-#elif defined(CONFIG_SYNCHRO_ITR1)
- LPTIM_InitTypeDef Init = {0};
- Init.LPTIM_Prescaler = 48 - 1;
- Init.LPTIM_ClockSource = LPTIM_CLK_Src_SysClk;
- Init.LPTIM_MatchMode = LPTIM_MatchMode_IRQ | LPTIM_MatchMode_Reset;
- Init.LPTIM_MatchValue = 1800 - 1;
- LPTIM_Init(TIM0, &Init);
-
- sys_irq_attr_t irq_attr = { .trig_mode = SYS_IRQ_TRIGGER_LEVEL, };
- sys_register_IRQ(TIM0_IRQn, TIM0_Handler, &irq_attr);
- sys_enable_girq();
- LPTIM_ITConfig(TIM0, true);
- LPTIM_Enable(TIM0);
- TIM_ITRxExternalClockConfig(TIMx,TIM_TS_ITR1);
-#endif
-
- /*set SLAVE MODE*/
- TIM_SelectSlaveMode(TIMx,TIM_SlaveMode_Reset);
-
- TIM_Cmd(TIMx, ENABLE);
- TIM_CtrlPWMOutputs(TIMx,ENABLE);
-
- while(1)
- {
-
- }
-}
-
-__INTERRUPT void TIM0_Handler(void)
-{
- if(LPTIM_GetFlagStatus(TIM0, LPTIM_Flag_Match0))
- {
- /* Clear TIM0 Updata */
- LPTIM_ClearFlag(TIM0, LPTIM_Flag_Match0);
- GPIO_TogglePin(GPIOA,GPIO_Pin_06);
- }
-}
diff --git a/Examples/tim/tim_clk_sel/.cproject b/Examples/tim/tim_clk_sel/.cproject
deleted file mode 100644
index 21d0162..0000000
--- a/Examples/tim/tim_clk_sel/.cproject
+++ /dev/null
@@ -1,293 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Examples/tim/tim_clk_sel/.project b/Examples/tim/tim_clk_sel/.project
deleted file mode 100644
index 2183c12..0000000
--- a/Examples/tim/tim_clk_sel/.project
+++ /dev/null
@@ -1,54 +0,0 @@
-
-
- Project
-
-
-
-
-
- org.eclipse.cdt.managedbuilder.core.genmakebuilder
- clean,full,incremental,
-
-
-
-
- org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
- full,incremental,
-
-
-
-
-
- org.eclipse.cdt.core.cnature
- org.eclipse.cdt.managedbuilder.core.managedBuildNature
- org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
-
-
-
- Common
- 2
- PARENT-3-PROJECT_LOC/Common
-
-
- Drivers
- 2
- PARENT-3-PROJECT_LOC/Drivers
-
-
- Profiles
- 2
- PARENT-3-PROJECT_LOC/Tools/scripts/Profiles
-
-
-
-
- 0
-
- 6
-
- org.eclipse.ui.ide.multiFilter
- 1.0-name-matches-false-false-*.nuproject
-
-
-
-
diff --git a/Examples/tim/tim_clk_sel/Project.nuproject b/Examples/tim/tim_clk_sel/Project.nuproject
deleted file mode 100644
index 0743ed2..0000000
--- a/Examples/tim/tim_clk_sel/Project.nuproject
+++ /dev/null
@@ -1,25 +0,0 @@
-SDK_CONFIG:
- Debug:
- core: N203E
- extra_asmflags:
- archext:
- extra_cxxflags:
- cmodel: medlow
- extra_commonflags:
- abi: ilp32e
- arch: rv32emac
- toolchain: gnu
- extra_cflags:
- extra_ldflags:
- Release:
- core: N203E
- extra_asmflags:
- archext:
- extra_cxxflags:
- cmodel: medlow
- extra_commonflags:
- abi: ilp32e
- arch: rv32emac
- toolchain: gnu
- extra_cflags:
- extra_ldflags:
diff --git a/Examples/tim/tim_clk_sel/component.mk b/Examples/tim/tim_clk_sel/component.mk
deleted file mode 100644
index b1b2bc6..0000000
--- a/Examples/tim/tim_clk_sel/component.mk
+++ /dev/null
@@ -1,16 +0,0 @@
-#
-# component Makefile
-#
-
-
-C_SOURCES += \
- $(srctree)/$(PROJ)/src/isr.c \
- $(srctree)/$(PROJ)/src/main.c
-
-C_INCLUDES += -I$(srctree)/$(PROJ)/inc
-
-
-LIBS +=
-CFLAGS +=
-LDFLAGS +=
-LIBDIR +=
diff --git a/Examples/tim/tim_clk_sel/inc/isr.h b/Examples/tim/tim_clk_sel/inc/isr.h
deleted file mode 100644
index 2f4d4da..0000000
--- a/Examples/tim/tim_clk_sel/inc/isr.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file isr.h
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/09/16
- * @license
- * @description
- */
-
-#ifndef __isr_H_wuraIpBA_lTJm_HvJw_sNDo_uEd5JnucTReY__
-#define __isr_H_wuraIpBA_lTJm_HvJw_sNDo_uEd5JnucTReY__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "main.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/Examples/tim/tim_clk_sel/inc/main.h b/Examples/tim/tim_clk_sel/inc/main.h
deleted file mode 100644
index 6bc013b..0000000
--- a/Examples/tim/tim_clk_sel/inc/main.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file main.h
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/08/29
- * @license
- * @description
- */
-
-#ifndef __main_H_wxBnwdPw_lq7D_H4I5_sHPp_uXof15pFLp4V__
-#define __main_H_wxBnwdPw_lq7D_H4I5_sHPp_uXof15pFLp4V__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-#include "hal_device.h"
-#include "syslog.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/Examples/tim/tim_clk_sel/readme.md b/Examples/tim/tim_clk_sel/readme.md
deleted file mode 100644
index 2ae306b..0000000
--- a/Examples/tim/tim_clk_sel/readme.md
+++ /dev/null
@@ -1,16 +0,0 @@
-TIMx_CLKSEL_project
----
-
-This example is a demo project to TIMx_CLKSEL
-
-## Hardware and Software environment
-
-+ This example runs on PB5700 devices.
-
-## Log
-
-+ CONFIG_CKINT :System Clock
-+ CONFIG_EXTMODE1_ETR :ETR pin input
-+ CONFIG_EXTMODE2_ETR :ETR pin input
-+ CONFIG_EXTMODE1_ITR1 :ITR1(ITR1 -> TIM0,Need to clear the flag bit)
-
diff --git a/Examples/tim/tim_clk_sel/src/isr.c b/Examples/tim/tim_clk_sel/src/isr.c
deleted file mode 100644
index d19995f..0000000
--- a/Examples/tim/tim_clk_sel/src/isr.c
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file isr.c
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/09/16
- * @license
- * @description
- */
-
-
-#include "isr.h"
-
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-
diff --git a/Examples/tim/tim_clk_sel/src/main.c b/Examples/tim/tim_clk_sel/src/main.c
deleted file mode 100644
index 9a78f06..0000000
--- a/Examples/tim/tim_clk_sel/src/main.c
+++ /dev/null
@@ -1,146 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file main.c
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/08/29
- * @license
- * @description
- */
-
-
-#include "main.h"
-#include "isr.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-#define CONFIG_USE_TIM2
-//#define CONFIG_USE_EPWM
-
-#define CONFIG_CKINT
-//#define CONFIG_EXTMODE1_ETR
-//#define CONFIG_EXTMODE2_ETR
-//#define CONFIG_EXTMODE1_ITR1
-
-#if defined(CONFIG_USE_TIM2)
- #define TIMx TIM2
- #define CONFIG_IRQ_ID TIM2_IRQn
-#elif defined(CONFIG_USE_EPWM)
- #define TIMx EPWM
- #define CONFIG_IRQ_ID EPWM_IRQn
-#endif
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-void TIM0_Handler(void);
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-int main(void)
-{
- SYSCFG_ClkInitTypeDef SysClkInit = {0};
-
- SysClkInit.ClkSource = SYSCFG_ClkSrc_HSI;
- SYSCFG_SysClkConfig(&SysClkInit);
-
-#if defined(CONFIG_USE_TIM2)
- GPIO_InitTypeDef GPIO_InitStruct;
- GPIO_InitStruct.GPIO_Pin = GPIO_Pin_02 | GPIO_Pin_03 | GPIO_Pin_04 | GPIO_Pin_05;
- GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF;
- GPIO_InitStruct.GPIO_AF_Mode = GPIO_AF_5;
- GPIO_Init(GPIOA, &GPIO_InitStruct);
- /*TIM2_ETR -> PA15*/
- GPIO_PeriAFConfig(GPIOA,GPIO_Peri_T2ETR,GPIO_PeriAF_2);
-#elif defined(CONFIG_USE_EPWM)
- GPIO_InitTypeDef GPIO_InitStruct;
- GPIO_InitStruct.GPIO_Pin = GPIO_Pin_00 |GPIO_Pin_02 | GPIO_Pin_04;
- GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF;
- GPIO_InitStruct.GPIO_AF_Mode = GPIO_AF_6;
- GPIO_Init(GPIOA, &GPIO_InitStruct);
- /*EPWM_ETR -> PA15*/
- GPIO_PeriAFConfig(GPIOA,GPIO_Peri_EPETR,GPIO_PeriAF_2);
-#endif
-
- TIM_DeInit(TIMx);
-
- TIM_TimeBaseInitTypeDef TIM_TimeBaseInitStruct;
- TIM_TimeBaseStructInit(&TIM_TimeBaseInitStruct);
- TIM_TimeBaseInitStruct.TIM_Prescaler = 1 - 1;
- TIM_TimeBaseInitStruct.TIM_CounterMode = TIM_CounterMode_Up;
- TIM_TimeBaseInitStruct.TIM_Period = 1000-1;//1ms
- TIM_TimeBaseInitStruct.TIM_ClockDivision = TIM_CKD_Div1;
- TIM_TimeBaseInitStruct.TIM_RepetitionCounter = 0;
- TIM_TimeBaseInit(TIMx, &TIM_TimeBaseInitStruct);
-#if defined(CONFIG_CKINT)
- TIM_InternalClockConfig(TIMx);
-#elif defined(CONFIG_EXTMODE1_ETR)
- TIM_ETRClockMode1Config(TIMx,TIM_ExtTRGPSC_OFF,TIM_ExtTRGPolarity_NonInverted,0x0);
-#elif defined(CONFIG_EXTMODE2_ETR)
- TIM_ETRClockMode2Config(TIMx,TIM_ExtTRGPSC_DIV2,TIM_ExtTRGPolarity_NonInverted,0x0);
-#elif defined(CONFIG_EXTMODE1_ITR1)
- LPTIM_InitTypeDef Init = {0};
- Init.LPTIM_Prescaler = 0;
- Init.LPTIM_ClockSource = LPTIM_CLK_Src_SysClk;
- Init.LPTIM_MatchMode = LPTIM_MatchMode_IRQ | LPTIM_MatchMode_Reset;
- Init.LPTIM_MatchValue = 48 - 1;
- LPTIM_Init(TIM0, &Init);
-
- LPTIM_ITConfig(TIM0, true);
- LPTIM_Enable(TIM0);
- TIM_ITRxExternalClockConfig(TIMx,TIM_TS_ITR1);
-#endif
-
- TIM_SetCompare1(TIMx,800);//CH1 DUTY:80%
- TIM_SelectOCxM(TIMx,TIM_Channel_1,TIM_OCMode_PWM1);
- TIM_CCxCmd(TIMx,TIM_Channel_1,TIM_CCx_Enable);
-
- TIM_SetCompare2(TIMx,400);//CH2 DUTY:40%
- TIM_SelectOCxM(TIMx,TIM_Channel_2,TIM_OCMode_PWM1);
- TIM_CCxCmd(TIMx,TIM_Channel_2,TIM_CCx_Enable);
-
- TIM_SetCompare3(TIMx,250);//CH3 DUTY:25%
- TIM_SelectOCxM(TIMx,TIM_Channel_3,TIM_OCMode_PWM1);
- TIM_CCxCmd(TIMx,TIM_Channel_3,TIM_CCx_Enable);
-
- TIM_SetCompare4(TIMx,100);//CH4 DUTY:10%
- TIM_SelectOCxM(TIMx,TIM_Channel_4,TIM_OCMode_PWM1);
- TIM_CCxCmd(TIMx,TIM_Channel_4,TIM_CCx_Enable);
-
- TIM_Cmd(TIMx, ENABLE);
- TIM_CtrlPWMOutputs(TIMx,ENABLE);
- /*ITR1/2/3 -> TIMx CLK,ITR1/2/3 Interrupt Enable must be after TIMx Enable*/
-#if defined(CONFIG_EXTMODE1_ITR1)
- sys_irq_attr_t irq_attr = { .trig_mode = SYS_IRQ_TRIGGER_LEVEL, };
- sys_register_IRQ(TIM0_IRQn, TIM0_Handler, &irq_attr);
- sys_enable_girq();
-#endif
- while(1)
- {
-
- }
-}
-
-__INTERRUPT void TIM0_Handler(void)
-{
- if( LPTIM_GetFlagStatus(TIM0, LPTIM_Flag_Match0) )
- {
- LPTIM_ClearFlag(TIM0, LPTIM_Flag_Match0);
- }
-}
diff --git a/Examples/tim/tim_encoder/.cproject b/Examples/tim/tim_encoder/.cproject
deleted file mode 100644
index 21d0162..0000000
--- a/Examples/tim/tim_encoder/.cproject
+++ /dev/null
@@ -1,293 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Examples/tim/tim_encoder/.project b/Examples/tim/tim_encoder/.project
deleted file mode 100644
index 2183c12..0000000
--- a/Examples/tim/tim_encoder/.project
+++ /dev/null
@@ -1,54 +0,0 @@
-
-
- Project
-
-
-
-
-
- org.eclipse.cdt.managedbuilder.core.genmakebuilder
- clean,full,incremental,
-
-
-
-
- org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
- full,incremental,
-
-
-
-
-
- org.eclipse.cdt.core.cnature
- org.eclipse.cdt.managedbuilder.core.managedBuildNature
- org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
-
-
-
- Common
- 2
- PARENT-3-PROJECT_LOC/Common
-
-
- Drivers
- 2
- PARENT-3-PROJECT_LOC/Drivers
-
-
- Profiles
- 2
- PARENT-3-PROJECT_LOC/Tools/scripts/Profiles
-
-
-
-
- 0
-
- 6
-
- org.eclipse.ui.ide.multiFilter
- 1.0-name-matches-false-false-*.nuproject
-
-
-
-
diff --git a/Examples/tim/tim_encoder/Project.nuproject b/Examples/tim/tim_encoder/Project.nuproject
deleted file mode 100644
index 0743ed2..0000000
--- a/Examples/tim/tim_encoder/Project.nuproject
+++ /dev/null
@@ -1,25 +0,0 @@
-SDK_CONFIG:
- Debug:
- core: N203E
- extra_asmflags:
- archext:
- extra_cxxflags:
- cmodel: medlow
- extra_commonflags:
- abi: ilp32e
- arch: rv32emac
- toolchain: gnu
- extra_cflags:
- extra_ldflags:
- Release:
- core: N203E
- extra_asmflags:
- archext:
- extra_cxxflags:
- cmodel: medlow
- extra_commonflags:
- abi: ilp32e
- arch: rv32emac
- toolchain: gnu
- extra_cflags:
- extra_ldflags:
diff --git a/Examples/tim/tim_encoder/component.mk b/Examples/tim/tim_encoder/component.mk
deleted file mode 100644
index b1b2bc6..0000000
--- a/Examples/tim/tim_encoder/component.mk
+++ /dev/null
@@ -1,16 +0,0 @@
-#
-# component Makefile
-#
-
-
-C_SOURCES += \
- $(srctree)/$(PROJ)/src/isr.c \
- $(srctree)/$(PROJ)/src/main.c
-
-C_INCLUDES += -I$(srctree)/$(PROJ)/inc
-
-
-LIBS +=
-CFLAGS +=
-LDFLAGS +=
-LIBDIR +=
diff --git a/Examples/tim/tim_encoder/inc/isr.h b/Examples/tim/tim_encoder/inc/isr.h
deleted file mode 100644
index 2f4d4da..0000000
--- a/Examples/tim/tim_encoder/inc/isr.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file isr.h
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/09/16
- * @license
- * @description
- */
-
-#ifndef __isr_H_wuraIpBA_lTJm_HvJw_sNDo_uEd5JnucTReY__
-#define __isr_H_wuraIpBA_lTJm_HvJw_sNDo_uEd5JnucTReY__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "main.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/Examples/tim/tim_encoder/inc/main.h b/Examples/tim/tim_encoder/inc/main.h
deleted file mode 100644
index 6bc013b..0000000
--- a/Examples/tim/tim_encoder/inc/main.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file main.h
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/08/29
- * @license
- * @description
- */
-
-#ifndef __main_H_wxBnwdPw_lq7D_H4I5_sHPp_uXof15pFLp4V__
-#define __main_H_wxBnwdPw_lq7D_H4I5_sHPp_uXof15pFLp4V__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-#include "hal_device.h"
-#include "syslog.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/Examples/tim/tim_encoder/readme.md b/Examples/tim/tim_encoder/readme.md
deleted file mode 100644
index 7e7312d..0000000
--- a/Examples/tim/tim_encoder/readme.md
+++ /dev/null
@@ -1,19 +0,0 @@
-TIM_encoder_project
----
-
-This example is a demo project to TIM encoder
-
-## Hardware and Software environment
-
-+ This example runs on PB5700 devices.
-
-## Log
-
-+ CAP0(PA14)/CAP1(PA15)/CAP2(PB0),PA6,PA7,PA8 set output
-+ PA6 connects PA14,PA7 connects PA15,PA8 connects PB0
-+ Set channel 1->T1, channel2 -> T2 , ARR to 65535
-+ Set the encoder mode
-+ Use PA6 and PA7 to output 3000 pulses
-+ Capture register values
-
-
diff --git a/Examples/tim/tim_encoder/src/isr.c b/Examples/tim/tim_encoder/src/isr.c
deleted file mode 100644
index d19995f..0000000
--- a/Examples/tim/tim_encoder/src/isr.c
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file isr.c
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/09/16
- * @license
- * @description
- */
-
-
-#include "isr.h"
-
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-
diff --git a/Examples/tim/tim_encoder/src/main.c b/Examples/tim/tim_encoder/src/main.c
deleted file mode 100644
index 5651ea3..0000000
--- a/Examples/tim/tim_encoder/src/main.c
+++ /dev/null
@@ -1,114 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file main.c
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/08/29
- * @license
- * @description
- */
-
-
-#include "main.h"
-#include "isr.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-//#define CONFIG_USE_TIM2
-#define CONFIG_USE_EPWM
-
-#if defined(CONFIG_USE_TIM2)
- #define TIMx TIM2
- #define CONFIG_IRQ_ID TIM2_IRQn
-#elif defined(CONFIG_USE_EPWM)
- #define TIMx EPWM
- #define CONFIG_IRQ_ID EPWM_IRQn
-#endif
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-uint32_t delayCounter = 0;
-uint32_t encoderCounter = 0;
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-//
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-int main(void)
-{
- SYSCFG_ClkInitTypeDef SysClkInit = {0};
-
- SysClkInit.ClkSource = SYSCFG_ClkSrc_HSI;
- SYSCFG_SysClkConfig(&SysClkInit);
-
-#if defined(CONFIG_USE_TIM2)
- /*TIM2 TCAP0 -> PA14,TCAP1 -> PA15, TCAP2 -> PB0*/
- GPIO_PeriAFConfig(GPIOA,GPIO_Peri_TCAP0,GPIO_PeriAF_1);
- GPIO_PeriAFConfig(GPIOA,GPIO_Peri_TCAP1,GPIO_PeriAF_2);
- GPIO_PeriAFConfig(GPIOA,GPIO_Peri_TCAP2,GPIO_PeriAF_3);
-#elif defined(CONFIG_USE_EPWM)
- /*EPWM ECAP0 -> PA14,ECAP1 -> PA15, ECAP2 -> PB0*/
- GPIO_PeriAFConfig(GPIOA,GPIO_Peri_ECAP0,GPIO_PeriAF_1);
- GPIO_PeriAFConfig(GPIOA,GPIO_Peri_ECAP1,GPIO_PeriAF_2);
- GPIO_PeriAFConfig(GPIOA,GPIO_Peri_ECAP2,GPIO_PeriAF_3);
-#endif
- GPIO_InitTypeDef GPIO_InitStruct;
- GPIO_InitStruct.GPIO_Pin = GPIO_Pin_06 | GPIO_Pin_07 | GPIO_Pin_08 ;
- GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT;
- GPIO_Init(GPIOA, &GPIO_InitStruct);
-
- TIM_DeInit(TIMx);
- TIM_TimeBaseInitTypeDef TIM_TimeBaseInitStruct;
- TIM_TimeBaseInitStruct.TIM_Prescaler = 0;
- TIM_TimeBaseInitStruct.TIM_CounterMode = TIM_CounterMode_Up;
- TIM_TimeBaseInitStruct.TIM_Period = 65535;
- TIM_TimeBaseInitStruct.TIM_ClockDivision = TIM_CKD_Div1;
- TIM_TimeBaseInitStruct.TIM_RepetitionCounter = 0;
- TIM_TimeBaseInit(TIMx, &TIM_TimeBaseInitStruct);
-
- TIM_ICInitTypeDef TIM_ICInitStruct;
- TIM_ICInitStruct.TIM_Channel = TIM_Channel_1;
- TIM_ICInitStruct.TIM_ICPolarity = TIM_ICPolarity_Rising;
- TIM_ICInitStruct.TIM_ICSelection = TIM_ICSelection_DirectTI;
- TIM_ICInitStruct.TIM_ICFilter = 0xF;
- TIM_ICInit(TIMx, &TIM_ICInitStruct);
-
- TIM_ICInitStruct.TIM_Channel = TIM_Channel_2;
- TIM_ICInitStruct.TIM_ICPolarity = TIM_ICPolarity_Rising;
- TIM_ICInitStruct.TIM_ICSelection = TIM_ICSelection_DirectTI;
- TIM_ICInitStruct.TIM_ICFilter = 0xF;
- TIM_ICInit(TIMx, &TIM_ICInitStruct);
-
- TIM_EncoderInterfaceConfig(TIMx,TIM_EncoderMode_TI1,TIM_ICPolarity_Rising,TIM_ICPolarity_Rising);
- TIM_Cmd(TIMx, ENABLE);
-
- /*GPIO output 3000 pulses,PA6 -> PA14(channel1 T1 ),PA7 -> PA15(channel2 T2)*/
- for(encoderCounter = 0;encoderCounter < 3000 ;encoderCounter ++)
- {
- GPIO_SetBits(GPIOA,GPIO_Pin_06);
- for(delayCounter = 0;delayCounter < 200 ;delayCounter ++);
- GPIO_SetBits(GPIOA,GPIO_Pin_07);
- for(delayCounter = 0;delayCounter < 200 ;delayCounter ++);
- GPIO_ResetBits(GPIOA,GPIO_Pin_06);
- for(delayCounter = 0;delayCounter < 200 ;delayCounter ++);
- GPIO_ResetBits(GPIOA,GPIO_Pin_07);
- for(delayCounter = 0;delayCounter < 200 ;delayCounter ++);
- }
- while(1)
- {
-
- }
-}
diff --git a/Examples/tim/tim_forceOutput/.cproject b/Examples/tim/tim_forceOutput/.cproject
index 21d0162..1a0019e 100644
--- a/Examples/tim/tim_forceOutput/.cproject
+++ b/Examples/tim/tim_forceOutput/.cproject
@@ -40,27 +40,28 @@
-
+
-
-
+
+
+
@@ -68,14 +69,14 @@
@@ -94,7 +95,7 @@
-
-
+
+
@@ -192,10 +193,10 @@
@@ -204,14 +205,14 @@
@@ -225,7 +226,7 @@
diff --git a/Examples/tim/tim_forceOutput/Project.nuproject b/Examples/tim/tim_forceOutput/Project.nuproject
index 0743ed2..0072223 100644
--- a/Examples/tim/tim_forceOutput/Project.nuproject
+++ b/Examples/tim/tim_forceOutput/Project.nuproject
@@ -7,7 +7,7 @@ SDK_CONFIG:
cmodel: medlow
extra_commonflags:
abi: ilp32e
- arch: rv32emac
+ arch: rv32ema_zba_zbb_zbs_zca_zcb_zcmp_zcmt_zicond
toolchain: gnu
extra_cflags:
extra_ldflags:
@@ -19,7 +19,7 @@ SDK_CONFIG:
cmodel: medlow
extra_commonflags:
abi: ilp32e
- arch: rv32emac
+ arch: rv32emac_zba_zbb_zbs
toolchain: gnu
extra_cflags:
extra_ldflags:
diff --git a/Examples/tim/tim_forceOutput/readme.md b/Examples/tim/tim_forceOutput/readme.md
index 2ca819a..3fdd5a2 100644
--- a/Examples/tim/tim_forceOutput/readme.md
+++ b/Examples/tim/tim_forceOutput/readme.md
@@ -5,11 +5,11 @@ This example is a demo project to TIM forceOutput
## Hardware and Software environment
-+ This example runs on PB5700 devices.
++ This example runs on PEC930 devices.
## Log
-+ Enable force output and delay
++ Enable force output and delay
+ Disable force output and delay
+ You can see PWM for SET GPIO(EPWM -> PA0 ,TIM2 -> PA2)
diff --git a/Examples/tim/tim_forceOutput/src/main.c b/Examples/tim/tim_forceOutput/src/main.c
index 5f5a61a..b8c2b8c 100644
--- a/Examples/tim/tim_forceOutput/src/main.c
+++ b/Examples/tim/tim_forceOutput/src/main.c
@@ -47,6 +47,12 @@ uint16_t delayCounter = 0;
//=============================================================================
int main(void)
{
+ SYSCFG_ClkInitTypeDef SysClkInit = {0};
+
+ /* Configure system clock */
+ SysClkInit.ClkSource = SYSCFG_ClkSrc_HSI;
+ SYSCFG_SysClkConfig(&SysClkInit);
+
#if defined(CONFIG_USE_TIM2)
GPIO_InitTypeDef GPIO_InitStruct;
GPIO_InitStruct.GPIO_Pin = GPIO_Pin_02 ;
@@ -65,8 +71,10 @@ int main(void)
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure = {0};
TIM_TimeBaseInit(TIMx,&TIM_TimeBaseStructure);
+
/* TIM1 counter enable */
TIM_Cmd(TIMx, ENABLE);
+
/* Main Output Enable */
TIM_CtrlPWMOutputs(TIMx, ENABLE);
while(1)
@@ -75,6 +83,7 @@ int main(void)
for(delayCounter = 0; delayCounter < 0x1000;delayCounter++);
TIM_SelectOCxM(TIMx,TIM_Channel_1,TIM_ForcedAction_Inactive);
TIM_CCxCmd(TIMx,TIM_Channel_1,TIM_CCx_Enable);
+
/* TIM_ForcedAction_Active*/
for(delayCounter = 0; delayCounter < 0x1000;delayCounter++);
TIM_SelectOCxM(TIMx,TIM_Channel_1,TIM_ForcedAction_Active);
diff --git a/Examples/tim/tim_onePulseOutput/.cproject b/Examples/tim/tim_onePulseOutput/.cproject
deleted file mode 100644
index 21d0162..0000000
--- a/Examples/tim/tim_onePulseOutput/.cproject
+++ /dev/null
@@ -1,293 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Examples/tim/tim_onePulseOutput/.project b/Examples/tim/tim_onePulseOutput/.project
deleted file mode 100644
index 2183c12..0000000
--- a/Examples/tim/tim_onePulseOutput/.project
+++ /dev/null
@@ -1,54 +0,0 @@
-
-
- Project
-
-
-
-
-
- org.eclipse.cdt.managedbuilder.core.genmakebuilder
- clean,full,incremental,
-
-
-
-
- org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
- full,incremental,
-
-
-
-
-
- org.eclipse.cdt.core.cnature
- org.eclipse.cdt.managedbuilder.core.managedBuildNature
- org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
-
-
-
- Common
- 2
- PARENT-3-PROJECT_LOC/Common
-
-
- Drivers
- 2
- PARENT-3-PROJECT_LOC/Drivers
-
-
- Profiles
- 2
- PARENT-3-PROJECT_LOC/Tools/scripts/Profiles
-
-
-
-
- 0
-
- 6
-
- org.eclipse.ui.ide.multiFilter
- 1.0-name-matches-false-false-*.nuproject
-
-
-
-
diff --git a/Examples/tim/tim_onePulseOutput/Project.nuproject b/Examples/tim/tim_onePulseOutput/Project.nuproject
deleted file mode 100644
index 0743ed2..0000000
--- a/Examples/tim/tim_onePulseOutput/Project.nuproject
+++ /dev/null
@@ -1,25 +0,0 @@
-SDK_CONFIG:
- Debug:
- core: N203E
- extra_asmflags:
- archext:
- extra_cxxflags:
- cmodel: medlow
- extra_commonflags:
- abi: ilp32e
- arch: rv32emac
- toolchain: gnu
- extra_cflags:
- extra_ldflags:
- Release:
- core: N203E
- extra_asmflags:
- archext:
- extra_cxxflags:
- cmodel: medlow
- extra_commonflags:
- abi: ilp32e
- arch: rv32emac
- toolchain: gnu
- extra_cflags:
- extra_ldflags:
diff --git a/Examples/tim/tim_onePulseOutput/component.mk b/Examples/tim/tim_onePulseOutput/component.mk
deleted file mode 100644
index b1b2bc6..0000000
--- a/Examples/tim/tim_onePulseOutput/component.mk
+++ /dev/null
@@ -1,16 +0,0 @@
-#
-# component Makefile
-#
-
-
-C_SOURCES += \
- $(srctree)/$(PROJ)/src/isr.c \
- $(srctree)/$(PROJ)/src/main.c
-
-C_INCLUDES += -I$(srctree)/$(PROJ)/inc
-
-
-LIBS +=
-CFLAGS +=
-LDFLAGS +=
-LIBDIR +=
diff --git a/Examples/tim/tim_onePulseOutput/inc/isr.h b/Examples/tim/tim_onePulseOutput/inc/isr.h
deleted file mode 100644
index 2f4d4da..0000000
--- a/Examples/tim/tim_onePulseOutput/inc/isr.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file isr.h
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/09/16
- * @license
- * @description
- */
-
-#ifndef __isr_H_wuraIpBA_lTJm_HvJw_sNDo_uEd5JnucTReY__
-#define __isr_H_wuraIpBA_lTJm_HvJw_sNDo_uEd5JnucTReY__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "main.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/Examples/tim/tim_onePulseOutput/inc/main.h b/Examples/tim/tim_onePulseOutput/inc/main.h
deleted file mode 100644
index 6bc013b..0000000
--- a/Examples/tim/tim_onePulseOutput/inc/main.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file main.h
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/08/29
- * @license
- * @description
- */
-
-#ifndef __main_H_wxBnwdPw_lq7D_H4I5_sHPp_uXof15pFLp4V__
-#define __main_H_wxBnwdPw_lq7D_H4I5_sHPp_uXof15pFLp4V__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-#include "hal_device.h"
-#include "syslog.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/Examples/tim/tim_onePulseOutput/readme.md b/Examples/tim/tim_onePulseOutput/readme.md
deleted file mode 100644
index 6d8a036..0000000
--- a/Examples/tim/tim_onePulseOutput/readme.md
+++ /dev/null
@@ -1,13 +0,0 @@
-TIM_onePulseOutput_project
----
-
-This example is a demo project to TIM onePulseOutput
-
-## Hardware and Software environment
-
-+ This example runs on PB5700 devices.
-
-## Log
-
-+ only out one Pulse
-
diff --git a/Examples/tim/tim_onePulseOutput/src/isr.c b/Examples/tim/tim_onePulseOutput/src/isr.c
deleted file mode 100644
index d19995f..0000000
--- a/Examples/tim/tim_onePulseOutput/src/isr.c
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file isr.c
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/09/16
- * @license
- * @description
- */
-
-
-#include "isr.h"
-
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-
diff --git a/Examples/tim/tim_onePulseOutput/src/main.c b/Examples/tim/tim_onePulseOutput/src/main.c
deleted file mode 100644
index 0256ecf..0000000
--- a/Examples/tim/tim_onePulseOutput/src/main.c
+++ /dev/null
@@ -1,99 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file main.c
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/08/29
- * @license
- * @description
- */
-
-
-#include "main.h"
-#include "isr.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-#define CONFIG_USE_TIM2
-//#define CONFIG_USE_EPWM
-
-#if defined(CONFIG_USE_TIM2)
- #define TIMx TIM2
- #define CONFIG_IRQ_ID TIM2_IRQn
-#elif defined(CONFIG_USE_EPWM)
- #define TIMx EPWM
- #define CONFIG_IRQ_ID EPWM_IRQn
-#endif
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-int main(void)
-{
-#if defined(CONFIG_USE_TIM2)
- GPIO_InitTypeDef GPIO_InitStruct;
- GPIO_InitStruct.GPIO_Pin = GPIO_Pin_02 | GPIO_Pin_03 | GPIO_Pin_04 | GPIO_Pin_05;
- GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF;
- GPIO_InitStruct.GPIO_AF_Mode = GPIO_AF_5;
- GPIO_Init(GPIOA, &GPIO_InitStruct);
-#elif defined(CONFIG_USE_EPWM)
- GPIO_InitTypeDef GPIO_InitStruct;
- GPIO_InitStruct.GPIO_Pin = GPIO_Pin_00 | GPIO_Pin_02 | GPIO_Pin_04;
- GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF;
- GPIO_InitStruct.GPIO_AF_Mode = GPIO_AF_6;
- GPIO_Init(GPIOA, &GPIO_InitStruct);
-#endif
-
- /* Resets the TIMx */
- TIM_DeInit(TIMx);
-
- TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
- /* Time Base configuration */
- TIM_TimeBaseStructure.TIM_Prescaler = 48 - 1;
- TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
- TIM_TimeBaseStructure.TIM_Period = 1000 - 1;
- TIM_TimeBaseStructure.TIM_ClockDivision = 0;
- TIM_TimeBaseStructure.TIM_RepetitionCounter = 0;
- TIM_TimeBaseInit(TIMx, &TIM_TimeBaseStructure);
-
- TIM_SetCompare1(TIMx,800);//CH1 DUTY:80%
- TIM_SelectOCxM(TIMx,TIM_Channel_1,TIM_OCMode_PWM1);
- TIM_CCxCmd(TIMx,TIM_Channel_1,TIM_CCx_Enable);
-
- TIM_SetCompare2(TIMx,400);//CH1 DUTY:40%
- TIM_SelectOCxM(TIMx,TIM_Channel_2,TIM_OCMode_PWM1);
- TIM_CCxCmd(TIMx,TIM_Channel_2,TIM_CCx_Enable);
-
- TIM_SetCompare3(TIMx,250);//CH1 DUTY:25%
- TIM_SelectOCxM(TIMx,TIM_Channel_3,TIM_OCMode_PWM1);
- TIM_CCxCmd(TIMx,TIM_Channel_3,TIM_CCx_Enable);
-
- TIM_SelectOnePulseMode(TIMx, TIM_OPMode_Single);
- /* TIM1 counter enable */
- TIM_Cmd(TIMx, ENABLE);
- /* Main Output Enable */
- TIM_CtrlPWMOutputs(TIMx, ENABLE);
-
- while(1)
- {
-
- }
-
-}
diff --git a/Examples/tim/tim_outputCompare/.cproject b/Examples/tim/tim_outputCompare/.cproject
index 21d0162..1a0019e 100644
--- a/Examples/tim/tim_outputCompare/.cproject
+++ b/Examples/tim/tim_outputCompare/.cproject
@@ -40,27 +40,28 @@
-
+
-
-
+
+
+
@@ -68,14 +69,14 @@
@@ -94,7 +95,7 @@
-
-
+
+
@@ -192,10 +193,10 @@
@@ -204,14 +205,14 @@
@@ -225,7 +226,7 @@
diff --git a/Examples/tim/tim_outputCompare/Project.nuproject b/Examples/tim/tim_outputCompare/Project.nuproject
index 0743ed2..0072223 100644
--- a/Examples/tim/tim_outputCompare/Project.nuproject
+++ b/Examples/tim/tim_outputCompare/Project.nuproject
@@ -7,7 +7,7 @@ SDK_CONFIG:
cmodel: medlow
extra_commonflags:
abi: ilp32e
- arch: rv32emac
+ arch: rv32ema_zba_zbb_zbs_zca_zcb_zcmp_zcmt_zicond
toolchain: gnu
extra_cflags:
extra_ldflags:
@@ -19,7 +19,7 @@ SDK_CONFIG:
cmodel: medlow
extra_commonflags:
abi: ilp32e
- arch: rv32emac
+ arch: rv32emac_zba_zbb_zbs
toolchain: gnu
extra_cflags:
extra_ldflags:
diff --git a/Examples/tim/tim_outputCompare/readme.md b/Examples/tim/tim_outputCompare/readme.md
index b96ec04..f54b90b 100644
--- a/Examples/tim/tim_outputCompare/readme.md
+++ b/Examples/tim/tim_outputCompare/readme.md
@@ -5,7 +5,7 @@ This example is a demo project to Compare output
## Hardware and Software environment
-+ This example runs on PB5700 devices.
++ This example runs on PEC930 devices.
## Log
diff --git a/Examples/tim/tim_outputCompare/src/main.c b/Examples/tim/tim_outputCompare/src/main.c
index aa38d4c..e6d4e25 100644
--- a/Examples/tim/tim_outputCompare/src/main.c
+++ b/Examples/tim/tim_outputCompare/src/main.c
@@ -47,11 +47,14 @@ void TIMx_handler(void);
//=============================================================================
int main(void)
{
+ TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
SYSCFG_ClkInitTypeDef SysClkInit = {0};
+ /* Configure system clock */
SysClkInit.ClkSource = SYSCFG_ClkSrc_HSI;
SYSCFG_SysClkConfig(&SysClkInit);
+ /* configure GPIO Pin mux of PWM */
#if defined(CONFIG_USE_TIM2)
GPIO_InitTypeDef GPIO_InitStruct;
GPIO_InitStruct.GPIO_Pin = GPIO_Pin_02 | GPIO_Pin_03 | GPIO_Pin_04 | GPIO_Pin_05;
@@ -66,6 +69,7 @@ int main(void)
GPIO_Init(GPIOA, &GPIO_InitStruct);
#endif
+ /* configure GPIO Pin OUT of test flag */
GPIO_InitStruct.GPIO_Pin = GPIO_Pin_06 | GPIO_Pin_07;
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT;
GPIO_Init(GPIOA, &GPIO_InitStruct);
@@ -73,9 +77,8 @@ int main(void)
/* Resets the TIMx */
TIM_DeInit(TIMx);
- TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
/* Time Base configuration */
- TIM_TimeBaseStructure.TIM_Prescaler = 48 - 1;
+ TIM_TimeBaseStructure.TIM_Prescaler = 60 - 1;
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseStructure.TIM_Period = 1000 - 1;
TIM_TimeBaseStructure.TIM_ClockDivision = 0;
@@ -96,14 +99,17 @@ int main(void)
/* Enable the CC2 Interrupt Request */
TIM_ITConfig(TIMx, TIM_IT_CC2, ENABLE);
- __enable_irq();
sys_irq_attr_t irq_attr = { .trig_mode = SYS_IRQ_TRIGGER_LEVEL, };
sys_register_IRQ(CONFIG_IRQ_ID, TIMx_handler, &irq_attr);
+ sys_enable_girq();
+ /* TIM ENABLE Flag */
GPIO_SetBits(GPIOA,GPIO_Pin_06);
+
/* TIM1 counter enable */
TIM_Cmd(TIMx, ENABLE);
+
/* Main Output Enable */
TIM_CtrlPWMOutputs(TIMx, ENABLE);
@@ -116,9 +122,15 @@ int main(void)
__INTERRUPT void TIMx_handler(void)
{
+ SAVE_IRQ_CSR_CONTEXT(); // Save CSRs
+
if(TIM_GetITStatus(TIMx, TIM_IT_CC2) == SET)
{
TIM_ClearITPendingBit(TIMx, TIM_IT_CC2);
+ /* TIM Interrupt Flag */
GPIO_SetBits(GPIOA, GPIO_Pin_07);
}
+
+ RESTORE_IRQ_CSR_CONTEXT(); // Restore CSRs
+ return;
}
diff --git a/Examples/tim/tim_pwm_output/.cproject b/Examples/tim/tim_pwm_output/.cproject
index 21d0162..1a0019e 100644
--- a/Examples/tim/tim_pwm_output/.cproject
+++ b/Examples/tim/tim_pwm_output/.cproject
@@ -40,27 +40,28 @@
-
+
-
-
+
+
+
@@ -68,14 +69,14 @@
@@ -94,7 +95,7 @@
-
-
+
+
@@ -192,10 +193,10 @@
@@ -204,14 +205,14 @@
@@ -225,7 +226,7 @@
diff --git a/Examples/tim/tim_pwm_output/Project.nuproject b/Examples/tim/tim_pwm_output/Project.nuproject
index 0743ed2..0072223 100644
--- a/Examples/tim/tim_pwm_output/Project.nuproject
+++ b/Examples/tim/tim_pwm_output/Project.nuproject
@@ -7,7 +7,7 @@ SDK_CONFIG:
cmodel: medlow
extra_commonflags:
abi: ilp32e
- arch: rv32emac
+ arch: rv32ema_zba_zbb_zbs_zca_zcb_zcmp_zcmt_zicond
toolchain: gnu
extra_cflags:
extra_ldflags:
@@ -19,7 +19,7 @@ SDK_CONFIG:
cmodel: medlow
extra_commonflags:
abi: ilp32e
- arch: rv32emac
+ arch: rv32emac_zba_zbb_zbs
toolchain: gnu
extra_cflags:
extra_ldflags:
diff --git a/Examples/tim/tim_pwm_output/readme.md b/Examples/tim/tim_pwm_output/readme.md
index 8a8c3a3..149dc68 100644
--- a/Examples/tim/tim_pwm_output/readme.md
+++ b/Examples/tim/tim_pwm_output/readme.md
@@ -4,7 +4,7 @@ This example is used to pwm output function.
## Hardware and Software environment
-+ This example runs on PB5700 devices.
++ This example runs on PEC930 devices.
> + How to log message
@@ -14,7 +14,7 @@ TIM2:T2CH1 -> PA2
T2CH2 -> PA3
T2CH3 -> PA4
T2CH4 -> PA5
-
+
EPWM:EPWMCH0P -> PA0
EPWMCH0N -> PA1
EPWMCH1P -> PA2
diff --git a/Examples/tim/tim_pwm_output/src/main.c b/Examples/tim/tim_pwm_output/src/main.c
index 64ce6c5..048d92a 100644
--- a/Examples/tim/tim_pwm_output/src/main.c
+++ b/Examples/tim/tim_pwm_output/src/main.c
@@ -54,10 +54,14 @@ int main(void)
uint16_t delay = 0;
SYSCFG_ClkInitTypeDef SysClkInit = {0};
+ /* Configure system clock */
SysClkInit.ClkSource = SYSCFG_ClkSrc_HSI;
SYSCFG_SysClkConfig(&SysClkInit);
+ /* Configure PWM OUT */
TIM_PWM_OUTPUT_Sample(TIMx,100 - 1,48 - 1,TIM_CounterMode_Up);//pwm:10K
+
+ /* Set PWM DUTY */
TIM_SetCompare1(TIMx,80);//CH1 DUTY:80%
TIM_SetCompare2(TIMx,40);//CH2 DUTY:40%
TIM_SetCompare3(TIMx,25);//CH3 DUTY:25%
@@ -84,7 +88,6 @@ void TIM_PWM_OUTPUT_Sample(TIM_Type *tim,uint16_t Period,uint16_t Prescaler ,uin
TIM_TimeBaseInitStruct.TIM_ClockDivision = TIM_CKD_Div1;
TIM_TimeBaseInitStruct.TIM_RepetitionCounter = 0;
TIM_TimeBaseInit(tim, &TIM_TimeBaseInitStruct);
-
TIM_ARRPreloadConfig(tim,ENABLE);
TIM_OCStructInit(&TIM_OCInitStruct);
@@ -124,6 +127,9 @@ void TIM_PWM_OUTPUT_Sample(TIM_Type *tim,uint16_t Period,uint16_t Prescaler ,uin
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT;
GPIO_Init(GPIOA, &GPIO_InitStruct);
+ /* Enable EPWM */
TIM_Cmd(tim, ENABLE);
+
+ /* Enable PWM OUT */
TIM_CtrlPWMOutputs(tim,ENABLE);
}
diff --git a/Examples/tim/tim_xorInput/.cproject b/Examples/tim/tim_xorInput/.cproject
deleted file mode 100644
index 21d0162..0000000
--- a/Examples/tim/tim_xorInput/.cproject
+++ /dev/null
@@ -1,293 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Examples/tim/tim_xorInput/.project b/Examples/tim/tim_xorInput/.project
deleted file mode 100644
index 2183c12..0000000
--- a/Examples/tim/tim_xorInput/.project
+++ /dev/null
@@ -1,54 +0,0 @@
-
-
- Project
-
-
-
-
-
- org.eclipse.cdt.managedbuilder.core.genmakebuilder
- clean,full,incremental,
-
-
-
-
- org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
- full,incremental,
-
-
-
-
-
- org.eclipse.cdt.core.cnature
- org.eclipse.cdt.managedbuilder.core.managedBuildNature
- org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
-
-
-
- Common
- 2
- PARENT-3-PROJECT_LOC/Common
-
-
- Drivers
- 2
- PARENT-3-PROJECT_LOC/Drivers
-
-
- Profiles
- 2
- PARENT-3-PROJECT_LOC/Tools/scripts/Profiles
-
-
-
-
- 0
-
- 6
-
- org.eclipse.ui.ide.multiFilter
- 1.0-name-matches-false-false-*.nuproject
-
-
-
-
diff --git a/Examples/tim/tim_xorInput/Project.nuproject b/Examples/tim/tim_xorInput/Project.nuproject
deleted file mode 100644
index 0743ed2..0000000
--- a/Examples/tim/tim_xorInput/Project.nuproject
+++ /dev/null
@@ -1,25 +0,0 @@
-SDK_CONFIG:
- Debug:
- core: N203E
- extra_asmflags:
- archext:
- extra_cxxflags:
- cmodel: medlow
- extra_commonflags:
- abi: ilp32e
- arch: rv32emac
- toolchain: gnu
- extra_cflags:
- extra_ldflags:
- Release:
- core: N203E
- extra_asmflags:
- archext:
- extra_cxxflags:
- cmodel: medlow
- extra_commonflags:
- abi: ilp32e
- arch: rv32emac
- toolchain: gnu
- extra_cflags:
- extra_ldflags:
diff --git a/Examples/tim/tim_xorInput/component.mk b/Examples/tim/tim_xorInput/component.mk
deleted file mode 100644
index b1b2bc6..0000000
--- a/Examples/tim/tim_xorInput/component.mk
+++ /dev/null
@@ -1,16 +0,0 @@
-#
-# component Makefile
-#
-
-
-C_SOURCES += \
- $(srctree)/$(PROJ)/src/isr.c \
- $(srctree)/$(PROJ)/src/main.c
-
-C_INCLUDES += -I$(srctree)/$(PROJ)/inc
-
-
-LIBS +=
-CFLAGS +=
-LDFLAGS +=
-LIBDIR +=
diff --git a/Examples/tim/tim_xorInput/inc/isr.h b/Examples/tim/tim_xorInput/inc/isr.h
deleted file mode 100644
index 2f4d4da..0000000
--- a/Examples/tim/tim_xorInput/inc/isr.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file isr.h
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/09/16
- * @license
- * @description
- */
-
-#ifndef __isr_H_wuraIpBA_lTJm_HvJw_sNDo_uEd5JnucTReY__
-#define __isr_H_wuraIpBA_lTJm_HvJw_sNDo_uEd5JnucTReY__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "main.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/Examples/tim/tim_xorInput/inc/main.h b/Examples/tim/tim_xorInput/inc/main.h
deleted file mode 100644
index 6bc013b..0000000
--- a/Examples/tim/tim_xorInput/inc/main.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file main.h
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/08/29
- * @license
- * @description
- */
-
-#ifndef __main_H_wxBnwdPw_lq7D_H4I5_sHPp_uXof15pFLp4V__
-#define __main_H_wxBnwdPw_lq7D_H4I5_sHPp_uXof15pFLp4V__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-#include "hal_device.h"
-#include "syslog.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/Examples/tim/tim_xorInput/readme.md b/Examples/tim/tim_xorInput/readme.md
deleted file mode 100644
index 850305c..0000000
--- a/Examples/tim/tim_xorInput/readme.md
+++ /dev/null
@@ -1,19 +0,0 @@
-TIM_xorInput_project
----
-
-This example is a demo project to TIM xorInput
-
-## Hardware and Software environment
-
-+ This example runs on PB5700 devices.
-
-## Log
-
-+ CAP0(PA14)/CAP1(PA15)/CAP2(PB0),PA6,PA7,PA8 set output
-+ PA6 connects PA14,PA7 connects PA15,PA8 connects PB0
-+ Set TIM output to 1KHz PWM
-+ Set as trigger mode, trigger source is T1
-+ Set T1 as the XOR result of CAP0, CAP1, and CAP2
-+ Set PA6/7/8 voltage level
-+ When PA6/7/8 changes from 0 to 1, PWM starts outputting
-
diff --git a/Examples/tim/tim_xorInput/src/isr.c b/Examples/tim/tim_xorInput/src/isr.c
deleted file mode 100644
index d19995f..0000000
--- a/Examples/tim/tim_xorInput/src/isr.c
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file isr.c
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/09/16
- * @license
- * @description
- */
-
-
-#include "isr.h"
-
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-
diff --git a/Examples/tim/tim_xorInput/src/main.c b/Examples/tim/tim_xorInput/src/main.c
deleted file mode 100644
index 85e967d..0000000
--- a/Examples/tim/tim_xorInput/src/main.c
+++ /dev/null
@@ -1,121 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file main.c
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/08/29
- * @license
- * @description
- */
-
-
-#include "main.h"
-#include "isr.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-#define CONFIG_USE_TIM2
-//#define CONFIG_USE_EPWM
-
-#if defined(CONFIG_USE_TIM2)
- #define TIMx TIM2
- #define CONFIG_IRQ_ID TIM2_IRQn
-#elif defined(CONFIG_USE_EPWM)
- #define TIMx EPWM
- #define CONFIG_IRQ_ID EPWM_IRQn
-#endif
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-uint32_t delayCounter = 0;
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-//
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-int main(void)
-{
- SYSCFG_ClkInitTypeDef SysClkInit = {0};
-
- SysClkInit.ClkSource = SYSCFG_ClkSrc_HSI;
- SYSCFG_SysClkConfig(&SysClkInit);
-
-#if defined(CONFIG_USE_TIM2)
- GPIO_InitTypeDef GPIO_InitStruct;
- GPIO_InitStruct.GPIO_Pin = GPIO_Pin_03 | GPIO_Pin_04;
- GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF;
- GPIO_InitStruct.GPIO_AF_Mode = GPIO_AF_5;
- GPIO_Init(GPIOA, &GPIO_InitStruct);
-
- /*TIM2 TCAP0 -> PA14,TCAP1 -> PA15, TCAP2 -> PB0*/
- GPIO_PeriAFConfig(GPIOA,GPIO_Peri_TCAP0,GPIO_PeriAF_1);
- GPIO_PeriAFConfig(GPIOA,GPIO_Peri_TCAP1,GPIO_PeriAF_2);
- GPIO_PeriAFConfig(GPIOA,GPIO_Peri_TCAP2,GPIO_PeriAF_3);
-#elif defined(CONFIG_USE_EPWM)
- GPIO_InitTypeDef GPIO_InitStruct;
- GPIO_InitStruct.GPIO_Pin = GPIO_Pin_02 | GPIO_Pin_04;
- GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF;
- GPIO_InitStruct.GPIO_AF_Mode = GPIO_AF_6;
- GPIO_Init(GPIOA, &GPIO_InitStruct);
-
- /*EPWM ECAP0 -> PA14,ECAP1 -> PA15, ECAP2 -> PB0*/
- GPIO_PeriAFConfig(GPIOA,GPIO_Peri_ECAP0,GPIO_PeriAF_1);
- GPIO_PeriAFConfig(GPIOA,GPIO_Peri_ECAP1,GPIO_PeriAF_2);
- GPIO_PeriAFConfig(GPIOA,GPIO_Peri_ECAP2,GPIO_PeriAF_3);
-#endif
- GPIO_InitStruct.GPIO_Pin = GPIO_Pin_06 | GPIO_Pin_07 | GPIO_Pin_08 ;
- GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT;
- GPIO_Init(GPIOA, &GPIO_InitStruct);
-
- TIM_DeInit(TIMx);
- TIM_TimeBaseInitTypeDef TIM_TimeBaseInitStruct;
- TIM_TimeBaseStructInit(&TIM_TimeBaseInitStruct);
- TIM_TimeBaseInitStruct.TIM_Prescaler = 48 - 1;
- TIM_TimeBaseInitStruct.TIM_CounterMode = TIM_CounterMode_Up;
- TIM_TimeBaseInitStruct.TIM_Period = 1000 - 1;//1ms
- TIM_TimeBaseInitStruct.TIM_ClockDivision = TIM_CKD_Div1;
- TIM_TimeBaseInitStruct.TIM_RepetitionCounter = 0;
- TIM_TimeBaseInit(TIMx, &TIM_TimeBaseInitStruct);
-
- TIM_ICInitTypeDef TIM_ICInitStruct;
- TIM_ICInitStruct.TIM_Channel = TIM_Channel_1;
- TIM_ICInitStruct.TIM_ICPolarity = TIM_ICPolarity_Rising;
- TIM_ICInitStruct.TIM_ICSelection = TIM_ICSelection_DirectTI;
- TIM_ICInitStruct.TIM_ICPrescaler = TIM_ICPSC_Div1;
- TIM_ICInitStruct.TIM_ICFilter = 0x0;
- TIM_ICInit(TIMx, &TIM_ICInitStruct);
-
- TIM_SetCompare2(TIMx,400);//CH2 DUTY:40%
- TIM_SelectOCxM(TIMx,TIM_Channel_2,TIM_OCMode_PWM1);
- TIM_CCxCmd(TIMx,TIM_Channel_2,TIM_CCx_Enable);
-
- TIM_SetCompare3(TIMx,250);//CH3 DUTY:25%
- TIM_SelectOCxM(TIMx,TIM_Channel_3,TIM_OCMode_PWM1);
- TIM_CCxCmd(TIMx,TIM_Channel_3,TIM_CCx_Enable);
-
- TIM_SelectInputTrigger(TIMx,TIM_TS_TI1F_ED);
- TIM_SelectSlaveMode(TIMx,TIM_SlaveMode_Trigger);
- TIM_SelectHallSensor(TIMx, ENABLE);
- TIM_Cmd(TIMx, ENABLE);
- TIM_CtrlPWMOutputs(TIMx, ENABLE);
- for(delayCounter = 0;delayCounter < 20000 ;delayCounter ++);
- GPIO_SetBits(GPIOA,GPIO_Pin_06 | GPIO_Pin_07 | GPIO_Pin_08);
-
- while(1)
- {
-
- }
-}
diff --git a/Examples/uart/uart_Interrupt/.cproject b/Examples/uart/uart_Interrupt/.cproject
index 19a602b..1a0019e 100644
--- a/Examples/uart/uart_Interrupt/.cproject
+++ b/Examples/uart/uart_Interrupt/.cproject
@@ -15,7 +15,7 @@
-
+
@@ -40,48 +40,51 @@
-
+
-
+
+
+
+
-
+
@@ -92,7 +95,7 @@
-
+
@@ -178,50 +181,52 @@
-
+
+
+
diff --git a/Examples/uart/uart_Interrupt/Project.nuproject b/Examples/uart/uart_Interrupt/Project.nuproject
index f71fbc6..0072223 100644
--- a/Examples/uart/uart_Interrupt/Project.nuproject
+++ b/Examples/uart/uart_Interrupt/Project.nuproject
@@ -1,27 +1,25 @@
SDK_CONFIG:
Debug:
- core: N100E
- download: LINK_FLASH
+ core: N203E
extra_asmflags:
archext:
extra_cxxflags:
cmodel: medlow
extra_commonflags:
abi: ilp32e
- arch: rv32ec
+ arch: rv32ema_zba_zbb_zbs_zca_zcb_zcmp_zcmt_zicond
toolchain: gnu
extra_cflags:
extra_ldflags:
Release:
- core: N100E
- download: LINK_FLASH
+ core: N203E
extra_asmflags:
archext:
extra_cxxflags:
cmodel: medlow
extra_commonflags:
abi: ilp32e
- arch: rv32ec
+ arch: rv32emac_zba_zbb_zbs
toolchain: gnu
extra_cflags:
extra_ldflags:
diff --git a/Examples/uart/uart_Interrupt/readme.md b/Examples/uart/uart_Interrupt/readme.md
index 6a51646..3ad6790 100644
--- a/Examples/uart/uart_Interrupt/readme.md
+++ b/Examples/uart/uart_Interrupt/readme.md
@@ -1,14 +1,44 @@
-Uart_Interrput_project
+uart_Interrput
---
-This example is a demo project to UART Interrput
+This is an example of UART Interrput
-## Hardware and Software environment
++ Select the UART TX/RX pins
+
+ ```
+ // in main.c
+ #define CONFIG_UART_IO_TX_PORT GPIOA
+ #define CONFIG_UART_IO_TX_PIN GPIO_Pin_01
+ #define CONFIG_UART_IO_TX_AF_MODE GPIO_AF_1
+ #define CONFIG_UART_IO_RX_PORT GPIOA
+ #define CONFIG_UART_IO_RX_PIN GPIO_Pin_00
+ #define CONFIG_UART_IO_RX_AF_MODE GPIO_AF_1
+ ```
+
++ Configure the parameters related to UART
+
+ ```
+ // in main.c
+ #define CONFIG_BAUD_RATE_VALUE 38400
+ UART_WordLength_8b //Data bit 8
+ UART_StopBits_1 //Stop bit 1
+ UART_Parity_No //No check bit
+ UART_Mode_TxRx //Transmit-Receive Mode
+ ```
+
++ Select the UART interrupt mode
++ It can be modified according to the requirements
+
+ ```
+ // in main.c
+ UART_ITConfig(UART0, UART_IE_RXNEE_Msk, ENABLE);
+ ```
-+ This example runs on PB5700 devices.
## Log
-+ SET different uart flag bits to enable interrupts
-+ Send data in the corresponding interrupt
+Use serial port with baudrate 38400, 8bit, no parity check
+
++ SET different uart flag bits to enable interrupts
++ Send the corresponding success log in the interrupt function
diff --git a/Examples/uart/uart_Interrupt/src/isr.c b/Examples/uart/uart_Interrupt/src/isr.c
index 4cd5b57..ffb59e1 100644
--- a/Examples/uart/uart_Interrupt/src/isr.c
+++ b/Examples/uart/uart_Interrupt/src/isr.c
@@ -37,14 +37,3 @@
//=============================================================================
// Public Function Definition
//=============================================================================
-/**
- * \brief System Software ISR
- *
- * \return None
- */
-__INTERRUPT void irqc_msip_handler(void)
-{
- sys_clear_swi();
- return;
-}
-
diff --git a/Examples/uart/uart_Interrupt/src/main.c b/Examples/uart/uart_Interrupt/src/main.c
index f6c6b50..aad4ae6 100644
--- a/Examples/uart/uart_Interrupt/src/main.c
+++ b/Examples/uart/uart_Interrupt/src/main.c
@@ -16,16 +16,30 @@
//=============================================================================
// Constant Definition
//=============================================================================
+/* UART0-TX GPIO pins are PA1 PA15 PB3 PB4
+ * GPIO reuse are GPIO_AF_1
+ * GPIO pins are PA0 PB0 PB5
+ * GPIO reuse are GPIO_AF_2
+ * UART0-RX GPIO pins are PA0 PB0 PB5
+ * GPIO reuse are GPIO_AF_1
+ * GPIO pins are PA1 PA15 PB4
+ * GPIO reuse are GPIO_AF_2
+ */
+/* adjustment Instructions for the GPIOs */
+#define CONFIG_UART_IO_TX_PORT GPIOA
+#define CONFIG_UART_IO_TX_PIN GPIO_Pin_01
+#define CONFIG_UART_IO_TX_AF_MODE GPIO_AF_1
+#define CONFIG_UART_IO_RX_PORT GPIOA
+#define CONFIG_UART_IO_RX_PIN GPIO_Pin_00
+#define CONFIG_UART_IO_RX_AF_MODE GPIO_AF_1
+
+/* Use Baud Rate */
+#define CONFIG_BAUD_RATE_VALUE 38400
//=============================================================================
// Macro Definition
//=============================================================================
-uint16_t rxDataBuffer[256];
-uint16_t rxCounter = 0;
-uint16_t rxData = 0;
-uint16_t txData = 0;
-uint16_t errCounter = 0;
-uint16_t rightCounter = 0;
+
//=============================================================================
// Structure Definition
//=============================================================================
@@ -37,142 +51,60 @@ uint16_t rightCounter = 0;
//=============================================================================
// Private Function Definition
//=============================================================================
+__INTERRUPT void UART0_Handler(void)
+{
+ SAVE_IRQ_CSR_CONTEXT(); //Save CSRs
+
+ if(UART_GetITStatus(UART0, UART_IE_RXNEE_Msk))
+ {
+ printf("UART0 RXNE Interrupt successful\r\n");
+ UART_ITConfig(UART0, UART_IE_RXNEE_Msk, DISABLE);
+ }
+
+ RESTORE_IRQ_CSR_CONTEXT(); //Restore CSRs
+ return;
+}
-void UART0_Handler(void);
//=============================================================================
// Public Function Definition
//=============================================================================
int main(void)
{
+ /* Configure the system clock */
SYSCFG_ClkInitTypeDef SysClkInit = {0};
-
SysClkInit.ClkSource = SYSCFG_ClkSrc_HSI;
SYSCFG_SysClkConfig(&SysClkInit);
- GPIO_InitTypeDef gpio_init = {0};
- UART_InitTypeDef uart_init = {0};
+ /* Configure GPIO Pin mux of UART */
+ GPIO_InitTypeDef GpioInit = {0};
+ GpioInit.GPIO_Pin = CONFIG_UART_IO_TX_PIN; //UART0-TX
+ GpioInit.GPIO_Mode = GPIO_Mode_AF;
+ GpioInit.GPIO_AF_Mode = CONFIG_UART_IO_TX_AF_MODE;
+ GPIO_Init(CONFIG_UART_IO_TX_PORT, &GpioInit);
+ GpioInit.GPIO_Pin = CONFIG_UART_IO_RX_PIN; //UART0-RX
+ GpioInit.GPIO_AF_Mode = CONFIG_UART_IO_RX_AF_MODE;
+ GPIO_Init(CONFIG_UART_IO_RX_PORT, &GpioInit);
- /* ToDo: configure GPIO Pin mux of UART (Tx through PA0?) */
- gpio_init.GPIO_Pin = GPIO_Pin_00 | GPIO_Pin_01;
- gpio_init.GPIO_Mode = GPIO_Mode_AF;
- gpio_init.GPIO_AF_Mode = GPIO_AF_1;
- GPIO_Init(GPIOA, &gpio_init);
+ /* Configure the parameters of UART */
+ UART_InitTypeDef UartInit = {0};
+ UartInit.BaudRate = CONFIG_BAUD_RATE_VALUE;
+ UartInit.WordLength = UART_WordLength_8b;
+ UartInit.StopBits = UART_StopBits_1;
+ UartInit.Parity = UART_Parity_No;
+ UartInit.Mode = UART_Mode_TxRx;
+ UART_Init(UART0, &UartInit);
- uart_init.BaudRate = SLOG_SERIAL_BPS;
- uart_init.WordLength = UART_WordLength_8b1P;
- uart_init.StopBits = UART_StopBits_1;
- uart_init.Parity = UART_Parity_No;
- uart_init.Mode = UART_Mode_TxRx;
- UART_Init(UART0, &uart_init);
-
- UART_ITConfig(UART0, UART_IT_RXF, ENABLE);
- sys_irq_attr_t irq_attr = { .trig_mode = SYS_IRQ_TRIGGER_LEVEL, };
- sys_register_IRQ(I2C0_IRQn, UART0_Handler, &irq_attr);
- __enable_irq();
+ /* Configure the interrupt function of UART */
+ UART_ITConfig(UART0, UART_IE_RXNEE_Msk, ENABLE);
+ sys_irq_attr_t irq_attr = { .trig_mode = SYS_IRQ_TRIGGER_LEVEL, };
+ sys_register_IRQ(UART0_IRQn, UART0_Handler, &irq_attr);
+ sys_enable_girq();
+ /* UART enable */
UART_Start(UART0);
while(1)
{
-
- }
-}
-
-__INTERRUPT void UART0_Handler(void)
-{
- if(UART_GetITStatus(UART0, UART_IT_RXNE) == 1)
- {
- printf("UART0 RXNE Interrupt successful\r\n");
- UART_ITConfig(UART0, UART_IT_RXNE, DISABLE);
-
- }
- if(UART_GetITStatus(UART0, UART_IT_TXE) == 1)
- {
- printf("UART0 TXE Interrupt successful\r\n");
- UART_ITConfig(UART0, UART_IT_TXE, DISABLE);
- }
- if(UART_GetITStatus(UART0, UART_IT_TXHE) == 1)
- {
- printf("UART0 TXHE Interrupt successful\r\n");
- UART_ITConfig(UART0, UART_IT_TXHE, DISABLE);
- }
- if(UART_GetITStatus(UART0, UART_IT_PERR) == 1)
- {
-
- printf("UART0 PERR Interrupt successful");
- REG_SET_BITS(UART0->SR, UART_IT_PERR);
-
- if(UART_GetFlagStatus(UART0, UART_IT_PERR ) == 0)
- {
- printf("UART0 PERR Interrupt Flag clear successful\r\n");
- }
- else
- {
- printf("UART0 PERR Interrupt Flag clear fail\r\n");
- }
-
- UART_ITConfig(UART0, UART_IT_PERR, DISABLE);
- }
- if(UART_GetITStatus(UART0, UART_IT_FERR) == 1)
- {
- printf("UART0 FERR Interrupt successful\r\n");
- REG_SET_BITS(UART0->SR, UART_IT_FERR);
- if(UART_GetFlagStatus(UART0, UART_IT_RXNE ) == 0)
- {
- printf("UART0 OVERR Interrupt Flag clear successful\r\n");
- }
- else
- {
- printf("UART0 OVERR Interrupt Flag clear fail\r\n");
- }
- UART_ITConfig(UART0, UART_IT_FERR, DISABLE);
- }
- if(UART_GetITStatus(UART0, UART_IT_OVERR) == 1)
- {
- printf("UART0 OVERR Interrupt successful\r\n");
- UART_ResetRxFIFO(UART0);
- REG_SET_BITS(UART0->SR, UART_IT_OVERR);
- if(UART_GetFlagStatus(UART0, UART_IT_RXNE ) == 0)
- {
- printf("UART0 OVERR Interrupt Flag clear successful\r\n");
- }
- else
- {
- printf("UART0 OVERR Interrupt Flag clear fail\r\n");
- }
- UART_ITConfig(UART0, UART_IT_OVERR, DISABLE);
- }
- if(UART_GetITStatus(UART0, UART_IT_TONE) == 1)
- {
- printf("UART0 TONE Interrupt successful\r\n");
- UART_ITConfig(UART0, UART_IT_TONE, DISABLE);
- }
- if(UART_GetITStatus(UART0, UART_IT_TOIDLE) == 1)
- {
- printf("UART0 TOIDLE Interrupt successful\r\n");
- UART_ITConfig(UART0, UART_IT_TOIDLE, DISABLE);
- }
- if(UART_GetITStatus(UART0, UART_IT_RXHF) == 1)
- {
- printf("UART0 RXHF Interrupt successful\r\n");
- UART_ITConfig(UART0, UART_IT_RXHF, DISABLE);
- }
- if(UART_GetITStatus(UART0, UART_IT_RXF) == 1)
- {
- printf("UART0 RXF Interrupt successful\r\n");
- UART_ITConfig(UART0, UART_IT_RXF, DISABLE);
- }
- if(UART_GetITStatus(UART0, UART_IT_TX_DONE) == 1)
- {
- printf("UART0 TXEND Interrupt successful\r\n");
- UART_ITConfig(UART0, UART_IT_TX_DONE, DISABLE);
- }
- if(UART_GetITStatus(UART0, UART_IT_TXF) == 1)
- {
- UART_ResetTxFIFO(UART0);
- UART_Start(UART0);
- printf("UART0 TXF Interrupt successful\r\n");
- UART_ITConfig(UART0, UART_IT_TXF, DISABLE);
}
}
diff --git a/Examples/uart/uart_polling/.cproject b/Examples/uart/uart_polling/.cproject
index d9ac06f..1a0019e 100644
--- a/Examples/uart/uart_polling/.cproject
+++ b/Examples/uart/uart_polling/.cproject
@@ -45,23 +45,23 @@
-
-
-
+
+
+
@@ -69,14 +69,14 @@
@@ -95,7 +95,7 @@
-
-
+
+
@@ -193,10 +193,10 @@
@@ -205,14 +205,14 @@
@@ -226,7 +226,7 @@
diff --git a/Examples/uart/uart_polling/readme.md b/Examples/uart/uart_polling/readme.md
index 2a6cf75..896bba6 100644
--- a/Examples/uart/uart_polling/readme.md
+++ b/Examples/uart/uart_polling/readme.md
@@ -1,14 +1,37 @@
-Uart_Polling_project
+uart_polling
---
-This example is a demo project to UART Polling
+This is an example of UART polling
-## Hardware and Software environment
++ Select the UART TX/RX pins
+
+ ```
+ // in main.c
+ #define CONFIG_UART_IO_TX_PORT GPIOA
+ #define CONFIG_UART_IO_TX_PIN GPIO_Pin_01
+ #define CONFIG_UART_IO_TX_AF_MODE GPIO_AF_1
+ #define CONFIG_UART_IO_RX_PORT GPIOA
+ #define CONFIG_UART_IO_RX_PIN GPIO_Pin_00
+ #define CONFIG_UART_IO_RX_AF_MODE GPIO_AF_1
+ ```
+
++ Configure the parameters related to UART
++ It can be modified according to the requirements
+
+ ```
+ // in main.c
+ #define CONFIG_BAUD_RATE_VALUE 38400
+ UART_WordLength_8b //Data bit 8
+ UART_StopBits_1 //Stop bit 1
+ UART_Parity_No //No check bit
+ UART_Mode_TxRx //Transmit-Receive Mode
+ ```
-+ This example runs on PB5700 devices.
## Log
-+ PC sends 1~255 to PB5700
-+ PB5700 receives and sends back data
+Use serial port with baudrate 38400, 8bit, no parity check
+
++ PC sends 1~255 to PEC930
++ PEC930 receives and sends back data
diff --git a/Examples/uart/uart_polling/src/main.c b/Examples/uart/uart_polling/src/main.c
index dad56e7..3403e5b 100644
--- a/Examples/uart/uart_polling/src/main.c
+++ b/Examples/uart/uart_polling/src/main.c
@@ -16,16 +16,36 @@
//=============================================================================
// Constant Definition
//=============================================================================
+uint16_t rxDataBuffer[256];
+uint16_t rxCounter = 0;
+uint16_t rxData = 0;
+uint16_t errCounter = 0;
+uint16_t rightCounter = 0;
+
+/* UART0-TX GPIO pins are PA1 PA15 PB3 PB4
+ * GPIO reuse are GPIO_AF_1
+ * GPIO pins are PA0 PB0 PB5
+ * GPIO reuse are GPIO_AF_2
+ * UART0-RX GPIO pins are PA0 PB0 PB5
+ * GPIO reuse are GPIO_AF_1
+ * GPIO pins are PA1 PA15 PB4
+ * GPIO reuse are GPIO_AF_2
+ */
+/* adjustment Instructions for the GPIOs */
+#define CONFIG_UART_IO_TX_PORT GPIOA
+#define CONFIG_UART_IO_TX_PIN GPIO_Pin_01
+#define CONFIG_UART_IO_TX_AF_MODE GPIO_AF_1
+#define CONFIG_UART_IO_RX_PORT GPIOA
+#define CONFIG_UART_IO_RX_PIN GPIO_Pin_00
+#define CONFIG_UART_IO_RX_AF_MODE GPIO_AF_1
+
+/* Use Baud Rate */
+#define CONFIG_BAUD_RATE_VALUE 38400
//=============================================================================
// Macro Definition
//=============================================================================
-uint16_t rxDataBuffer[256];
-uint16_t rxCounter = 0;
-uint16_t rxData = 0;
-uint16_t txData = 0;
-uint16_t errCounter = 0;
-uint16_t rightCounter = 0;
+
//=============================================================================
// Structure Definition
//=============================================================================
@@ -43,32 +63,34 @@ uint16_t rightCounter = 0;
//=============================================================================
int main(void)
{
+ /* Configure the system clock */
SYSCFG_ClkInitTypeDef SysClkInit = {0};
-
- SysClkInit.ClkSource = SYSCFG_ClkSrc_HSI;
+ SysClkInit.ClkSource = SYSCFG_ClkSrc_HSI;
SYSCFG_SysClkConfig(&SysClkInit);
- GPIO_InitTypeDef gpio_init = {0};
- UART_InitTypeDef uart_init = {0};
+ /* Configure GPIO Pin mux of UART */
+ GPIO_InitTypeDef GpioInit = {0};
+ GpioInit.GPIO_Pin = CONFIG_UART_IO_TX_PIN; //UART0-TX
+ GpioInit.GPIO_Mode = GPIO_Mode_AF;
+ GpioInit.GPIO_AF_Mode = CONFIG_UART_IO_TX_AF_MODE;
+ GPIO_Init(CONFIG_UART_IO_TX_PORT, &GpioInit);
+ GpioInit.GPIO_Pin = CONFIG_UART_IO_RX_PIN; //UART0-RX
+ GpioInit.GPIO_AF_Mode = CONFIG_UART_IO_RX_AF_MODE;
+ GPIO_Init(CONFIG_UART_IO_RX_PORT, &GpioInit);
- /* ToDo: configure GPIO Pin mux of UART (Tx through PA0?) */
- gpio_init.GPIO_Pin = GPIO_Pin_00 | GPIO_Pin_01 ;
- gpio_init.GPIO_Mode = GPIO_Mode_AF;
- gpio_init.GPIO_AF_Mode = GPIO_AF_1;
- GPIO_Init(GPIOA, &gpio_init);
-
- uart_init.BaudRate = 115200;
- uart_init.WordLength = UART_WordLength_8b;
- uart_init.StopBits = UART_StopBits_1;
- uart_init.Parity = UART_Parity_No;
- uart_init.Mode = UART_Mode_TxRx;
- UART_Init(UART0, &uart_init);
+ /* Configure the parameters of UART */
+ UART_InitTypeDef UartInit = {0};
+ UartInit.BaudRate = CONFIG_BAUD_RATE_VALUE;
+ UartInit.WordLength = UART_WordLength_8b;
+ UartInit.StopBits = UART_StopBits_1;
+ UartInit.Parity = UART_Parity_No;
+ UartInit.Mode = UART_Mode_TxRx;
+ UART_Init(UART0, &UartInit);
+ /* UART enable */
UART_Start(UART0);
- for(rxCounter = 0; rxCounter < 256 ;rxCounter ++)
- {
+ for(rxCounter = 0; rxCounter < 256; rxCounter ++)
rxDataBuffer[rxCounter] = rxCounter;
- }
while(1)
{
@@ -77,17 +99,13 @@ int main(void)
rxData = UART_ReceiveData(UART0);
UART_ResetRxFIFO(UART0);
if(rxData != rxDataBuffer[rxData])
- {
- printf("rx error");
- errCounter ++;
- }
+ errCounter++;
else
{
- UART_SendData(UART0,rxData);
+ UART_SendData(UART0, rxData);
UART_WaitTxFifoEmpty(UART0);
- rightCounter ++ ;
+ rightCounter++;
}
}
-
}
}
diff --git a/Examples/wdg/wdg_count/.cproject b/Examples/wdg/wdg_count/.cproject
index 21d0162..1a0019e 100644
--- a/Examples/wdg/wdg_count/.cproject
+++ b/Examples/wdg/wdg_count/.cproject
@@ -40,27 +40,28 @@
-
+
-
-
+
+
+
@@ -68,14 +69,14 @@
@@ -94,7 +95,7 @@
-
-
+
+
@@ -192,10 +193,10 @@
@@ -204,14 +205,14 @@
@@ -225,7 +226,7 @@
diff --git a/Examples/wdg/wdg_count/Project.nuproject b/Examples/wdg/wdg_count/Project.nuproject
index 0743ed2..0072223 100644
--- a/Examples/wdg/wdg_count/Project.nuproject
+++ b/Examples/wdg/wdg_count/Project.nuproject
@@ -7,7 +7,7 @@ SDK_CONFIG:
cmodel: medlow
extra_commonflags:
abi: ilp32e
- arch: rv32emac
+ arch: rv32ema_zba_zbb_zbs_zca_zcb_zcmp_zcmt_zicond
toolchain: gnu
extra_cflags:
extra_ldflags:
@@ -19,7 +19,7 @@ SDK_CONFIG:
cmodel: medlow
extra_commonflags:
abi: ilp32e
- arch: rv32emac
+ arch: rv32emac_zba_zbb_zbs
toolchain: gnu
extra_cflags:
extra_ldflags:
diff --git a/Examples/wdg/wdg_count/readme.md b/Examples/wdg/wdg_count/readme.md
index 8f0b1b4..5a3cf98 100644
--- a/Examples/wdg/wdg_count/readme.md
+++ b/Examples/wdg/wdg_count/readme.md
@@ -1,20 +1,28 @@
-wdg count and interrupt
+wdg_count
---
-This example is used to run wdg count and interrupt function.
+This is an example of WDG count
-## Hardware and Software environment
++ Select the toggle output gpio pins
-+ This example runs on PB5700 devices.
+ ```
+ // in main.c
+ #define CONFIG_TOGGLE_PORT GPIOA
+ #define CONFIG_TOGGLE_PIN GPIO_Pin_02
+ ```
-## How to use it ?
++ Configure the parameters related to WDG
++ It can be modified according to the requirements
-### In order to make the program work, you must do the following:
+ ```
+ // in main.c
+ #define CONFIG_WDG_RELAOD_VALUE (32000 - 1)
+ WDG_Reset_Dis //WDG reset disable
+ WDG_Debug_Dis //WDG debug disable
+ ```
-+ Open your preferred toolchain
-+ Rebuild all files and load your image into target memory
-+ Set the reload value
-+ Run the example
-+ If you want to use the reset function, you can set the reset enable,
- but you need to remove the clear watchdog in the interrupt.
\ No newline at end of file
+## Log
+
++ Enable the WDG interrupt
++ In the interrupt function, clear the watchdog overflow and flip the GPIO output
diff --git a/Examples/wdg/wdg_count/src/main.c b/Examples/wdg/wdg_count/src/main.c
index f7d6d48..d4833de 100644
--- a/Examples/wdg/wdg_count/src/main.c
+++ b/Examples/wdg/wdg_count/src/main.c
@@ -19,6 +19,10 @@
/* Use PA2 to toggle */
#define CONFIG_TOGGLE_PORT GPIOA
#define CONFIG_TOGGLE_PIN GPIO_Pin_02
+
+/* Use WDG relaod value */
+#define CONFIG_WDG_RELAOD_VALUE (32000 - 1)
+
//=============================================================================
// Macro Definition
//=============================================================================
@@ -36,77 +40,50 @@
//=============================================================================
__INTERRUPT void WDG_Handler(void)
{
- WDG_Clear();
- GPIO_TogglePin(CONFIG_TOGGLE_PORT, CONFIG_TOGGLE_PIN);
- return;
+ SAVE_IRQ_CSR_CONTEXT();
+ WDG_Clear();
+ GPIO_TogglePin(CONFIG_TOGGLE_PORT, CONFIG_TOGGLE_PIN);
+
+ RESTORE_IRQ_CSR_CONTEXT();
+ return;
}
+
//=============================================================================
// Public Function Definition
//=============================================================================
int main(void)
{
- WDG_BaseInitTypeDef WDG_InitStruct = {0};
+ /* Configure the system clock */
SYSCFG_ClkInitTypeDef SysClkInit = {0};
-
- SysClkInit.ClkSource = SYSCFG_ClkSrc_HSI;
+ SysClkInit.ClkSource = SYSCFG_ClkSrc_HSI;
SYSCFG_SysClkConfig(&SysClkInit);
- syslog_init();
- msg("The value of RST_INFO is %#0x\n", SYSCFG->SYSRSTSR);
- SYSCFG->SYSRSTSR = 0XFF;
+ /* Configure the GPIO of toggle pin */
+ GPIO_InitTypeDef GpioInit = {0};
+ GpioInit.GPIO_Pin = CONFIG_TOGGLE_PIN;
+ GpioInit.GPIO_Mode = GPIO_Mode_OUT;
+ GpioInit.GPIO_PuPd = GPIO_PuPd_NOPULL;
+ GpioInit.GPIO_OType = GPIO_OType_PP;
+ GPIO_Init(CONFIG_TOGGLE_PORT, &GpioInit);
- printf("Program start \r\n");
+ /* Configure the parameters of WDG */
+ WDG_BaseInitTypeDef WdgInit = {0};
+ WdgInit.Relaod = CONFIG_WDG_RELAOD_VALUE;
+ WdgInit.Reset = WDG_Reset_Dis;
+ WdgInit.Debug = WDG_Debug_Dis;
+ WDG_BaseInit(&WdgInit);
- {
- // configure I/O to toggle
- GPIO_InitTypeDef GPIO_InitStruct = {0};
- GPIO_InitStruct.GPIO_Pin = CONFIG_TOGGLE_PIN | GPIO_Pin_03;
- GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT;
- GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL;
- GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;
- GPIO_Init(CONFIG_TOGGLE_PORT, &GPIO_InitStruct);
- }
-
- GPIO_TogglePin(CONFIG_TOGGLE_PORT, GPIO_Pin_03);
- for(int i=0; i<1000; i++);
- GPIO_TogglePin(CONFIG_TOGGLE_PORT, GPIO_Pin_03);
- for(int i=0; i<1000; i++);
- GPIO_TogglePin(CONFIG_TOGGLE_PORT, GPIO_Pin_03);
-
- sys_irq_attr_t irq_attr = { .trig_mode = SYS_IRQ_TRIGGER_LEVEL, };
+ /* Configure the interrupt function of WDG */
+ sys_irq_attr_t irq_attr = { .trig_mode = SYS_IRQ_TRIGGER_LEVEL, };
sys_register_IRQ(WDG_IRQn, WDG_Handler, &irq_attr);
sys_enable_girq();
- WDG_InitStruct.Relaod = 1000; //3200;
- WDG_InitStruct.Reset = WDG_Reset_Dis;
- WDG_InitStruct.Debug = WDG_Debug_Dis;
+ /* WDG enable */
+ WDG_Enable();
- WDG_BaseInit(&WDG_InitStruct);
-
- WDG_Enable();
-
-// while(1)
-// {
-// __NOP();
-// }
-
- int i=0;
- uint32_t cnt_value[2] = {0};
- while(1)
- {
- cnt_value[0] = 0;
- cnt_value[1] = 0;
-
- cnt_value[0] = WDG_GetCountValue();
- for(i=0; i<2; )
- {
- i = i+1;
- }
- cnt_value[1] = WDG_GetCountValue();
- i = 0;
- }
-
-
- return 0;
+ while(1)
+ {
+ __NOP();
+ }
}
diff --git a/Examples/wdg/wdg_lock/.cproject b/Examples/wdg/wdg_lock/.cproject
deleted file mode 100644
index 21d0162..0000000
--- a/Examples/wdg/wdg_lock/.cproject
+++ /dev/null
@@ -1,293 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Examples/wdg/wdg_lock/.project b/Examples/wdg/wdg_lock/.project
deleted file mode 100644
index 2183c12..0000000
--- a/Examples/wdg/wdg_lock/.project
+++ /dev/null
@@ -1,54 +0,0 @@
-
-
- Project
-
-
-
-
-
- org.eclipse.cdt.managedbuilder.core.genmakebuilder
- clean,full,incremental,
-
-
-
-
- org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
- full,incremental,
-
-
-
-
-
- org.eclipse.cdt.core.cnature
- org.eclipse.cdt.managedbuilder.core.managedBuildNature
- org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
-
-
-
- Common
- 2
- PARENT-3-PROJECT_LOC/Common
-
-
- Drivers
- 2
- PARENT-3-PROJECT_LOC/Drivers
-
-
- Profiles
- 2
- PARENT-3-PROJECT_LOC/Tools/scripts/Profiles
-
-
-
-
- 0
-
- 6
-
- org.eclipse.ui.ide.multiFilter
- 1.0-name-matches-false-false-*.nuproject
-
-
-
-
diff --git a/Examples/wdg/wdg_lock/Project.nuproject b/Examples/wdg/wdg_lock/Project.nuproject
deleted file mode 100644
index 0743ed2..0000000
--- a/Examples/wdg/wdg_lock/Project.nuproject
+++ /dev/null
@@ -1,25 +0,0 @@
-SDK_CONFIG:
- Debug:
- core: N203E
- extra_asmflags:
- archext:
- extra_cxxflags:
- cmodel: medlow
- extra_commonflags:
- abi: ilp32e
- arch: rv32emac
- toolchain: gnu
- extra_cflags:
- extra_ldflags:
- Release:
- core: N203E
- extra_asmflags:
- archext:
- extra_cxxflags:
- cmodel: medlow
- extra_commonflags:
- abi: ilp32e
- arch: rv32emac
- toolchain: gnu
- extra_cflags:
- extra_ldflags:
diff --git a/Examples/wdg/wdg_lock/component.mk b/Examples/wdg/wdg_lock/component.mk
deleted file mode 100644
index b1b2bc6..0000000
--- a/Examples/wdg/wdg_lock/component.mk
+++ /dev/null
@@ -1,16 +0,0 @@
-#
-# component Makefile
-#
-
-
-C_SOURCES += \
- $(srctree)/$(PROJ)/src/isr.c \
- $(srctree)/$(PROJ)/src/main.c
-
-C_INCLUDES += -I$(srctree)/$(PROJ)/inc
-
-
-LIBS +=
-CFLAGS +=
-LDFLAGS +=
-LIBDIR +=
diff --git a/Examples/wdg/wdg_lock/inc/isr.h b/Examples/wdg/wdg_lock/inc/isr.h
deleted file mode 100644
index 2f4d4da..0000000
--- a/Examples/wdg/wdg_lock/inc/isr.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file isr.h
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/09/16
- * @license
- * @description
- */
-
-#ifndef __isr_H_wuraIpBA_lTJm_HvJw_sNDo_uEd5JnucTReY__
-#define __isr_H_wuraIpBA_lTJm_HvJw_sNDo_uEd5JnucTReY__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "main.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/Examples/wdg/wdg_lock/inc/main.h b/Examples/wdg/wdg_lock/inc/main.h
deleted file mode 100644
index 6bc013b..0000000
--- a/Examples/wdg/wdg_lock/inc/main.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file main.h
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/08/29
- * @license
- * @description
- */
-
-#ifndef __main_H_wxBnwdPw_lq7D_H4I5_sHPp_uXof15pFLp4V__
-#define __main_H_wxBnwdPw_lq7D_H4I5_sHPp_uXof15pFLp4V__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-#include "hal_device.h"
-#include "syslog.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/Examples/wdg/wdg_lock/readme.md b/Examples/wdg/wdg_lock/readme.md
deleted file mode 100644
index 0a04e69..0000000
--- a/Examples/wdg/wdg_lock/readme.md
+++ /dev/null
@@ -1,17 +0,0 @@
-wdg lock
----
-
-This example is used to run wdg lock function.
-
-## Hardware and Software environment
-
-+ This example runs on PB5700 devices.
-
-## How to use it ?
-
-### In order to make the program work, you must do the following:
-
-+ Open your preferred toolchain
-+ Rebuild all files and load your image into target memory
-+ Set the lock to aviod overwriting or unlock so that overwriting can be done
-+ Run the example
\ No newline at end of file
diff --git a/Examples/wdg/wdg_lock/src/isr.c b/Examples/wdg/wdg_lock/src/isr.c
deleted file mode 100644
index d19995f..0000000
--- a/Examples/wdg/wdg_lock/src/isr.c
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file isr.c
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/09/16
- * @license
- * @description
- */
-
-
-#include "isr.h"
-
-//=============================================================================
-// Constant Definition
-//=============================================================================
-
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-
diff --git a/Examples/wdg/wdg_lock/src/main.c b/Examples/wdg/wdg_lock/src/main.c
deleted file mode 100644
index 7303fe1..0000000
--- a/Examples/wdg/wdg_lock/src/main.c
+++ /dev/null
@@ -1,114 +0,0 @@
-/**
- * Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
- */
-/** @file main.c
- *
- * @author Wei-Lun Hsu
- * @version 0.1
- * @date 2024/08/29
- * @license
- * @description
- */
-
-
-#include "main.h"
-#include "isr.h"
-//=============================================================================
-// Constant Definition
-//=============================================================================
-/* Use PA2 to toggle */
-#define CONFIG_TOGGLE_PORT GPIOA
-#define CONFIG_TOGGLE_PIN GPIO_Pin_02
-//=============================================================================
-// Macro Definition
-//=============================================================================
-
-//=============================================================================
-// Structure Definition
-//=============================================================================
-
-//=============================================================================
-// Global Data Definition
-//=============================================================================
-uint32_t cnt_int_flag = 0;
-//=============================================================================
-// Private Function Definition
-//=============================================================================
-__INTERRUPT void WDG_Handler(void)
-{
- WDG_Clear();
- GPIO_TogglePin(CONFIG_TOGGLE_PORT, CONFIG_TOGGLE_PIN);
-
- cnt_int_flag++;
- return;
-
-}
-//=============================================================================
-// Public Function Definition
-//=============================================================================
-int main(void)
-{
- WDG_BaseInitTypeDef WDG_InitStruct = {0};
- SYSCFG_ClkInitTypeDef SysClkInit = {0};
-
- SysClkInit.ClkSource = SYSCFG_ClkSrc_HSI;
- SYSCFG_SysClkConfig(&SysClkInit);
-
- syslog_init();
- msg("The value of RST_INFO is %#0x\n", SYSCFG->SYSRSTSR);
- SYSCFG->SYSRSTSR = 0XFF;
-
- printf("Program start \r\n");
-
- {
- // configure I/O to toggle
- GPIO_InitTypeDef GPIO_InitStruct = {0};
- GPIO_InitStruct.GPIO_Pin = CONFIG_TOGGLE_PIN | GPIO_Pin_03;
- GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT;
- GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL;
- GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;
- GPIO_Init(CONFIG_TOGGLE_PORT, &GPIO_InitStruct);
- }
-
- GPIO_TogglePin(CONFIG_TOGGLE_PORT, GPIO_Pin_03);
- for(int i=0; i<1000; i++);
- GPIO_TogglePin(CONFIG_TOGGLE_PORT, GPIO_Pin_03);
- for(int i=0; i<1000; i++);
- GPIO_TogglePin(CONFIG_TOGGLE_PORT, GPIO_Pin_03);
-
- sys_irq_attr_t irq_attr = { .trig_mode = SYS_IRQ_TRIGGER_LEVEL, };
- sys_register_IRQ(WDG_IRQn, WDG_Handler, &irq_attr);
- sys_enable_girq();
-
- WDG_InitStruct.Relaod = 1000; //3200;
- WDG_InitStruct.Reset = WDG_Reset_Dis;
- WDG_InitStruct.Debug = WDG_Debug_Dis;
-
- WDG_BaseInit(&WDG_InitStruct);
-
- WDG_Enable();
- WDG_Lock();
- while(WDG_GetLockStatus() != 1);
- GPIO_TogglePin(CONFIG_TOGGLE_PORT, GPIO_Pin_03);
- cnt_int_flag = 0;
- while(cnt_int_flag<10);
-
-
- WDG_Unlock();
- while(WDG_GetLockStatus() != 0);
-
- WDG_SetReload(2000);
- WDG_Clear();
- GPIO_TogglePin(CONFIG_TOGGLE_PORT, GPIO_Pin_03);
- cnt_int_flag = 0;
- while(cnt_int_flag<10);
-
- WDG_Disable();
- GPIO_TogglePin(CONFIG_TOGGLE_PORT, GPIO_Pin_03);
- while(1)
- {
- __NOP();
- }
-
- return 0;
-}
diff --git a/Makefile b/Makefile
index ebdfdd9..73e6311 100644
--- a/Makefile
+++ b/Makefile
@@ -19,7 +19,7 @@ NC="\033[0m"
PHONY := all flash flash_nvr clean help
-PHONY += gdb_server gdb
+PHONY += gdb
PHONY += tags TAGS cscope gtags
PHONY += upload
######################################
@@ -29,12 +29,12 @@ ifeq ("$(TARGET)","")
TARGET = Project
endif
-SOC ?= pb5700
+SOC ?= pec930
ifeq (,$(filter $(MAKECMDGOALS),clean help))
-ifeq ("$(SOC)","pb5700")
- SOC_DRIVER = PB5700
+ifeq ("$(SOC)","pec930")
+ SOC_DRIVER = PEC930
else
$(error "Unknown SoC, User MUST define 'SOC' name !")
endif
@@ -54,7 +54,7 @@ DEBUG = y
OPT =
ifeq ("$(D)","0")
DEBUG = n
- OPT ?= -O2
+ OPT = -O2
endif
V ?= $(VERBOSE)
@@ -264,10 +264,6 @@ flash: $(OUT)/$(TARGET).bin
-c "program $(OUT)/$(TARGET).bin verify 0; exit" 2>&1 | tee openocd.log
-gdb_server: $(OUT)/$(TARGET).elf
- @${OPENOCD} -s Tools/openocd/scripts -f Tools/openocd/scripts/target/$(SOC).cfg
-
-
gdb: $(OUT)/$(TARGET).elf
ifeq ("$(DEBUG)","y")
@$(ECHO) $(YELLOW) "Download and Run GDB" $(NC)
@@ -288,7 +284,7 @@ endif
upload: $(OUT)/$(TARGET).bin
@$(ECHO) $(YELLOW) "Download $(OUT)/$(TARGET).elf to flash of DUT and Run" $(NC)
@$(OPENOCD) -s Tools/openocd/scripts -f Tools/openocd/scripts/target/$(SOC).cfg \
- -c "program $(OUT)/$(TARGET).elf verify 0; reset run" 2>&1 | tee openocd.log
+ -c "program $(OUT)/$(TARGET).elf verify reset exit" 2>&1 | tee openocd.log
clean:
@$(ECHO) $(YELLOW) "Clean target" $(NC)
@@ -320,7 +316,6 @@ help:
@$(ECHO) ""
@$(ECHO) " make upload - Program ELF file to flash of DUT and free-run"
@$(ECHO) ""
- @$(ECHO) " make gdb_server - Start GDB server"
@$(ECHO) " make gdb - Download elf to flash and run GDB for development"
@$(ECHO) ""
@$(ECHO) " make tags/TAGS - Generate tags file for editors"
diff --git a/README.md b/README.md
index add911b..6567e3d 100644
--- a/README.md
+++ b/README.md
@@ -1,62 +1,13 @@
-# pb5700_sdk
+# pec930_sdk
-PB5700_SDK (Nuclei-N203E)
+PEC930_SDK (RISC-V 32-bits)
+> `Tools/markdown/MarkdownEditor.exe` is a markdown viewer
+and it assists user to view markdown file friendly (e.g. readme.md)
-## Setup Editor
-
-+ Spaces to replace Tab
- > `4-空白`做縮排
-
-+ File uses `UTF-8` encoding
- > 檔案使用 `utf-8` 編碼
## Naming directory and file
+ only use ASCII `a-z`, `A-Z`, `0-9`, and `_` (DONOT use white-space)
- > 在目錄或檔案命名上, 只允許使用**英文/數字**及**下底線**, 禁止使用空白字元
-
-## Download SDK
-
-+ [Git-for-Windows](https://git-scm.com/)
-
- - Setup Git when first-time
-
- ```
- $ git config --global user.name "your name"
- $ git config --global user.email your-mail
- $ git config --global http.sslVerify false
- $ git config --global core.ignorecase false
- $ git config --global core.autocrlf input
- ```
-
- - Clone SDK
-
- ```
- $ git -c http.sslVerify=false clone --recurse-submodules https://60.248.80.176:28080/wlhsu/pb5700_sdk.git
- ```
-
- Sign-in with Username/Password
- 
-
-+ [TortoiseGit](https://tortoisegit.org/)
-
- - Use `Git-for-Windows` to configure paraments
-
- ```
- $ git config --global user.name "your name"
- $ git config --global user.email your-mail
- $ git config --global http.sslVerify false
- $ git config --global core.ignorecase false
- $ git config --global core.autocrlf input
- ```
- - Clone SDK
-
- 
-
- - 基本操作
- 1. [TortoiseGit使用 - 風御之舉 - 部落格園](https://www.cnblogs.com/agui125/p/15940508.html)
- > + `三:TortoiseGit使用`
- 1. [易學難精:Git 簡單的部分(一)](https://jonny-huang.github.io/projects/03_git_01/)
## Development
@@ -77,6 +28,17 @@ SDK uses Makefile to compile in Ubuntu and type `make help` to get message

++ Delete the recent project before open the other project (Recommend)
+ > Avoid IDE automatically appends suffix serial number
+
+
+ - Close project
+
+ 
+
+ - Delete the recent project of IDE
+
+ 
### Log message
diff --git a/Tools/openocd/scripts/target/pb5700.cfg b/Tools/openocd/scripts/target/pec930.cfg
similarity index 98%
rename from Tools/openocd/scripts/target/pb5700.cfg
rename to Tools/openocd/scripts/target/pec930.cfg
index 9756fc2..613c4ed 100644
--- a/Tools/openocd/scripts/target/pb5700.cfg
+++ b/Tools/openocd/scripts/target/pec930.cfg
@@ -102,7 +102,7 @@ set _BURN_DEV_SIZE 0x8000
# eflash
echo "=> Burn Data to eFlash ..."
-set _LOADER_BIN [_get_loader Drivers/PB5700/Flash/loader.bin]
+set _LOADER_BIN [_get_loader Drivers/PEC930/Flash/loader.bin]
flash bank $_FLASHNAME custom $_BURN_DEV_BASE $_BURN_DEV_SIZE 0 0 $_TARGETNAME 0x4000F800 $_LOADER_BIN sectorsize=512
diff --git a/Tools/scripts/Profiles/Project_Debug_OpenOCD.launch b/Tools/scripts/Profiles/Project_Debug_OpenOCD.launch
index 499d283..f2a66c4 100644
--- a/Tools/scripts/Profiles/Project_Debug_OpenOCD.launch
+++ b/Tools/scripts/Profiles/Project_Debug_OpenOCD.launch
@@ -16,13 +16,13 @@
-
+
-
+
diff --git a/Tools/scripts/Profiles/Project_Debug_jLink.launch b/Tools/scripts/Profiles/Project_Debug_jLink.launch
deleted file mode 100644
index 659be1c..0000000
--- a/Tools/scripts/Profiles/Project_Debug_jLink.launch
+++ /dev/null
@@ -1,80 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-