Skip to content

Commit

Permalink
Sync with local development
Browse files Browse the repository at this point in the history
  • Loading branch information
vanvught committed Feb 13, 2024
1 parent 38c2520 commit 1454f56
Show file tree
Hide file tree
Showing 37 changed files with 436 additions and 99 deletions.
3 changes: 3 additions & 0 deletions firmware-template-gd32/startup_gd32f450.S
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ Zerobss:
bl stack_debug_init
#endif
bl SystemInit
#if !defined (ENABLE_TFTP_SERVER)
bl __libc_init_array
#endif
bl main
bx lr
.size Reset_Handler, .-Reset_Handler
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
constexpr uint32_t DEVICE_SOFTWARE_VERSION_ID=1704725179;
constexpr uint32_t DEVICE_SOFTWARE_VERSION_ID=1707838977;
2 changes: 1 addition & 1 deletion gd32_emac_artnet_pixel_multi/include/sofware_version_id.h
Original file line number Diff line number Diff line change
@@ -1 +1 @@
constexpr uint32_t DEVICE_SOFTWARE_VERSION_ID=1706294736;
constexpr uint32_t DEVICE_SOFTWARE_VERSION_ID=1707839019;
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuildCommandParser" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser" keep-relative-paths="false" name="CDT GCC Build Output Parser" parameter="([^/\\\\]*)((g?cc)|([gc]\+\+)|(clang))" prefer-non-shared="true"/>
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="-959411350189512322" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="-959356223340840322" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
Expand Down
2 changes: 1 addition & 1 deletion gd32_emac_ddp_pixel_dmx_multi/include/sofware_version_id.h
Original file line number Diff line number Diff line change
@@ -1 +1 @@
constexpr uint32_t DEVICE_SOFTWARE_VERSION_ID=1702811913;
constexpr uint32_t DEVICE_SOFTWARE_VERSION_ID=1707839032;
2 changes: 1 addition & 1 deletion gd32_emac_ddp_pixel_multi/.settings/language.settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuildCommandParser" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser" keep-relative-paths="false" name="CDT GCC Build Output Parser" parameter="([^/\\\\]*)((g?cc)|([gc]\+\+)|(clang))" prefer-non-shared="true"/>
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="-959411350189512322" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="-959356223340840322" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
Expand Down
2 changes: 1 addition & 1 deletion gd32_emac_ddp_pixel_multi/include/sofware_version_id.h
Original file line number Diff line number Diff line change
@@ -1 +1 @@
constexpr uint32_t DEVICE_SOFTWARE_VERSION_ID=1702811915;
constexpr uint32_t DEVICE_SOFTWARE_VERSION_ID=1707839045;
3 changes: 1 addition & 2 deletions gd32_emac_e131_pixel_dmx_multi/include/sofware_version_id.h
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
// Generated do 14 sep 2023 12:39:45 CEST
constexpr uint32_t DEVICE_SOFTWARE_VERSION_ID=1694687985;
constexpr uint32_t DEVICE_SOFTWARE_VERSION_ID=1707839069;
3 changes: 1 addition & 2 deletions gd32_emac_e131_pixel_multi/include/sofware_version_id.h
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
// Generated do 14 sep 2023 12:39:46 CEST
constexpr uint32_t DEVICE_SOFTWARE_VERSION_ID=1694687986;
constexpr uint32_t DEVICE_SOFTWARE_VERSION_ID=1707839082;
2 changes: 1 addition & 1 deletion lib-e131/src/controller/e131controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @file e131controller.cpp
*
*/
/* Copyright (C) 2020-2023 by Arjan van Vught mailto:[email protected]
/* Copyright (C) 2020-2024 by Arjan van Vught mailto:[email protected]
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
29 changes: 16 additions & 13 deletions lib-hal/include/gd32/hardware.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @file hardware.h
*
*/
/* Copyright (C) 2021-2023 by Arjan van Vught mailto:[email protected]
/* Copyright (C) 2021-2024 by Arjan van Vught mailto:[email protected]
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -67,7 +67,9 @@ class Hardware {
return 0; // FIXME GetReleaseId
}

void GetUuid(uuid_t out);
void GetUuid(uuid_t out) {
memcpy(out, m_uuid, sizeof(uuid_t));
}

uint32_t Millis() {
extern volatile uint32_t s_nSysTickMillis;
Expand All @@ -83,12 +85,12 @@ class Hardware {
}

bool SetTime(__attribute__((unused)) const struct tm *pTime) {
#if !defined(DISABLE_RTC)
#if !defined(DISABLE_RTC)
m_HwClock.Set(pTime);
return true;
#else
#else
return false;
#endif
#endif
}

void GetTime(struct tm *pTime) {
Expand All @@ -108,22 +110,22 @@ class Hardware {
}
#endif

const char *GetBoardName(uint8_t &nLength) {
const char *GetBoardName(uint8_t& nLength) {
nLength = sizeof(GD32_BOARD_NAME) - 1U;
return GD32_BOARD_NAME;
}

const char *GetSysName(uint8_t &nLength) {
const char* GetSysName(uint8_t& nLength) {
nLength = 8;
return "Embedded";
}

const char *GetSocName(uint8_t &nLength) {
nLength = 5;
return "GD32F";
const char* GetSocName(uint8_t& nLength) {
nLength = 4;
return "GD32";
}

const char *GetCpuName(uint8_t &nLength) {
const char *GetCpuName(uint8_t& nLength) {
nLength = sizeof(GD32_MCU_NAME) - 1U;
return GD32_MCU_NAME;
}
Expand All @@ -137,8 +139,8 @@ class Hardware {
}

void WatchdogInit() {
const auto status = fwdgt_config(0xFFFF, FWDGT_PSC_DIV16);
m_bIsWatchdog = (SUCCESS == status);
m_bIsWatchdog = (SUCCESS == fwdgt_config(0xFFFF, FWDGT_PSC_DIV16));

if (m_bIsWatchdog) {
fwdgt_enable();
}
Expand Down Expand Up @@ -262,6 +264,7 @@ class Hardware {
#if !defined(DISABLE_RTC)
HwClock m_HwClock;
#endif
uuid_t m_uuid;
bool m_bIsWatchdog { false };
hardware::ledblink::Mode m_Mode { hardware::ledblink::Mode::UNKNOWN };
bool m_doLock { false };
Expand Down
12 changes: 8 additions & 4 deletions lib-hal/include/hardware.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @file hardware.h
*
*/
/* Copyright (C) 2020-2023 by Arjan van Vught mailto:[email protected]
/* Copyright (C) 2020-2024 by Arjan van Vught mailto:[email protected]
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand All @@ -27,6 +27,8 @@
#define HARDWARE_H_

#include <cstdint>
#include <cstring>
#include <uuid/uuid.h>

namespace hardware {
enum class BootDevice {
Expand All @@ -42,8 +44,6 @@ namespace ledblink {
enum class Mode {
OFF_OFF, OFF_ON, NORMAL, DATA, FAST, REBOOT, UNKNOWN
};

void display(const uint32_t nState);
} // namespace ledblink
} // namespace hardware

Expand All @@ -56,7 +56,11 @@ void display(const uint32_t nState);
# include "rpi/hardware.h"
# endif
#else
# include "linux/hardware.h"
# if defined (CONFIG_HAL_USE_MINIMUM)
# include "linux/minimum/hardware.h"
# else
# include "linux/hardware.h"
# endif
#endif

#endif /* HARDWARE_H_ */
11 changes: 5 additions & 6 deletions lib-hal/include/utc.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @file utc.h
*
*/
/* Copyright (C) 2019-2020 by Arjan van Vught mailto:[email protected]
/* Copyright (C) 2019-2024 by Arjan van Vught mailto:[email protected]
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand All @@ -26,14 +26,13 @@

#include <cstdint>

enum TUtcOffset {
namespace hal {
enum class UtcOffset {
UTC_OFFSET_MIN = -12,
UTC_OFFSET_MAX = 14
};

class Utc {
public:
static int32_t Validate(float fOffset);
};
int32_t utc_validate(const float fOffset);
} // namespace hal

#endif /* UTC_H_ */
37 changes: 6 additions & 31 deletions lib-hal/src/gd32/hardware.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,14 @@ void usb_init();

