Skip to content

Commit

Permalink
RT-Thread BSP v0.7.0 for HPM6300EVK
Browse files Browse the repository at this point in the history
- Integrated HPM_SDK v0.12.1
- Fixed some bugs
- Switched to RV32 toolchain by default

Signed-off-by: Fan YANG <[email protected]>
  • Loading branch information
helloeagleyang committed Aug 1, 2022
1 parent a93d9f7 commit 9d7ff2d
Show file tree
Hide file tree
Showing 5,034 changed files with 239,043 additions and 1,234,652 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
7 changes: 7 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Change Log

## v0.7.0
- Integrated the SDK v0.12.1 release
- Note:
- The doc, middleware, cmake, samples folder were removed
- Fixed:
- SD card multi-block read/write issue

## v0.6.0
- Integrated the SDK v0.11.0 release
- Note:
Expand Down
7 changes: 7 additions & 0 deletions ChangeLog_zh.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# 更新

## 0.7.0
- 整合了SDK v0.12.1
- 注:
- SDK根目录下的doc, middleware,samples,cmake 目录被删除
- 修复了如下问题:
- sd 卡 multi-block read/write 问题

## v0.6.0

- 整合了SDK v0.11.0
Expand Down
34 changes: 17 additions & 17 deletions HPMicro-HPM6300EVK.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ features_zh:
- '调试接口: 板载FT2232'
pkg_type: Board_Support_Packages
pkg_vendor: HPMicro
pkg_version: 0.6.0
pkg_version: 0.7.0

template_projects:
- project_name: blink_led
Expand Down Expand Up @@ -81,10 +81,10 @@ template_projects:
files_and_folders:
- board
external_files:
- package_name: RISC-V-GCC
- package_name: RISC-V-GCC-RV32
package_type: ToolChain_Support_Packages
package_vendor: 'RISC-V'
package_version: 11.1.0
package_version: '2022-04-12'
source_path_offset: ''
target_path_offset: ''
files_and_folders: []
Expand Down Expand Up @@ -126,10 +126,10 @@ example_projects:
files_and_folders:
- board
external_files:
- package_name: RISC-V-GCC
- package_name: RISC-V-GCC-RV32
package_type: ToolChain_Support_Packages
package_vendor: 'RISC-V'
package_version: 11.1.0
package_version: '2022-04-12'
source_path_offset: ''
target_path_offset: ''
files_and_folders: []
Expand Down Expand Up @@ -170,10 +170,10 @@ example_projects:
files_and_folders:
- board
external_files:
- package_name: RISC-V-GCC
- package_name: RISC-V-GCC-RV32
package_type: ToolChain_Support_Packages
package_vendor: 'RISC-V'
package_version: 11.1.0
package_version: '2022-04-12'
source_path_offset: ''
target_path_offset: ''
files_and_folders: []
Expand Down Expand Up @@ -214,10 +214,10 @@ example_projects:
files_and_folders:
- board
external_files:
- package_name: RISC-V-GCC
- package_name: RISC-V-GCC-RV32
package_type: ToolChain_Support_Packages
package_vendor: 'RISC-V'
package_version: 11.1.0
package_version: '2022-04-12'
source_path_offset: ''
target_path_offset: ''
files_and_folders: []
Expand Down Expand Up @@ -258,10 +258,10 @@ example_projects:
files_and_folders:
- board
external_files:
- package_name: RISC-V-GCC
- package_name: RISC-V-GCC-RV32
package_type: ToolChain_Support_Packages
package_vendor: 'RISC-V'
package_version: 11.1.0
package_version: '2022-04-12'
source_path_offset: ''
target_path_offset: ''
files_and_folders: []
Expand Down Expand Up @@ -302,10 +302,10 @@ example_projects:
files_and_folders:
- board
external_files:
- package_name: RISC-V-GCC
- package_name: RISC-V-GCC-RV32
package_type: ToolChain_Support_Packages
package_vendor: 'RISC-V'
package_version: 11.1.0
package_version: '2022-04-12'
source_path_offset: ''
target_path_offset: ''
files_and_folders: []
Expand Down Expand Up @@ -346,10 +346,10 @@ example_projects:
files_and_folders:
- board
external_files:
- package_name: RISC-V-GCC
- package_name: RISC-V-GCC-RV32
package_type: ToolChain_Support_Packages
package_vendor: 'RISC-V'
package_version: 11.1.0
package_version: '2022-04-12'
source_path_offset: ''
target_path_offset: ''
files_and_folders: []
Expand Down Expand Up @@ -390,10 +390,10 @@ example_projects:
files_and_folders:
- board
external_files:
- package_name: RISC-V-GCC
- package_name: RISC-V-GCC-RV32
package_type: ToolChain_Support_Packages
package_vendor: 'RISC-V'
package_version: 11.1.0
package_version: '2022-04-12'
source_path_offset: ''
target_path_offset: ''
files_and_folders: []
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ RT-Thread Studio BSP for HPM6300EVK Board
- flashdb_demo
- can_example
- adc_example
- Users need to provide valid voltage to ADC1 IN7 pin(J26 Pin5 on HPM6300EVK) first, then runs the adc demo, the sampled voltage will be printed out by the demo via the console UART periodically.
- Valid voltage range is [0V, 3.3V], make sure the input voltage is in valid range, otherwise the SoC may be demaged.
4 changes: 3 additions & 1 deletion README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ HPM6300EVK 开板的 RT-Thread Studio 板级支持包
- sdcard_demo
- flashdb_demo
- can_example
- adc_example
- adc_example
- demo运行前需要给ADC1 IN7引脚(插件J26 Pin5)一个输入电压,adc demo会通过控制台打印采样到的电压值
- 输入电压范围0-3.3v,超出范围可能会损坏芯片
32 changes: 8 additions & 24 deletions board/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,29 +189,12 @@ uint32_t board_init_dram_clock(void)

