Skip to content

Commit

Permalink
Merge pull request #5 from stm32duino/master
Browse files Browse the repository at this point in the history
Update 23 diciembre 2020
  • Loading branch information
sabas1080 committed Dec 23, 2020
2 parents d22095e + b626ed2 commit 2e1e076
Show file tree
Hide file tree
Showing 494 changed files with 296,163 additions and 100,495 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/Continuous-Integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
- CI/**
- '!CI/build/arduino-cli.py'
- '!CI/build/platformio-builder.py'
- '!CI/build/examples/**'
- tools/**
- '!tools/platformio-build.py'
pull_request:
Expand All @@ -20,6 +21,7 @@ on:
- CI/**
- '!CI/build/arduino-cli.py'
- '!CI/build/platformio-builder.py'
- '!CI/build/examples/**'
- tools/**
- '!tools/platformio-build.py'
jobs:
Expand Down
2 changes: 1 addition & 1 deletion CI/build/arduino-cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ def find_board():
for fqbn in fqbn_list_tmp:
try:
output = subprocess.check_output(
[arduino_cli, "board", "details", "--format", "json", fqbn],
[arduino_cli, "board", "details", "--additional-urls", stm32_url, "--format", "json", fqbn],
stderr=subprocess.STDOUT,
).decode("utf-8")
except subprocess.CalledProcessError as e:
Expand Down
54 changes: 53 additions & 1 deletion CI/build/examples/BareMinimum/BareMinimum.ino
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,36 @@
#include <SoftwareSerial.h>
#include <Wire.h>

#include <CMSIS_DSP.h>
/* ----------------------------------------------------------------------
Defines each of the tests performed
------------------------------------------------------------------- */
#define MAX_BLOCKSIZE 2
#define DELTA (0.0001f)
/* ----------------------------------------------------------------------
Test input data for Floating point sin_cos example for 32-blockSize
Generated by the MATLAB randn() function
------------------------------------------------------------------- */
const float32_t testInput_f32[MAX_BLOCKSIZE] =
{
-1.244916875853235400, -4.793533929171324800
};
const float32_t testRefOutput_f32 = 1.000000000;
/* ----------------------------------------------------------------------
Declare Global variables
------------------------------------------------------------------- */
uint32_t blockSize = 2;
float32_t testOutput;
float32_t cosOutput;
float32_t sinOutput;
float32_t cosSquareOutput;
float32_t sinSquareOutput;
/* ----------------------------------------------------------------------
Max magnitude FFT Bin test
------------------------------------------------------------------- */
arm_status status;
/* CMSIS_DSP */

#ifndef USER_BTN
#define USER_BTN 2
#endif
Expand Down Expand Up @@ -103,6 +133,28 @@ void setup() {
Wire.endTransmission();
Wire.requestFrom(2, 1);
Wire.end();

// CMSIS DSP
float32_t diff;
for (uint32_t i = 0; i < blockSize; i++) {
cosOutput = arm_cos_f32(testInput_f32[i]);
sinOutput = arm_sin_f32(testInput_f32[i]);
arm_mult_f32(&cosOutput, &cosOutput, &cosSquareOutput, 1);
arm_mult_f32(&sinOutput, &sinOutput, &sinSquareOutput, 1);
arm_add_f32(&cosSquareOutput, &sinSquareOutput, &testOutput, 1);
/* absolute value of difference between ref and test */
diff = fabsf(testRefOutput_f32 - testOutput);
/* Comparison of sin_cos value with reference */
status = (diff > DELTA) ? ARM_MATH_TEST_FAILURE : ARM_MATH_SUCCESS;
if ( status == ARM_MATH_TEST_FAILURE) {
break;
}
}
if (status != ARM_MATH_SUCCESS) {
Serial.printf("FAILURE\n");
} else {
Serial.printf("SUCCESS\n");
}
}

void loop() {
Expand All @@ -120,4 +172,4 @@ void receiveEvent(int) {
// this function is registered as an event, see setup()
void requestEvent() {
Wire.write("x");
}
}
89 changes: 66 additions & 23 deletions CI/utils/stm32update.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,13 +232,16 @@ def checkVersion(serie, repo_path):
"stm32{}xx_hal.c".format(lserie),
)
cube_HAL_versions[serie] = parseVersion(HAL_file)
HAL_file = os.path.join(
hal_dest_path,
"STM32{}xx_HAL_Driver".format(userie),
"Src",
"stm32{}xx_hal.c".format(lserie),
)
core_HAL_versions[serie] = parseVersion(HAL_file)
if upargs.add:
core_HAL_versions[serie] = "0.0.0"
else:
HAL_file = os.path.join(
hal_dest_path,
"STM32{}xx_HAL_Driver".format(userie),
"Src",
"stm32{}xx_hal.c".format(lserie),
)
core_HAL_versions[serie] = parseVersion(HAL_file)

