{"id":20841317,"url":"https://github.com/zephyrproject-rtos/hal_gigadevice","last_synced_at":"2025-05-08T22:08:48.268Z","repository":{"id":37788024,"uuid":"413845037","full_name":"zephyrproject-rtos/hal_gigadevice","owner":"zephyrproject-rtos","description":"HAL for GigaDevice devices","archived":false,"fork":false,"pushed_at":"2023-10-05T15:21:22.000Z","size":1523,"stargazers_count":9,"open_issues_count":2,"forks_count":15,"subscribers_count":10,"default_branch":"main","last_synced_at":"2025-05-08T22:08:43.040Z","etag":null,"topics":["hal","module"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zephyrproject-rtos.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-10-05T14:10:02.000Z","updated_at":"2025-05-08T05:34:58.000Z","dependencies_parsed_at":"2023-02-09T15:46:34.509Z","dependency_job_id":null,"html_url":"https://github.com/zephyrproject-rtos/hal_gigadevice","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zephyrproject-rtos%2Fhal_gigadevice","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zephyrproject-rtos%2Fhal_gigadevice/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zephyrproject-rtos%2Fhal_gigadevice/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zephyrproject-rtos%2Fhal_gigadevice/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zephyrproject-rtos","download_url":"https://codeload.github.com/zephyrproject-rtos/hal_gigadevice/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253154975,"owners_count":21862622,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hal","module"],"created_at":"2024-11-18T01:19:38.203Z","updated_at":"2025-05-08T22:08:48.230Z","avatar_url":"https://github.com/zephyrproject-rtos.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Introduction\n\nThe **hal_gigadevice** is a set of both standard firmware library and ARM CMSIS\nconfigurations for GigaDevice MCUs. The HAL is organized following the\ndirectory structure detailed below.\n\n## Directory Structure\n\nThe directory is composed by three parts:\n\n - SoC specific libraries.\n - ZephyrRTOS module directory (`zephyr`).\n - This README file.\n\n### ARM\n\nEach ARM firmware library is organized in the following structure:\n\n```\n.\n└── gd32xxx\n    ├── cmsis\n    │   └── gd\n    │       └── gd32xxx\n    ├── standard_peripheral\n    │   ├── include\n    │   └── source\n    └── support (optional)\n        └── GigaDevice.GD32xxx_DFP.1.0.0.pack (Only for packs not in [Keil MDK5 Software Packs](https://www.keil.com/dd2/pack/))\n```\n\n### RISC-V\n\nThe RISC-V structure is not defined yet. The riscv sub-directory will change\nbased on how [NMSIS library](https://github.com/Nuclei-Software/NMSIS/) will\nbe integrated in Zephyr. At present date, the structure only reflects current\nmanufacturer version.\n\n```\n└── gd32bf103\n    ├── riscv\n    │   ├── drivers\n    │   ├── include\n    │   ├── source\n    │   └── stubs\n    └── standard_peripheral\n        ├── include\n        └── source\n```\n\n Any contribution should follow the `How to submit code` using as premisses the\n [Zephyr Contribution Guidelines](https://docs.zephyrproject.org/latest/contribute/index.html).\n\n# How to submit code\n\n - When submiting an updated firmware library version, it is important to make\n   sure that the last firmware version will be merged. The library version is\n   used to be checked at [GigaDevice MCU Site](http://www.gd32mcu.com/en/download/).\n - This repository is managed mainly on Linux. This means that changes should\n   be submited using Linux LF format. Usually running a similar command to\n   `find * type f -print0 | xargs -0 dos2unix -k` should be enough.\n - Make sure directory structure is respected.\n - Directory names should be converted to lowercase.\n - Exceptions should be discussed at review phase.\n\n## The gd32 standard peripheral API\n\nThe gd32 standard peripheral API define all information to access GigaDevice\nperipherals. The firmware library does not have namespaces and prefixes which\neasily results in name collision with ZephyrRTOS core and libraries. To avoid\nthat situation, macros, enum values and function names should follow two\ngeneral rules:\n\n - Public API funtions must be prefixed with `gd32_`.\n - Public defines and enum values must be uppercase and prefixed with `GD32_`.\n\nThe cmsis and riscv contents are not part of standard peripheral library and\nchanges are treated as exceptions. This means that `\u003cfirmware_library\u003e.h\u003e` and\n`system_\u003cfirmware_library\u003e.h\u003e` files should reside on their own respective\nplaces instead in standard peripheral library directory.\n\n### Grace Period\n\nRework gd32 standard peripheral API is a huge step. To allow developers move\nforward a grace period was created. The grace period is available until\n`gd32_api_convert` script be available. When the script be available any new\nfirmware library must be converted. The main objective of the script is to\nautomate conversion process of all gd32 standard peripheral API.\n\nBesides there is a grace period developers are obligated to solve any existent\nconflict. The conflict should follow gd32 standard peripheral API rules.\n\n### Current known conflict list\n\nThe conflicts at gd32 standard peripheral API are listed by the afected file(s).\nIn general, a name is the conflict itself and that whould be reworked following\nthe gd32 standard peripheral API rules.\n\n - `\u003cfirmware_library\u003e_timer.h/c`: `timer_init()` should be prefixed with\n   `gd32_` and become `gd32_timer_init()`.\n - `\u003cfirmware_library\u003e_can.h/c`: all `CAN_` macros that collide with any\n   macro defined at `/include/drivers/can.h` should be prefixed with `GD32_`\n   and become `GD32_CAN_*`.\n\n## Exceptions\n\nThe exception list define macros and enum values that may have a different\nconflict resolution. See below list with the proposed solution:\n\n - The `BIT` macro is already define in Zephyr. Fix using `#ifndef`:\n```review\n+#ifndef BIT\n#define BIT(x)                       ((uint32_t)((uint32_t)0x01U\u003c\u003c(x)))\n+#endif\n```\n- i2c-gd32 driver needs to know the clock frequency boundary. Fix it with\n  two step work. First move I2CCLK_MAX and I2CCLK_MIN marco from i2c source\n  file to header file. Then split the I2CCLK_MIN for each supported transfer\n  mode.\n\n- gd32l23x\n\n  - `SystemInit` function in `system_gd32l23x.c` contain an invalid usage of\n    `nvic_vector_table_set` function, just remove it.\n\n  - `gd32l23x_libopt.h` file not exist, add it manually.\n\n  - i2c have different implement than current gd32 i2c driver. no need to patch\n    upper i2c speed requirement.\n\n- gd32a50x\n\n  - `SystemCoreClockUpdate` function contain an `pllmf` calculate error.  \n    Fix by change `0xFU` to `RCU_CFG0_PLLMF`:\n    ``` diff\n      /* PLL multiplication factor */\n      pllmf = GET_BITS(RCU_CFG0, 18, 21);\n      pllmf += ((RCU_CFG0 \u0026 RCU_CFG0_PLLMF_4) ? 15U : 0U);\n    - pllmf += ((0xFU == (RCU_CFG0 \u0026 RCU_CFG0_PLLMF)) ? 1U : 2U);\n    + pllmf += ((RCU_CFG0_PLLMF == (RCU_CFG0 \u0026 RCU_CFG0_PLLMF)) ? 1U : 2U);\n    ```\n  - For debug this board, `pyocd` need a pack file from Gigadevice,\n    But Gigadevice don't upload pack file to [keil packs repo](https://www.keil.com/dd2/pack/).\n    Fix: Storage pack as `gd32a50x/support/GigaDevice.GD32A50x_DFP.1.0.0.pack`\n    (Download from https://gd32mcu.com/cn/download/7?kw=GD32A5 -\u003e GD32A50x AddOn)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzephyrproject-rtos%2Fhal_gigadevice","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzephyrproject-rtos%2Fhal_gigadevice","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzephyrproject-rtos%2Fhal_gigadevice/lists"}