extern "C" {
void console_init(void);
void __libc_init_array(void);
void systick_config(void);
}

void udelay_init();
void gd32_adc_init();
namespace hal {
void uuid_init(uuid_t out);
} // namespace hardware

Hardware *Hardware::s_pThis;

Expand All @@ -72,11 +74,9 @@ Hardware::Hardware() {
s_pThis = this;

console_init();
#if !defined (ENABLE_TFTP_SERVER)
__libc_init_array();
#endif
systick_config();
udelay_init();
hal::uuid_init(m_uuid);
gd32_adc_init();
gd32_i2c_begin();

Expand All @@ -88,7 +88,8 @@ Hardware::Hardware() {
timer_init(TIMER5, &timer_initpara);
timer_enable(TIMER5);

#if defined (GD32F4XX)
#if defined (GD32H7XX)
#elif defined (GD32F4XX)
rcu_timer_clock_prescaler_config(RCU_TIMER_PSC_MUL4);
#else
#endif
Expand Down Expand Up @@ -212,32 +213,6 @@ Hardware::Hardware() {
DEBUG_EXIT
}

typedef union pcast32 {
uuid_t uuid;
uint32_t u32[4];
} _pcast32;

void Hardware::GetUuid(uuid_t out) {
_pcast32 cast;

#if defined (GD32H7XX)
cast.u32[0] = *(volatile uint32_t*) (0x1FF0F7E8);
cast.u32[1] = *(volatile uint32_t*) (0x1FF0F7EC);
cast.u32[2] = *(volatile uint32_t*) (0x1FF0F7F0);
#elif defined (GD32F4XX)
cast.u32[0] = *(volatile uint32_t*) (0x1FFF7A10);
cast.u32[1] = *(volatile uint32_t*) (0x1FFF7A14);
cast.u32[2] = *(volatile uint32_t*) (0x1FFF7A18);
#else
cast.u32[0] = *(volatile uint32_t*) (0x1FFFF7E8);
cast.u32[1] = *(volatile uint32_t*) (0x1FFFF7EC);
cast.u32[2] = *(volatile uint32_t*) (0x1FFFF7F0);
#endif
cast.u32[3] = cast.u32[0] + cast.u32[1] + cast.u32[2];

memcpy(out, cast.uuid, sizeof(uuid_t));
}

#include <cstdio>

bool Hardware::Reboot() {
Expand Down
58 changes: 58 additions & 0 deletions lib-hal/src/gd32/uuid.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/**
* @file uuid.cpp
*
*/
/* Copyright (C) 2024 by Arjan van Vught mailto:[email protected]
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of thnDmxDataDirecte Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

#include <cstdint>
#include <cstring>
#include <uuid/uuid.h>

#include "gd32.h"

namespace hal {
typedef union pcast32 {
uuid_t uuid;
uint32_t u32[4];
} _pcast32;

void uuid_init(uuid_t out) {
_pcast32 cast;

#if defined (GD32H7XX)
cast.u32[0] = REG32(0x1FF0F7E8);
cast.u32[1] = REG32(0x1FF0F7EC);
cast.u32[2] = REG32(0x1FF0F7F0);
#elif defined (GD32F4XX)
cast.u32[0] = REG32(0x1FFF7A10);
cast.u32[1] = REG32(0x1FFF7A14);
cast.u32[2] = REG32(0x1FFF7A18);
#else
cast.u32[0] = REG32(0x1FFFF7E8);
cast.u32[1] = REG32(0x1FFFF7EC);
cast.u32[2] = REG32(0x1FFFF7F0);
#endif
cast.u32[3] = cast.u32[0] + cast.u32[1] + cast.u32[2];

memcpy(out, cast.uuid, sizeof(uuid_t));
}
} // namespace hal
4 changes: 3 additions & 1 deletion lib-hal/src/hardware.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @file hardware.cpp
*
*/
/* Copyright (C) 2023 by Arjan van Vught mailto:[email protected]
/* Copyright (C) 2023-2024 by Arjan van Vught mailto:[email protected]
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -38,6 +38,7 @@ enum class FreqMode {
OFF_OFF = 0, NORMAL = 1, DATA = 3, FAST = 5, REBOOT = 8, OFF_ON = 255
};

#if !defined (CONFIG_HAL_USE_MINIMUM)
void Hardware::SetModeWithLock(hardware::ledblink::Mode mode, bool doLock) {
m_doLock = false;
SetMode(mode);
Expand Down Expand Up @@ -79,3 +80,4 @@ void Hardware::SetMode(hardware::ledblink::Mode mode) {

DEBUG_PRINTF("Mode=%d", static_cast<int>(m_Mode));
}
#endif
6 changes: 4 additions & 2 deletions lib-hal/src/utc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @file utc.cpp
*
*/
/* Copyright (C) 2019-2021 by Arjan van Vught mailto:[email protected]
/* Copyright (C) 2019-2024 by Arjan van Vught mailto:[email protected]
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand All @@ -27,9 +27,10 @@

// https://en.wikipedia.org/wiki/List_of_UTC_time_offsets

namespace hal {
static const float s_ValidOffets[] = { -9.5, -3.5, 3.5, 4.5, 5.5, 5.75, 6.5, 8.75, 9.5, 10.5, 12.75 };

int32_t Utc::Validate(float fOffset) {
int32_t utc_validate(const float fOffset) {
auto nInt = static_cast<int32_t>(fOffset);

if ((nInt >= -12) && (nInt <= 14)) {
Expand All @@ -46,3 +47,4 @@ int32_t Utc::Validate(float fOffset) {

return 0;
}
} // namespace hal
4 changes: 2 additions & 2 deletions lib-network/Rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ ifneq ($(MAKE_FLAGS),)
endif
ifndef COND
EXTRA_SRCDIR+=src/apps/mdns src/apps/ntp src/apps/tftp
EXTRA_SRCDIR+=src/emac src/params src/net
EXTRA_SRCDIR+=src/emac/phy
EXTRA_SRCDIR+=src/emac src/net src/emac/phy
EXTRA_SRCDIR+=src/params
ifeq ($(findstring ENABLE_PHY_SWITCH,$(MAKE_FLAGS)), ENABLE_PHY_SWITCH)
EXTRA_SRCDIR+=src/emac/dsa
endif
Expand Down
Loading

0 comments on commit 1454f56

Please sign in to comment.