-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- add hpm5300evk support - add hpm5301evklite support Signed-off-by: Zihan XU <[email protected]>
- Loading branch information
Zihan XU
committed
Jul 8, 2024
1 parent
45d786d
commit 5e0dc3c
Showing
567 changed files
with
207,768 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Arduino core for the HPMicro boards | ||
|
||
The Arduino HPMicro project is an open source project to support the development of Arduino-compatible boards based on the HPMicro SoC. | ||
|
||
#### Need help or have a question? [Open a new Issue or search for existing issues](https://github.com/hpmicro/arduino/issues) | ||
|
||
## Supported Boards | ||
|
||
Here are the boards supported by the Arduino HPMicro project: | ||
|
||
| **Board** | **Soc** | **schematic diagram** | **Pin Informations** | | ||
|----------|:---------------:|:--------------:|:------------------:| | ||
| HPM5300EVK | HPM5361 | [HPM5300](http://www.hpmicro.com/down.aspx?DId=3d0cc6ad-dd0b-4ed2-a3bb-4c3b8807dd30&LId=&SkipL=T) | [HPM5300EVK Pin Infos](https://github.com/hpmicro/arduino/blob/main/variants/hpm5300evk/README_hpm5300evk_Arduino_en.md) | | ||
| HPM5301EVKLITE | HPM5301 | | [HPM5301EVKLITE Pin Infos](https://github.com/hpmicro/arduino/blob/main/variants/hpm5301evklite/README_hpm5301evklite_Arduino_en.md) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
# Copyright (c) 2024 HPMicro | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
# | ||
# For more info: | ||
# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification | ||
|
||
menu.opt=Optimize | ||
menu.upload_method=Bootloader Mode | ||
menu.build_type=Build Type | ||
|
||
############################################################## | ||
HPM5300EVK.name=HPM5300EVK | ||
|
||
HPM5300EVK.build.board=hpm5300evk | ||
HPM5300EVK.build.arch=riscv32 | ||
HPM5300EVK.build.soc_cfg=hpm5300 | ||
HPM5300EVK.build.f_cpu=480000000L | ||
HPM5300EVK.build.mcu=HPM5361 | ||
HPM5300EVK.build.soc_series=HPM5300 | ||
HPM5300EVK.build.soc_flags="-DSOC_HAS_I2C0=1" "-DSOC_HAS_PWM=1" "-DSOC_HAS_RNG=1" | ||
HPM5300EVK.build.jlink_soc=HPM5361xCBx | ||
HPM5300EVK.vid=0x34B7 | ||
HPM5300EVK.pid=0x0005 | ||
HPM5300EVK.upload.vid=0x34B7 | ||
HPM5300EVK.upload.pid=0x0005 | ||
HPM5300EVK.build.core=hpmicro | ||
HPM5300EVK.build.cpu_flags= | ||
HPM5300EVK.build.variant=hpm5300evk | ||
HPM5300EVK.upload.tool=Serial | ||
|
||
#-- Optimizations | ||
HPM5300EVK.menu.opt.osstd=Smallest (default) | ||
|
||
HPM5300EVK.menu.opt.o1std=Fast (-O1) | ||
HPM5300EVK.menu.opt.o1std.build.flags.optimize=-O1 | ||
HPM5300EVK.menu.opt.o1std.build.flags.ldspecs= | ||
|
||
HPM5300EVK.menu.opt.o2std=Faster (-O2) | ||
HPM5300EVK.menu.opt.o2std.build.flags.optimize=-O2 | ||
HPM5300EVK.menu.opt.o2std.build.flags.ldspecs= | ||
|
||
HPM5300EVK.menu.opt.o3std=Fastest (-O3) | ||
HPM5300EVK.menu.opt.o3std.build.flags.optimize=-O3 | ||
HPM5300EVK.menu.opt.o3std.build.flags.ldspecs= | ||
|
||
HPM5300EVK.menu.opt.ogstd=Debug (-g) | ||
HPM5300EVK.menu.opt.ogstd.build.flags.optimize=-Og | ||
HPM5300EVK.menu.opt.ogstd.build.flags.ldspecs= | ||
|
||
HPM5300EVK.menu.build_type.flash=FLASH | ||
HPM5300EVK.menu.build_type.flash.build.linker_file=flash_xip | ||
HPM5300EVK.menu.build_type.flash.build.build_type_flag="-DFLASH_XIP" | ||
HPM5300EVK.menu.build_type.flash.build.build_type=FLASH | ||
|
||
HPM5300EVK.menu.build_type.ram=RAM | ||
HPM5300EVK.menu.build_type.ram.build.linker_file=ram | ||
HPM5300EVK.menu.build_type.ram.build.build_type_flag= | ||
HPM5300EVK.menu.build_type.ram.build.build_type=RAM | ||
|
||
|
||
################################################################################ | ||
|
||
#---------------------------- UPLOAD METHODS --------------------------- | ||
# Upload methods is designed to upload sketch to board by [BOOTROM] via USB(USB0) or Serial(UART0) | ||
# | ||
HPM5300EVK.menu.upload_method.DFUUploadMethod=USB | ||
HPM5300EVK.menu.upload_method.DFUUploadMethod.upload.protocol=gdb_bmp | ||
HPM5300EVK.menu.upload_method.DFUUploadMethod.upload.tool=bootrom_usb_upload | ||
|
||
HPM5300EVK.menu.upload_method.serialMethod=Serial | ||
HPM5300EVK.menu.upload_method.serialMethod.upload.protocol=gdb_bmp | ||
HPM5300EVK.menu.upload_method.serialMethod.upload.tool=bootrom_serial_upload | ||
|
||
############################################################## | ||
HPM5301EVKLITE.name=HPM5301EVKLITE | ||
|
||
HPM5301EVKLITE.build.board=hpm5301evklite | ||
HPM5301EVKLITE.build.arch=riscv32 | ||
HPM5301EVKLITE.build.soc_cfg=hpm5301 | ||
HPM5301EVKLITE.build.f_cpu=480000000L | ||
HPM5301EVKLITE.build.mcu=HPM5301 | ||
HPM5301EVKLITE.build.soc_series=HPM5300 | ||
HPM5301EVKLITE.build.soc_flags="-DSOC_HAS_I2C2=1" | ||
HPM5301EVKLITE.build.jlink_soc=HPM5301xEGx | ||
HPM5301EVKLITE.vid=0x34B7 | ||
HPM5301EVKLITE.pid=0x0005 | ||
HPM5301EVKLITE.upload.vid=0x34B7 | ||
HPM5301EVKLITE.upload.pid=0x0005 | ||
HPM5301EVKLITE.build.core=hpmicro | ||
HPM5301EVKLITE.build.cpu_flags= | ||
HPM5301EVKLITE.build.variant=hpm5301evklite | ||
HPM5301EVKLITE.upload.tool=Serial | ||
|
||
#-- Optimizations | ||
HPM5301EVKLITE.menu.opt.osstd=Smallest (default) | ||
|
||
HPM5301EVKLITE.menu.opt.o1std=Fast (-O1) | ||
HPM5301EVKLITE.menu.opt.o1std.build.flags.optimize=-O1 | ||
HPM5301EVKLITE.menu.opt.o1std.build.flags.ldspecs= | ||
|
||
HPM5301EVKLITE.menu.opt.o2std=Faster (-O2) | ||
HPM5301EVKLITE.menu.opt.o2std.build.flags.optimize=-O2 | ||
HPM5301EVKLITE.menu.opt.o2std.build.flags.ldspecs= | ||
|
||
HPM5301EVKLITE.menu.opt.o3std=Fastest (-O3) | ||
HPM5301EVKLITE.menu.opt.o3std.build.flags.optimize=-O3 | ||
HPM5301EVKLITE.menu.opt.o3std.build.flags.ldspecs= | ||
|
||
HPM5301EVKLITE.menu.opt.ogstd=Debug (-g) | ||
HPM5301EVKLITE.menu.opt.ogstd.build.flags.optimize=-Og | ||
HPM5301EVKLITE.menu.opt.ogstd.build.flags.ldspecs= | ||
|
||
HPM5301EVKLITE.menu.build_type.flash=FLASH | ||
HPM5301EVKLITE.menu.build_type.flash.build.linker_file=flash_xip | ||
HPM5301EVKLITE.menu.build_type.flash.build.build_type_flag="-DFLASH_XIP" | ||
HPM5301EVKLITE.menu.build_type.flash.build.build_type=FLASH | ||
|
||
HPM5301EVKLITE.menu.build_type.ram=RAM | ||
HPM5301EVKLITE.menu.build_type.ram.build.linker_file=ram | ||
HPM5301EVKLITE.menu.build_type.ram.build.build_type_flag= | ||
HPM5301EVKLITE.menu.build_type.ram.build.build_type=RAM | ||
|
||
################################################################################ | ||
|
||
#---------------------------- UPLOAD METHODS --------------------------- | ||
# Upload methods is designed to upload sketch to board by [BOOTROM] via USB(USB0) or Serial(UART0) | ||
# | ||
|
||
HPM5301EVKLITE.menu.upload_method.serialMethod=Serial | ||
HPM5301EVKLITE.menu.upload_method.serialMethod.upload.protocol=gdb_bmp | ||
HPM5301EVKLITE.menu.upload_method.serialMethod.upload.tool=bootrom_serial_upload |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright (c) 2024 HPMicro | ||
* | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
* | ||
*/ | ||
|
||
#ifndef Arduino_h | ||
#define Arduino_h | ||
|
||
#include <stdbool.h> | ||
#include <stdint.h> | ||
#include <stdarg.h> | ||
#include <stddef.h> | ||
#include <stdio.h> | ||
#include "class/wirish_math.h" | ||
#include <string.h> | ||
#include <inttypes.h> | ||
#include "port/Common.h" | ||
#include "board.h" | ||
#include "arduino/pins_arduino.h" | ||
#include <class/HardwareSerial.h> | ||
#include <class/SPI.h> | ||
#include <class/Wire.h> | ||
#include <class/USBMouse.h> | ||
#include <class/USBKeyboard.h> | ||
#include "arduino/i2c_instance.h" | ||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
#define pgm_read_byte(addr) (*(const unsigned char *)(addr)) | ||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* _HPMICRO_CORE_ARDUINO_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,194 @@ | ||
/* | ||
* Copyright (c) 2024 HPMicro | ||
* | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
* | ||
*/ | ||
#include "HardwareSerial.h" | ||
#include "arduino/pins_arduino.h" | ||
#include "hpm_soc.h" | ||
#include "hpm_gpio_drv.h" | ||
#include "hpm_uart_drv.h" | ||
#include "hpm_interrupt.h" | ||
#include "ring_buffer.h" | ||
HardwareSerial::HardwareSerial(uart_dev_t *usart_device) | ||
{ | ||
this->usart_device = usart_device; | ||
} | ||
|
||
void HardwareSerial::begin(uint32 baud) | ||
{ | ||
begin(baud,SERIAL_8N1); | ||
} | ||
|
||
void HardwareSerial::begin(uint32 baud, uint8_t config_arg) | ||
{ | ||
|
||
hpm_stat_t stat = status_fail; | ||
|
||
this->irq_num = usart_device->irq_num; | ||
|
||
rb_init(usart_device->rb, USART_RX_BUF_SIZE, usart_device->rx_buf); | ||
rb_init(usart_device->wb, USART_TX_BUF_SIZE, usart_device->tx_buf); | ||
|
||
HPM_IOC->PAD[usart_device->tx_ioc_idx].FUNC_CTL = usart_device->tx_ioc_fun; | ||
HPM_IOC->PAD[usart_device->rx_ioc_idx].FUNC_CTL = usart_device->rx_ioc_fun; | ||
|
||
if (usart_device->tx_pioc) { | ||
HPM_PIOC->PAD[usart_device->tx_ioc_idx].FUNC_CTL = usart_device->tx_pioc_fun; | ||
} | ||
if (usart_device->rx_pioc) { | ||
HPM_PIOC->PAD[usart_device->rx_ioc_idx].FUNC_CTL = usart_device->rx_pioc_fun; | ||
} | ||
|
||
uart_config_t config = {0}; | ||
uart_default_config(usart_device->base, &config); | ||
config.src_freq_in_hz = clock_get_frequency(usart_device->clock_name); | ||
config.baudrate = baud; | ||
switch (config_arg) { | ||
case SERIAL_5N1: | ||
config.word_length = word_length_5_bits; | ||
break; | ||
case SERIAL_6N1: | ||
config.word_length = word_length_6_bits; | ||
break; | ||
case SERIAL_7N1: | ||
config.word_length = word_length_7_bits; | ||
break; | ||
case SERIAL_5N2: | ||
config.word_length = word_length_5_bits; | ||
config.num_of_stop_bits = stop_bits_2; | ||
break; | ||
case SERIAL_6N2: | ||
config.word_length = word_length_6_bits; | ||
config.num_of_stop_bits = stop_bits_2; | ||
break; | ||
case SERIAL_7N2: | ||
config.word_length = word_length_7_bits; | ||
config.num_of_stop_bits = stop_bits_2; | ||
break; | ||
case SERIAL_8N2: | ||
config.num_of_stop_bits = stop_bits_2; | ||
break; | ||
case SERIAL_5E1: | ||
config.word_length = word_length_5_bits; | ||
config.parity = parity_even; | ||
break; | ||
case SERIAL_6E1: | ||
config.word_length = word_length_6_bits; | ||
config.parity = parity_even; | ||
break; | ||
case SERIAL_7E1: | ||
config.word_length = word_length_7_bits; | ||
config.parity = parity_even; | ||
break; | ||
case SERIAL_8E1: | ||
config.parity = parity_even; | ||
break; | ||
case SERIAL_5E2: | ||
config.word_length = word_length_5_bits; | ||
config.num_of_stop_bits = stop_bits_2; | ||
config.parity = parity_even; | ||
break; | ||
case SERIAL_6E2: | ||
config.word_length = word_length_6_bits; | ||
config.num_of_stop_bits = stop_bits_2; | ||
config.parity = parity_even; | ||
break; | ||
case SERIAL_7E2: | ||
config.word_length = word_length_7_bits; | ||
config.num_of_stop_bits = stop_bits_2; | ||
config.parity = parity_even; | ||
break; | ||
case SERIAL_8E2: | ||
config.num_of_stop_bits = stop_bits_2; | ||
config.parity = parity_even; | ||
break; | ||
case SERIAL_5O1: | ||
config.word_length = word_length_5_bits; | ||
config.parity = parity_odd; | ||
break; | ||
case SERIAL_6O1: | ||
config.word_length = word_length_6_bits; | ||
config.parity = parity_odd; | ||
break; | ||
case SERIAL_7O1: | ||
config.word_length = word_length_7_bits; | ||
config.parity = parity_odd; | ||
break; | ||
case SERIAL_8O1: | ||
config.parity = parity_odd; | ||
break; | ||
case SERIAL_5O2: | ||
config.word_length = word_length_5_bits; | ||
config.num_of_stop_bits = stop_bits_2; | ||
config.parity = parity_odd; | ||
break; | ||
case SERIAL_6O2: | ||
config.word_length = word_length_6_bits; | ||
config.num_of_stop_bits = stop_bits_2; | ||
config.parity = parity_odd; | ||
break; | ||
case SERIAL_7O2: | ||
config.word_length = word_length_7_bits; | ||
config.num_of_stop_bits = stop_bits_2; | ||
config.parity = parity_odd; | ||
break; | ||
case SERIAL_8O2: | ||
config.num_of_stop_bits = stop_bits_2; | ||
config.parity = parity_odd; | ||
break; | ||
default: | ||
break; | ||
} | ||
stat = uart_init(usart_device->base, &config); | ||
if (status_success != stat) { | ||
printf("Failed init HardwareSerial\n"); | ||
while(1); | ||
} | ||
uart_enable_irq(usart_device->base, uart_intr_rx_data_avail_or_timeout); | ||
intc_m_enable_irq_with_priority(irq_num, 1); | ||
} | ||
|
||
void HardwareSerial::end(void) | ||
{ | ||
intc_m_disable_irq(irq_num); | ||
} | ||
|
||
int HardwareSerial::read(void) | ||
{ | ||
if(available()) { | ||
return rb_remove(usart_device->rb); | ||
} else { | ||
return -1; | ||
} | ||
} | ||
|
||
int HardwareSerial::available(void) { | ||
return rb_full_count(this->usart_device->rb); | ||
} | ||
|
||
int HardwareSerial::peek(void) | ||
{ | ||
return rb_peek(this->usart_device->rb); | ||
} | ||
|
||
int HardwareSerial::availableForWrite(void) | ||
{ | ||
return this->usart_device->wb->size-rb_full_count(this->usart_device->wb); | ||
} | ||
|
||
size_t HardwareSerial::write(unsigned char ch) | ||
{ | ||
hpm_stat_t stat; | ||
stat = uart_send_byte(usart_device->base, ch); | ||
if (stat != status_success) { | ||
err_count++; | ||
} | ||
return 1; | ||
} | ||
|
||
void HardwareSerial::flush(void) | ||
{ | ||
while(!rb_is_empty(this->usart_device->wb)); // wait for TX buffer empty | ||
} |
Oops, something went wrong.