Skip to content

Commit c832515

Browse files
authored
Merge pull request #5770 from 0xc0170/fix_rza1h
Renesas: fix cmsis lib build
2 parents eda0acc + a8fc394 commit c832515

File tree

8 files changed

+61
-112
lines changed

8 files changed

+61
-112
lines changed

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,3 +188,5 @@ matrix:
188188
env: NAME=mbed2-ATMEL
189189
- <<: *mbed-2
190190
env: NAME=mbed2-NUVOTON
191+
- <<: *mbed-2
192+
env: NAME=mbed2-RENESAS

targets/TARGET_RENESAS/TARGET_RZ_A1H/device/os_tick_ostm.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
* limitations under the License.
2323
*/
2424

25+
#ifdef MBED_CONF_RTOS_PRESENT
26+
2527
#include "os_tick.h"
2628
#include "irq_ctrl.h"
2729

@@ -185,3 +187,6 @@ uint32_t OS_Tick_GetCount (void) {
185187
uint32_t OS_Tick_GetOverflow (void) {
186188
return (IRQ_GetPending(OSTM_IRQn));
187189
}
190+
191+
#endif
192+

targets/TARGET_RENESAS/TARGET_VK_RZ_A1H/device/VKRZA1H.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -626,9 +626,9 @@ typedef enum IRQn
626626
#define __NVIC_PRIO_BITS 5 /*!< Number of Bits used for Priority Levels */
627627
#define __Vendor_SysTickConfig 0 /*!< Set to 1 if different SysTick Config is used */
628628

629-
#include <core_ca9.h>
629+
#include "core_ca.h"
630630
#include "system_VKRZA1H.h"
631-
631+
#include "iodefine.h"
632632

633633
/******************************************************************************/
634634
/* Device Specific Peripheral Section */

targets/TARGET_RENESAS/TARGET_VK_RZ_A1H/serial_api.c

Lines changed: 21 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "cmsis.h"
2424
#include "pinmap.h"
2525
#include "gpio_api.h"
26+
#include "mbed_critical.h"
2627

2728
#include "scif_iodefine.h"
2829
#include "cpg_iodefine.h"
@@ -570,21 +571,14 @@ static void serial_flow_irq_set(serial_t *obj, uint32_t enable) {
570571
int serial_getc(serial_t *obj) {
571572
uint16_t err_read;
572573
int data;
573-
int was_masked;
574574

575-
#if defined ( __ICCARM__ )
576-
was_masked = __disable_irq_iar();
577-
#else
578-
was_masked = __disable_irq();
579-
#endif /* __ICCARM__ */
575+
core_util_critical_section_enter();
580576
if (obj->uart->SCFSR & 0x93) {
581577
err_read = obj->uart->SCFSR;
582578
obj->uart->SCFSR = (err_read & ~0x93);
583579
}
584580
obj->uart->SCSCR |= 0x0040; // Set RIE
585-
if (!was_masked) {
586-
__enable_irq();
587-
}
581+
core_util_critical_section_exit();
588582

589583
if (obj->uart->SCLSR & 0x0001) {
590584
obj->uart->SCLSR = 0u; // ORER clear
@@ -593,16 +587,12 @@ int serial_getc(serial_t *obj) {
593587
while (!serial_readable(obj));
594588
data = obj->uart->SCFRDR & 0xff;
595589

596-
#if defined ( __ICCARM__ )
597-
was_masked = __disable_irq_iar();
598-
#else
599-
was_masked = __disable_irq();
600-
#endif /* __ICCARM__ */
590+
core_util_critical_section_enter();
591+
601592
err_read = obj->uart->SCFSR;
602593
obj->uart->SCFSR = (err_read & 0xfffD); // Clear RDF
603-
if (!was_masked) {
604-
__enable_irq();
605-
}
594+
595+
core_util_critical_section_exit();
606596

607597
if (err_read & 0x80) {
608598
data = -1; //err
@@ -612,29 +602,16 @@ int serial_getc(serial_t *obj) {
612602

613603
void serial_putc(serial_t *obj, int c) {
614604
uint16_t dummy_read;
615-
int was_masked;
616605

617-
#if defined ( __ICCARM__ )
618-
was_masked = __disable_irq_iar();
619-
#else
620-
was_masked = __disable_irq();
621-
#endif /* __ICCARM__ */
606+
core_util_critical_section_enter();
622607
obj->uart->SCSCR |= 0x0080; // Set TIE
623-
if (!was_masked) {
624-
__enable_irq();
625-
}
608+
core_util_critical_section_exit();
626609
while (!serial_writable(obj));
627610
obj->uart->SCFTDR = c;
628-
#if defined ( __ICCARM__ )
629-
was_masked = __disable_irq_iar();
630-
#else
631-
was_masked = __disable_irq();
632-
#endif /* __ICCARM__ */
611+
core_util_critical_section_enter();
633612
dummy_read = obj->uart->SCFSR;
634613
obj->uart->SCFSR = (dummy_read & 0xff9f); // Clear TEND/TDFE
635-
if (!was_masked) {
636-
__enable_irq();
637-
}
614+
core_util_critical_section_exit();
638615
uart_data[obj->index].count++;
639616
}
640617

@@ -647,83 +624,46 @@ int serial_writable(serial_t *obj) {
647624
}
648625

649626
void serial_clear(serial_t *obj) {
650-
int was_masked;
651-
#if defined ( __ICCARM__ )
652-
was_masked = __disable_irq_iar();
653-
#else
654-
was_masked = __disable_irq();
655-
#endif /* __ICCARM__ */
656-
627+
core_util_critical_section_enter();
657628
obj->uart->SCFCR |= 0x06; // TFRST = 1, RFRST = 1
658629
obj->uart->SCFCR &= ~0x06; // TFRST = 0, RFRST = 0
659630
obj->uart->SCFSR &= ~0x0093u; // ER, BRK, RDF, DR = 0
660-
661-
if (!was_masked) {
662-
__enable_irq();
663-
}
631+
core_util_critical_section_exit();
664632
}
665633

666634
void serial_pinout_tx(PinName tx) {
667635
pinmap_pinout(tx, PinMap_UART_TX);
668636
}
669637

670638
void serial_break_set(serial_t *obj) {
671-
int was_masked;
672-
#if defined ( __ICCARM__ )
673-
was_masked = __disable_irq_iar();
674-
#else
675-
was_masked = __disable_irq();
676-
#endif /* __ICCARM__ */
639+
core_util_critical_section_enter();
677640
// TxD Output(L)
678641
obj->uart->SCSPTR &= ~0x0001u; // SPB2DT = 0
679642
obj->uart->SCSCR &= ~0x0020u; // TE = 0 (Output disable)
680-
if (!was_masked) {
681-
__enable_irq();
682-
}
643+
core_util_critical_section_exit();
683644
}
684645

685646
void serial_break_clear(serial_t *obj) {
686-
int was_masked;
687-
#if defined ( __ICCARM__ )
688-
was_masked = __disable_irq_iar();
689-
#else
690-
was_masked = __disable_irq();
691-
#endif /* __ICCARM__ */
647+
core_util_critical_section_enter();
692648
obj->uart->SCSCR |= 0x0020u; // TE = 1 (Output enable)
693649
obj->uart->SCSPTR |= 0x0001u; // SPB2DT = 1
694-
if (!was_masked) {
695-
__enable_irq();
696-
}
650+
core_util_critical_section_exit();
697651
}
698652

699653
void serial_set_flow_control(serial_t *obj, FlowControl type, PinName rxflow, PinName txflow) {
700654
// determine the UART to use
701-
int was_masked;
702-
703655
serial_flow_irq_set(obj, 0);
704656

705657
if (type == FlowControlRTSCTS) {
706-
#if defined ( __ICCARM__ )
707-
was_masked = __disable_irq_iar();
708-
#else
709-
was_masked = __disable_irq();
710-
#endif /* __ICCARM__ */
658+
core_util_critical_section_enter();
711659
obj->uart->SCFCR = 0x0008u; // CTS/RTS enable
712-
if (!was_masked) {
713-
__enable_irq();
714-
}
660+
core_util_critical_section_exit();
715661
pinmap_pinout(rxflow, PinMap_UART_RTS);
716662
pinmap_pinout(txflow, PinMap_UART_CTS);
717663
} else {
718-
#if defined ( __ICCARM__ )
719-
was_masked = __disable_irq_iar();
720-
#else
721-
was_masked = __disable_irq();
722-
#endif /* __ICCARM__ */
664+
core_util_critical_section_enter();
723665
obj->uart->SCFCR = 0x0000u; // CTS/RTS diable
724-
if (!was_masked) {
725-
__enable_irq();
726-
}
666+
core_util_critical_section_exit();
727667
}
728668
}
729669

targets/TARGET_RENESAS/TARGET_VK_RZ_A1H/us_ticker.c

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
#include "RZ_A1_Init.h"
2222
#include "VKRZA1H.h"
23+
#include "mbed_critical.h"
2324

2425
#define US_TICKER_TIMER_IRQn (OSTMI1TINT_IRQn)
2526
#define CPG_STBCR5_BIT_MSTP50 (0x01u) /* OSTM1 */
@@ -83,22 +84,14 @@ static uint64_t ticker_read_counter64(void) {
8384
uint32_t us_ticker_read() {
8485
uint64_t cnt_val64;
8586
uint64_t us_val64;
86-
int check_irq_masked;
8787

88-
#if defined ( __ICCARM__)
89-
check_irq_masked = __disable_irq_iar();
90-
#else
91-
check_irq_masked = __disable_irq();
92-
#endif /* __ICCARM__ */
88+
core_util_critical_section_enter();
9389

9490
cnt_val64 = ticker_read_counter64();
9591
us_val64 = (cnt_val64 / count_clock);
9692
ticker_us_last64 = us_val64;
9793

98-
if (!check_irq_masked) {
99-
__enable_irq();
100-
}
101-
94+
core_util_critical_section_exit();
10295
/* clock to us */
10396
return (uint32_t)us_val64;
10497
}

targets/targets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2411,7 +2411,7 @@
24112411
"device_has": ["ANALOGIN", "CAN", "ETHERNET", "I2C", "I2CSLAVE", "INTERRUPTIN", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SERIAL", "SERIAL_FC", "SPI", "SPISLAVE", "STDIO_MESSAGES"],
24122412
"features": ["LWIP"],
24132413
"default_lib": "std",
2414-
"release_versions": ["2"]
2414+
"release_versions": []
24152415
},
24162416
"MAXWSNENV": {
24172417
"inherits": ["Target"],

tools/build_api.py

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -999,19 +999,6 @@ def build_mbed_libs(target, toolchain_name, verbose=False,
999999
config.add_config_files([MBED_CONFIG_FILE])
10001000
toolchain.set_config_data(toolchain.config.get_config_data())
10011001

1002-
# CMSIS
1003-
toolchain.info("Building library %s (%s, %s)" %
1004-
('CMSIS', target.name, toolchain_name))
1005-
cmsis_src = MBED_CMSIS_PATH
1006-
resources = toolchain.scan_resources(cmsis_src)
1007-
1008-
toolchain.copy_files(resources.headers, build_target)
1009-
toolchain.copy_files(resources.linker_script, build_toolchain)
1010-
toolchain.copy_files(resources.bin_files, build_toolchain)
1011-
1012-
objects = toolchain.compile_sources(resources, tmp_path)
1013-
toolchain.copy_files(objects, build_toolchain)
1014-
10151002
# mbed
10161003
toolchain.info("Building library %s (%s, %s)" %
10171004
('MBED', target.name, toolchain_name))
@@ -1027,9 +1014,12 @@ def build_mbed_libs(target, toolchain_name, verbose=False,
10271014
toolchain.copy_files(resources.headers, dest)
10281015
library_incdirs.append(dest)
10291016

1030-
# Target specific sources
1031-
hal_src = MBED_TARGETS_PATH
1032-
hal_implementation = toolchain.scan_resources(hal_src)
1017+
cmsis_implementation = toolchain.scan_resources(MBED_CMSIS_PATH)
1018+
toolchain.copy_files(cmsis_implementation.headers, build_target)
1019+
toolchain.copy_files(cmsis_implementation.linker_script, build_toolchain)
1020+
toolchain.copy_files(cmsis_implementation.bin_files, build_toolchain)
1021+
1022+
hal_implementation = toolchain.scan_resources(MBED_TARGETS_PATH)
10331023
toolchain.copy_files(hal_implementation.headers +
10341024
hal_implementation.hex_files +
10351025
hal_implementation.libraries +
@@ -1038,8 +1028,8 @@ def build_mbed_libs(target, toolchain_name, verbose=False,
10381028
toolchain.copy_files(hal_implementation.linker_script, build_toolchain)
10391029
toolchain.copy_files(hal_implementation.bin_files, build_toolchain)
10401030
incdirs = toolchain.scan_resources(build_target).inc_dirs
1041-
objects = toolchain.compile_sources(hal_implementation,
1042-
library_incdirs + incdirs)
1031+
objects = toolchain.compile_sources(cmsis_implementation + hal_implementation,
1032+
library_incdirs + incdirs + [tmp_path])
10431033
toolchain.copy_files(objects, build_toolchain)
10441034

10451035
# Common Sources

tools/build_travis.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,14 @@
168168
{ "target": "NUMAKER_PFM_M453", "toolchains": "GCC_ARM", "libs": ["dsp", "usb"] },
169169
{ "target": "NUMAKER_PFM_M487", "toolchains": "GCC_ARM", "libs": ["dsp", "usb"] },
170170
)
171+
},
172+
173+
174+
{
175+
"RENESAS":
176+
(
177+
{ "target": "RZ_A1H", "toolchains": "GCC_ARM" },
178+
)
171179
}
172180
]
173181

@@ -326,6 +334,17 @@
326334
}
327335
}
328336
)
337+
},
338+
{
339+
"RENESAS":
340+
(
341+
{
342+
"target": "RZ_A1H",
343+
"toolchains": "GCC_ARM",
344+
"tests": {"" : ["MBED_2", "MBED_10", "MBED_11", "MBED_16"],
345+
}
346+
},
347+
)
329348
}
330349
]
331350

0 commit comments

Comments
 (0)