CMSIS_file = os.path.join(
repo_path,
Expand All @@ -248,13 +251,16 @@ def checkVersion(serie, repo_path):
"stm32{}xx.h".format(lserie),
)
cube_CMSIS_versions[serie] = parseVersion(CMSIS_file)
CMSIS_file = os.path.join(
cmsis_dest_path,
"STM32{}xx".format(userie),
"Include",
"stm32{}xx.h".format(lserie),
)
core_CMSIS_versions[serie] = parseVersion(CMSIS_file)
if upargs.add:
core_CMSIS_versions[serie] = "0.0.0"
else:
CMSIS_file = os.path.join(
cmsis_dest_path,
"STM32{}xx".format(userie),
"Include",
"stm32{}xx.h".format(lserie),
)
core_CMSIS_versions[serie] = parseVersion(CMSIS_file)

# print("STM32Cube" + serie + " HAL version: " + cube_HAL_versions[serie])
# print("STM32Core " + serie + " HAL version: " + core_HAL_versions[serie])
Expand Down Expand Up @@ -417,7 +423,9 @@ def updateCore():
core_CMSIS_version = core_CMSIS_versions[serie]
cube_CMSIS_version = cube_CMSIS_versions[serie]
cube_version = cube_versions[serie]
regexmd = re.compile(rf"(STM32{serie}:\s+)\d+.\d+.\d+")
regexmd_up = re.compile(rf"(STM32{serie}:\s+)\d+.\d+.\d+")
regexmd_serie = re.compile(r"STM32(\w+):\s+\d+.\d+.\d+")
regexmd_add = re.compile(r"(STM32)\w+(:\s+)\d+.\d+.\d+")
HAL_updated = False
CMSIS_updated = False
hal_commit_msg = """[{0}] Update STM32{0}xx HAL Drivers to v{1}
Expand Down Expand Up @@ -453,9 +461,22 @@ def updateCore():
)
copyFolder(HAL_serie_cube_path, HAL_serie_core_path, {"*.chm"})
# Update MD file
for line in fileinput.input(md_HAL_path, inplace=True):
line = regexmd.sub(rf"\g<1>{cube_HAL_version}", line)
print(line, end="")
if upargs.add: # Add the new STM32YY entry
added = False
for line in fileinput.input(md_HAL_path, inplace=True):
m = regexmd_serie.search(line)
if not added and m and m.group(1) > serie.upper():
print(
regexmd_add.sub(
rf"\g<1>{serie}\g<2>{cube_HAL_version}", line
),
end="",
)
added = True
print(line, end="")
else: # Update the version
for line in fileinput.input(md_HAL_path, inplace=True):
print(regexmd_up.sub(rf"\g<1>{cube_HAL_version}", line), end="")
# Commit all HAL files
commitFiles(core_path, hal_commit_msg)
HAL_updated = True
Expand All @@ -480,9 +501,22 @@ def updateCore():
)
copyFolder(CMSIS_serie_cube_path, CMSIS_serie_dest_path, {"iar", "arm"})
# Update MD file
for line in fileinput.input(md_CMSIS_path, inplace=True):
line = regexmd.sub(rf"\g<1>{cube_CMSIS_version}", line)
print(line, end="")
if upargs.add: # Add the new STM32YY entry
added = False
for line in fileinput.input(md_CMSIS_path, inplace=True):
m = regexmd_serie.search(line)
if not added and m and m.group(1) > serie.upper():
print(
regexmd_add.sub(
rf"\g<1>{serie}\g<2>{cube_CMSIS_version}", line
),
end="",
)
added = True
print(line, end="")
else: # Update the version
for line in fileinput.input(md_CMSIS_path, inplace=True):
print(regexmd_up.sub(rf"\g<1>{cube_CMSIS_version}", line), end="")
# Commit all CMSIS files
commitFiles(core_path, cmsis_commit_msg)
CMSIS_updated = True
Expand All @@ -506,9 +540,13 @@ def updateCore():
upparser.add_argument(
"-c", "--check", help="Check versions. Default all.", action="store_true"
)
upparser.add_argument(
group = upparser.add_mutually_exclusive_group()
group.add_argument(
"-s", "--serie", metavar="pattern", help="Pattern of the STM32 serie(s) to update"
)
group.add_argument(
"-a", "--add", metavar="name", help="STM32 serie name to add. Ex: 'F1'"
)

upargs = upparser.parse_args()

Expand All @@ -519,8 +557,13 @@ def main():
checkConfig()
updateCoreRepo()
stm32_list = genSTM32List(hal_dest_path, upargs.serie)
if upargs.add:
if upargs.add.upper() not in stm32_list:
stm32_list = [upargs.add.upper()]
else:
print(upargs.add + " can't be added as it already exists!")
exit(1)
updateSTRepo()

if upargs.check:
printVersion()
else:
Expand Down
19 changes: 13 additions & 6 deletions CI/utils/stm32wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,16 @@ def print_LL_header(open_file, name):


def printCMSISStartup(log):
filelist = glob.glob(
os.path.join(
CMSIS_Device_ST_path, "STM32*", "Source", "Templates", "gcc", "startup_*.s",
filelist = sorted(
glob.glob(
os.path.join(
CMSIS_Device_ST_path,
"STM32*",
"Source",
"Templates",
"gcc",
"startup_*.s",
)
)
)
if len(filelist):
Expand Down Expand Up @@ -131,9 +138,9 @@ def printCMSISStartup(log):
# File name
fn = os.path.basename(fp)
valueline = re.split("_|\\.", fn)
upper = (
valueline[1].upper().replace("X", "x").replace("MP15xx", "MP1xx")
)
if "stm32mp15" in valueline[1] and not valueline[1].endswith("xx"):
valueline[1] += "xx"
upper = valueline[1].upper().replace("X", "x")
out_file.write(
""" #elif defined({})
#define CMSIS_STARTUP_FILE \"{}\"
Expand Down
18 changes: 14 additions & 4 deletions cores/arduino/HardwareSerial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@
#endif