void board_delay_us(uint32_t us)
{
static uint32_t gptmr_freq;
gptmr_channel_config_t config;

if (init_delay_flag == false) {
init_delay_flag = true;
clock_add_to_group(BOARD_DELAY_TIMER_CLK_NAME, 0);
gptmr_freq = clock_get_frequency(BOARD_DELAY_TIMER_CLK_NAME);
gptmr_channel_get_default_config(BOARD_DELAY_TIMER, &config);
gptmr_channel_config(BOARD_DELAY_TIMER, BOARD_DELAY_TIMER_CH, &config, false);
}

gptmr_channel_config_update_reload(BOARD_DELAY_TIMER, BOARD_DELAY_TIMER_CH, gptmr_freq / 1000000 * us);
gptmr_start_counter(BOARD_DELAY_TIMER, BOARD_DELAY_TIMER_CH);
while (!gptmr_check_status(BOARD_DELAY_TIMER, GPTMR_CH_RLD_STAT_MASK(BOARD_DELAY_TIMER_CH))) {
__asm("nop");
}
gptmr_stop_counter(BOARD_DELAY_TIMER, BOARD_DELAY_TIMER_CH);
gptmr_clear_status(BOARD_DELAY_TIMER, GPTMR_CH_RLD_STAT_MASK(BOARD_DELAY_TIMER_CH));
clock_cpu_delay_us(us);
}

void board_delay_ms(uint32_t ms)
{
board_delay_us(1000 * ms);
clock_cpu_delay_ms(ms);
}

