From b34995a54920e3a586b2a0a66c819db7c5ecc1df Mon Sep 17 00:00:00 2001 From: Luke Wren Date: Tue, 9 Feb 2021 14:47:16 +0000 Subject: [PATCH] Add missing extern "C" to header files (closes #104) --- .../hardware_base/include/hardware/address_mapped.h | 8 ++++++++ src/rp2_common/hardware_claim/include/hardware/claim.h | 8 ++++++++ .../hardware_divider/include/hardware/divider.h | 8 ++++++++ src/rp2_common/hardware_flash/include/hardware/flash.h | 7 +++++++ src/rp2_common/hardware_resets/include/hardware/resets.h | 8 ++++++++ src/rp2_common/hardware_rtc/include/hardware/rtc.h | 7 +++++++ .../hardware_watchdog/include/hardware/watchdog.h | 8 ++++++++ src/rp2_common/pico_bootrom/include/pico/bootrom.h | 7 +++++++ .../include/pico/stdio_semihosting.h | 8 ++++++++ src/rp2_common/pico_stdio_uart/include/pico/stdio_uart.h | 8 ++++++++ src/rp2_common/pico_stdio_usb/include/pico/stdio_usb.h | 8 ++++++++ 11 files changed, 85 insertions(+) diff --git a/src/rp2_common/hardware_base/include/hardware/address_mapped.h b/src/rp2_common/hardware_base/include/hardware/address_mapped.h index 6645fbd..1c1b29c 100644 --- a/src/rp2_common/hardware_base/include/hardware/address_mapped.h +++ b/src/rp2_common/hardware_base/include/hardware/address_mapped.h @@ -48,6 +48,10 @@ * leaving the other bits unchanged. */ +#ifdef __cplusplus +extern "C" { +#endif + #define check_hw_layout(type, member, offset) static_assert(offsetof(type, member) == (offset), "hw offset mismatch") #define check_hw_size(type, size) static_assert(sizeof(type) == (size), "hw size mismatch") @@ -120,4 +124,8 @@ inline static void hw_write_masked(io_rw_32 *addr, uint32_t values, uint32_t wri hw_xor_bits(addr, (*addr ^ values) & write_mask); } +#ifdef __cplusplus +} +#endif + #endif diff --git a/src/rp2_common/hardware_claim/include/hardware/claim.h b/src/rp2_common/hardware_claim/include/hardware/claim.h index eadae50..681962a 100644 --- a/src/rp2_common/hardware_claim/include/hardware/claim.h +++ b/src/rp2_common/hardware_claim/include/hardware/claim.h @@ -32,6 +32,10 @@ * 3. Finding unused resources */ +#ifdef __cplusplus +extern "C" { +#endif + /*! \brief Atomically claim a resource, panicking if it is already in use * \ingroup hardware_claim * @@ -98,4 +102,8 @@ uint32_t hw_claim_lock(void); */ void hw_claim_unlock(uint32_t token); +#ifdef __cplusplus +} +#endif + #endif diff --git a/src/rp2_common/hardware_divider/include/hardware/divider.h b/src/rp2_common/hardware_divider/include/hardware/divider.h index 4bcadab..5693e07 100644 --- a/src/rp2_common/hardware_divider/include/hardware/divider.h +++ b/src/rp2_common/hardware_divider/include/hardware/divider.h @@ -36,6 +36,10 @@ * \include hello_divider.c */ +#ifdef __cplusplus +extern "C" { +#endif + typedef uint64_t divmod_result_t; /*! \brief Start a signed asynchronous divide @@ -392,4 +396,8 @@ void hw_divider_save_state(hw_divider_state_t *dest); void hw_divider_restore_state(hw_divider_state_t *src); +#ifdef __cplusplus +} +#endif + #endif // _HARDWARE_DIVIDER_H diff --git a/src/rp2_common/hardware_flash/include/hardware/flash.h b/src/rp2_common/hardware_flash/include/hardware/flash.h index 40e2949..3fa21c2 100644 --- a/src/rp2_common/hardware_flash/include/hardware/flash.h +++ b/src/rp2_common/hardware_flash/include/hardware/flash.h @@ -44,6 +44,9 @@ * \include flash_program.c */ +#ifdef __cplusplus +extern "C" { +#endif /*! \brief Erase areas of flash * \ingroup hardware_flash @@ -75,4 +78,8 @@ void flash_range_program(uint32_t flash_offs, const uint8_t *data, size_t count) */ void flash_get_unique_id(uint8_t *id_out); +#ifdef __cplusplus +} +#endif + #endif diff --git a/src/rp2_common/hardware_resets/include/hardware/resets.h b/src/rp2_common/hardware_resets/include/hardware/resets.h index fab604b..a3f7014 100644 --- a/src/rp2_common/hardware_resets/include/hardware/resets.h +++ b/src/rp2_common/hardware_resets/include/hardware/resets.h @@ -56,6 +56,10 @@ * \include hello_reset.c */ +#ifdef __cplusplus +extern "C" { +#endif + /// \tag::reset_funcs[] /*! \brief Reset the specified HW blocks @@ -88,4 +92,8 @@ static inline void unreset_block_wait(uint32_t bits) { } /// \end::reset_funcs[] +#ifdef __cplusplus +} +#endif + #endif diff --git a/src/rp2_common/hardware_rtc/include/hardware/rtc.h b/src/rp2_common/hardware_rtc/include/hardware/rtc.h index 83d5bdf..65028db 100644 --- a/src/rp2_common/hardware_rtc/include/hardware/rtc.h +++ b/src/rp2_common/hardware_rtc/include/hardware/rtc.h @@ -28,6 +28,9 @@ * \include hello_rtc.c */ +#ifdef __cplusplus +extern "C" { +#endif typedef void (*rtc_callback_t)(void); @@ -71,4 +74,8 @@ void rtc_set_alarm(datetime_t *t, rtc_callback_t user_callback); */ void rtc_disable_alarm(void); +#ifdef __cplusplus +} +#endif + #endif diff --git a/src/rp2_common/hardware_watchdog/include/hardware/watchdog.h b/src/rp2_common/hardware_watchdog/include/hardware/watchdog.h index ae5ccdc..c739d53 100644 --- a/src/rp2_common/hardware_watchdog/include/hardware/watchdog.h +++ b/src/rp2_common/hardware_watchdog/include/hardware/watchdog.h @@ -25,6 +25,10 @@ * \include hello_watchdog.c */ +#ifdef __cplusplus +extern "C" { +#endif + /*! \brief Define actions to perform at watchdog timeout * \ingroup hardware_watchdog * @@ -84,4 +88,8 @@ bool watchdog_caused_reboot(void); */ uint32_t watchdog_get_count(void); +#ifdef __cplusplus +} +#endif + #endif diff --git a/src/rp2_common/pico_bootrom/include/pico/bootrom.h b/src/rp2_common/pico_bootrom/include/pico/bootrom.h index 1aa1297..1300ed9 100644 --- a/src/rp2_common/pico_bootrom/include/pico/bootrom.h +++ b/src/rp2_common/pico_bootrom/include/pico/bootrom.h @@ -14,6 +14,9 @@ * Access to functions and data in the RP2040 bootrom */ +#ifdef __cplusplus +extern "C" { +#endif /*! \brief Return a bootrom lookup code based on two ASCII characters * \ingroup pico_bootrom @@ -82,4 +85,8 @@ static inline void __attribute__((noreturn)) reset_usb_boot(uint32_t usb_activit func(usb_activity_gpio_pin_mask, disable_interface_mask); } +#ifdef __cplusplus +} +#endif + #endif diff --git a/src/rp2_common/pico_stdio_semihosting/include/pico/stdio_semihosting.h b/src/rp2_common/pico_stdio_semihosting/include/pico/stdio_semihosting.h index 2219385..3304368 100644 --- a/src/rp2_common/pico_stdio_semihosting/include/pico/stdio_semihosting.h +++ b/src/rp2_common/pico_stdio_semihosting/include/pico/stdio_semihosting.h @@ -22,6 +22,10 @@ #define PICO_STDIO_SEMIHOSTING_DEFAULT_CRLF PICO_STDIO_DEFAULT_CRLF #endif +#ifdef __cplusplus +extern "C" { +#endif + extern stdio_driver_t stdio_semihosting; /*! \brief Explicitly initialize stdout over semihosting and add it to the current set of stdout targets @@ -31,4 +35,8 @@ extern stdio_driver_t stdio_semihosting; */ void stdio_semihosting_init(void); +#ifdef __cplusplus +} +#endif + #endif diff --git a/src/rp2_common/pico_stdio_uart/include/pico/stdio_uart.h b/src/rp2_common/pico_stdio_uart/include/pico/stdio_uart.h index 6f48616..5afe910 100644 --- a/src/rp2_common/pico_stdio_uart/include/pico/stdio_uart.h +++ b/src/rp2_common/pico_stdio_uart/include/pico/stdio_uart.h @@ -23,6 +23,10 @@ #define PICO_STDIO_UART_DEFAULT_CRLF PICO_STDIO_DEFAULT_CRLF #endif +#ifdef __cplusplus +extern "C" { +#endif + extern stdio_driver_t stdio_uart; /*! \brief Explicitly initialize stdin/stdout over UART and add it to the current set of stdin/stdout drivers @@ -59,4 +63,8 @@ void stdin_uart_init(void); */ void stdio_uart_init_full(uart_inst_t *uart, uint baud_rate, int tx_pin, int rx_pin); +#ifdef __cplusplus +} +#endif + #endif diff --git a/src/rp2_common/pico_stdio_usb/include/pico/stdio_usb.h b/src/rp2_common/pico_stdio_usb/include/pico/stdio_usb.h index 6b5ef97..f8b645f 100644 --- a/src/rp2_common/pico_stdio_usb/include/pico/stdio_usb.h +++ b/src/rp2_common/pico_stdio_usb/include/pico/stdio_usb.h @@ -42,6 +42,10 @@ #define PICO_STDIO_USB_LOW_PRIORITY_IRQ 31 #endif +#ifdef __cplusplus +extern "C" { +#endif + extern stdio_driver_t stdio_usb; /*! \brief Explicitly initialize USB stdio and add it to the current set of stdin drivers @@ -49,4 +53,8 @@ extern stdio_driver_t stdio_usb; */ bool stdio_usb_init(void); +#ifdef __cplusplus +} +#endif + #endif