#if defined(HAVE_HWSERIAL10)
HardwareSerial Serial10(UART10);
#if defined(USART10)
HardwareSerial Serial10(USART10);
#else
HardwareSerial Serial10(UART10);
#endif
void serialEvent10() __attribute__((weak));
#endif

Expand Down Expand Up @@ -218,16 +222,22 @@ HardwareSerial::HardwareSerial(void *peripheral, HalfDuplexMode_t halfDuplex)
setTx(PIN_SERIAL8_TX);
} else
#endif
#if defined(PIN_SERIAL9_TX) && defined(UART9)
#if defined(PIN_SERIAL9_TX) && defined(UART9_BASE)
if (peripheral == UART9) {
#if defined(PIN_SERIAL9_RX)
setRx(PIN_SERIAL9_RX);
#endif
setTx(PIN_SERIAL9_TX);
} else
#endif
#if defined(PIN_SERIAL10_TX) && defined(UART10)
if (peripheral == UART10) {
#if defined(PIN_SERIAL10_TX) &&\
(defined(USART10_BASE) || defined(UART10_BASE))
#if defined(USART10_BASE)
if (peripheral == USART10)
#elif defined(UART10_BASE)
if (peripheral == UART10)
#endif
{
#if defined(PIN_SERIAL10_RX)
setRx(PIN_SERIAL10_RX);
#endif
Expand Down
44 changes: 33 additions & 11 deletions cores/arduino/HardwareSerial.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,16 +173,38 @@ class HardwareSerial : public Stream {
void configForLowPower(void);
};

extern HardwareSerial Serial1;
extern HardwareSerial Serial2;
extern HardwareSerial Serial3;
extern HardwareSerial Serial4;
extern HardwareSerial Serial5;
extern HardwareSerial Serial6;
extern HardwareSerial Serial7;
extern HardwareSerial Serial8;
extern HardwareSerial Serial9;
extern HardwareSerial Serial10;
extern HardwareSerial SerialLP1;
#if defined(USART1)
extern HardwareSerial Serial1;
#endif
#if defined(USART2)
extern HardwareSerial Serial2;
#endif
#if defined(USART3)
extern HardwareSerial Serial3;
#endif
#if defined(UART4) || defined(USART4)
extern HardwareSerial Serial4;
#endif
#if defined(UART5) || defined(USART5)
extern HardwareSerial Serial5;
#endif
#if defined(USART6)
extern HardwareSerial Serial6;
#endif
#if defined(UART7) || defined(USART7)
extern HardwareSerial Serial7;
#endif
#if defined(UART8) || defined(USART8)
extern HardwareSerial Serial8;
#endif
#if defined(UART9)
extern HardwareSerial Serial9;
#endif
#if defined(UART10) || defined(USART10)
extern HardwareSerial Serial10;
#endif
#if defined(LPUART1)
extern HardwareSerial SerialLP1;
#endif

#endif
Loading

0 comments on commit 2e1e076

Please sign in to comment.