void board_timer_isr(void)
Expand Down Expand Up @@ -342,6 +325,7 @@ void board_init_pmp(void)
void board_init_clock(void)
{
uint32_t cpu0_freq = clock_get_frequency(clock_cpu0);
hpm_core_clock = cpu0_freq;
if (cpu0_freq == PLLCTL_SOC_PLL_REFCLK_FREQ) {
/* Configure the External OSC ramp-up time: ~9ms */
pllctlv2_xtal_set_rampup_time(HPM_PLLCTLV2, 32UL * 1000UL * 9U);
Expand Down Expand Up @@ -424,19 +408,19 @@ uint32_t board_init_adc12_clock(ADC16_Type *ptr)
switch ((uint32_t) ptr) {
case HPM_ADC0_BASE:
/* Configure the ADC clock to 200MHz */
clock_set_adc_source(clock_adc0, clk_adc_src_ana0);
clock_set_adc_source(clock_adc0, clk_adc_src_ana);
clock_set_source_divider(clock_ana0, clk_src_pll1_clk1, 2U);
freq = clock_get_frequency(clock_adc0);
break;
case HPM_ADC1_BASE:
/* Configure the ADC clock to 200MHz */
clock_set_adc_source(clock_adc1, clk_adc_src_ana0);
clock_set_adc_source(clock_adc1, clk_adc_src_ana);
clock_set_source_divider(clock_ana0, clk_src_pll1_clk1, 2U);
freq = clock_get_frequency(clock_adc1);
break;
case HPM_ADC2_BASE:
/* Configure the ADC clock to 200MHz */
clock_set_adc_source(clock_adc2, clk_adc_src_ana0);
clock_set_adc_source(clock_adc2, clk_adc_src_ana);
clock_set_source_divider(clock_ana0, clk_src_pll1_clk1, 2U);
freq = clock_get_frequency(clock_adc2);
break;
Expand Down Expand Up @@ -475,10 +459,10 @@ uint32_t board_init_dac_clock(DAC_Type *ptr, bool clk_src_ahb)
if (ptr == HPM_DAC) {
if (clk_src_ahb == true) {
/* Configure the DAC clock to 133MHz */
clock_set_dac_source(clock_dac0, clk_dac_src_ahb0);
clock_set_dac_source(clock_dac0, clk_dac_src_ahb);
} else {
/* Configure the DAC clock to 166MHz */
clock_set_dac_source(clock_dac0, clk_dac_src_ana3);
clock_set_dac_source(clock_dac0, clk_dac_src_ana);
clock_set_source_divider(clock_ana3, clk_src_pll0_clk1, 2);
}

Expand Down
6 changes: 3 additions & 3 deletions board/fal_flash_port.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ FAL_RAMFUNC static int read(long offset, uint8_t *buf, size_t size)
l1c_dc_invalidate(aligned_start, aligned_size);
rt_hw_interrupt_enable(level);

(void) memcpy(buf, (void*) flash_addr, size);
(void) rt_memcpy(buf, (void*) flash_addr, size);

return size;
}
Expand Down Expand Up @@ -173,7 +173,7 @@ FAL_RAMFUNC static int write(long offset, const uint8_t *buf, size_t size)
{
uint32_t write_size_in_page = page_size - offset_in_page;
uint32_t write_page_size = MIN(write_size_in_page, size);
(void) memcpy(buf_32, buf, write_page_size);
(void) rt_memcpy(buf_32, buf, write_page_size);
write_size = write_unaligned_page_data(offset, buf_32, write_page_size);
if (write_size < 0)
{
Expand All @@ -189,7 +189,7 @@ FAL_RAMFUNC static int write(long offset, const uint8_t *buf, size_t size)
while (remaining_size > 0)
{
write_size = MIN(remaining_size, sizeof(buf_32));
memcpy(buf_32, buf, write_size);
rt_memcpy(buf_32, buf, write_size);
src = &buf_32[0];

FAL_ENTER_CRITICAL();
Expand Down
14 changes: 14 additions & 0 deletions board/rtt_board.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,17 @@ ATTR_PLACE_AT(".isr_vector") void mchtmr_isr(void)
rt_tick_increase();
rt_interrupt_leave();
}

void rt_hw_cpu_reset(void)
{
HPM_PPOR->RESET_ENABLE = (1UL << 31);
HPM_PPOR->RESET_HOT &= ~(1UL << 31);
HPM_PPOR->RESET_COLD |= (1UL << 31);

HPM_PPOR->SOFTWARE_RESET = 1000U;
while(1) {

}
}

MSH_CMD_EXPORT_ALIAS(rt_hw_cpu_reset, reset, reset the board);
3 changes: 3 additions & 0 deletions common/libraries/drivers/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ if GetDepend('BSP_USING_UART'):
if GetDepend('BSP_USING_ADC'):
src += ['drv_adc.c']

if GetDepend('BSP_USING_USB_HOST'):
src += ['drv_usb.c']

path = [cwd]

group = DefineGroup('Drivers', src, depend = [''], CPPPATH = path)
Expand Down
5 changes: 3 additions & 2 deletions common/libraries/drivers/drv_enet.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
/*
* Copyright (c) 2021 hpm
* Copyright (c) 2021 - 2022 hpmicro
*
* SPDX-License-Identifier: BSD-3-Clause
*
* Change Logs:
* Date Author Notes
* 2022-01-11 hpm First version
* 2022-01-11 hpmicro First version
* 2022-07-10 hpmicro Driver optimization for multiple instances
*/

#include <rtdevice.h>
Expand Down
11 changes: 2 additions & 9 deletions common/libraries/drivers/drv_gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
*
* Change Logs:
* Date Author Notes
* 2022-01-11 hpm First version
* 2022-01-11 hpmicro First version
* 2022-07-28 hpmicro Fixed compiling warnings
*/

#include <rtthread.h>
Expand Down Expand Up @@ -75,7 +76,6 @@ static int hpm_get_gpi_irq_num(uint32_t gpio_idx)
static void hpm_gpio_isr(uint32_t gpio_index, GPIO_Type *base)
{
uint32_t pin_idx = 0;
uint32_t isr_status = gpio_get_port_interrupt_flags(base, gpio_index);
for(pin_idx = 0; pin_idx < 32; pin_idx++)
{
if (gpio_check_pin_interrupt_flag(base, gpio_index, pin_idx))
Expand Down Expand Up @@ -234,9 +234,6 @@ static void hpm_pin_write(rt_device_t dev, rt_base_t pin, rt_base_t value)
static rt_err_t hpm_pin_attach_irq(struct rt_device *device, rt_int32_t pin, rt_uint32_t mode,
void (*hdr)(void *args), void *args)
{
/* TODO: Check the validity of the pin value */
uint32_t gpio_idx = pin >> 5;
uint32_t pin_idx = pin & 0x1FU;

rt_base_t level;
level = rt_hw_interrupt_disable();
Expand All @@ -251,10 +248,6 @@ static rt_err_t hpm_pin_attach_irq(struct rt_device *device, rt_int32_t pin, rt_

static rt_err_t hpm_pin_detach_irq(struct rt_device *device, rt_int32_t pin)
{
/* TODO: Check the validity of the pin value */
uint32_t gpio_idx = pin >> 5;
uint32_t pin_idx = pin & 0x1FU;

rt_base_t level;
level = rt_hw_interrupt_disable();
hpm_gpio_pin_hdr_tbl[pin].pin = -1;
Expand Down
7 changes: 5 additions & 2 deletions common/libraries/drivers/drv_i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#include "hpm_i2c_drv.h"
#include "board.h"

#ifdef RT_USING_I2C

struct hpm_i2c
{
struct rt_i2c_bus_device bus;
Expand Down Expand Up @@ -130,20 +132,21 @@ int rt_hw_i2c_init(void)
freq = clock_get_frequency(hpm_i2cs[i].clk_name);
stat = i2c_init_master(hpm_i2cs[i].base, freq, &config);
if (stat != status_success) {
LOG_E("rt i2c device %s init failed", hpm_i2cs[i].device_name);
LOG_E("rt i2c device %s init failed", hpm_i2cs[i].bus_name);
}

hpm_i2cs[i].bus.ops = &hpm_i2c_ops;
ret = rt_i2c_bus_device_register(&hpm_i2cs[i].bus, hpm_i2cs[i].bus_name);
if (ret != RT_EOK) {
LOG_E("rt i2c device %s register failed, status=%d\n", hpm_i2cs[i].device_name, ret);
LOG_E("rt i2c device %s register failed, status=%d\n", hpm_i2cs[i].bus_name, ret);
}
}

return ret;
}
INIT_DEVICE_EXPORT(rt_hw_i2c_init);

#endif /* RT_USING_I2C */

#endif /*BSP_USING_I2C*/

Loading

0 comments on commit 9d7ff2d

Please sign in to comment.