-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Puya PY32F07x support #3694
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
rhgndf
wants to merge
7
commits into
hathach:master
Choose a base branch
from
rhgndf:py32f0
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Puya PY32F07x support #3694
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0c294ce
add py32f0 support
rhgndf 50072fc
examples now build
rhgndf 310dba8
probably the right mcu target
rhgndf de5470e
cleanup
rhgndf 87fb3e5
add to docs
rhgndf 3e6e8a6
makefile cleanup
rhgndf 61e6e7c
misc fixes
rhgndf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| /* | ||
| * The MIT License (MIT) | ||
| * | ||
| * Copyright (c) 2026, Ha Thach (tinyusb.org) | ||
| * | ||
| * 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 the 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. | ||
| * | ||
| * This file is part of the TinyUSB stack. | ||
| */ | ||
|
|
||
| #ifndef FREERTOS_CONFIG_H_ | ||
| #define FREERTOS_CONFIG_H_ | ||
|
|
||
| #ifndef __IASMARM__ | ||
| #include "py32f0xx.h" | ||
| #endif | ||
|
|
||
| #define configENABLE_MPU 0 | ||
| #define configENABLE_FPU 0 | ||
| #define configENABLE_TRUSTZONE 0 | ||
| #define configMINIMAL_SECURE_STACK_SIZE 1024 | ||
|
|
||
| #define configUSE_PREEMPTION 1 | ||
| #define configUSE_PORT_OPTIMISED_TASK_SELECTION 0 | ||
| #define configCPU_CLOCK_HZ SystemCoreClock | ||
| #define configTICK_RATE_HZ 1000 | ||
| #define configMAX_PRIORITIES 5 | ||
| #define configMINIMAL_STACK_SIZE 128 | ||
| #define configTOTAL_HEAP_SIZE ( configSUPPORT_DYNAMIC_ALLOCATION * 4 * 1024 ) | ||
| #define configMAX_TASK_NAME_LEN 16 | ||
| #define configUSE_16_BIT_TICKS 0 | ||
| #define configIDLE_SHOULD_YIELD 1 | ||
| #define configUSE_MUTEXES 1 | ||
| #define configUSE_RECURSIVE_MUTEXES 1 | ||
| #define configUSE_COUNTING_SEMAPHORES 1 | ||
| #define configQUEUE_REGISTRY_SIZE 4 | ||
| #define configUSE_QUEUE_SETS 0 | ||
| #define configUSE_TIME_SLICING 0 | ||
| #define configUSE_NEWLIB_REENTRANT 0 | ||
| #define configENABLE_BACKWARD_COMPATIBILITY 1 | ||
| #define configSTACK_ALLOCATION_FROM_SEPARATE_HEAP 0 | ||
|
|
||
| #define configSUPPORT_STATIC_ALLOCATION 1 | ||
| #define configSUPPORT_DYNAMIC_ALLOCATION 0 | ||
|
|
||
| #define configUSE_IDLE_HOOK 0 | ||
| #define configUSE_TICK_HOOK 0 | ||
| #define configUSE_MALLOC_FAILED_HOOK 0 | ||
| #define configCHECK_FOR_STACK_OVERFLOW 2 | ||
| #define configCHECK_HANDLER_INSTALLATION 0 | ||
|
|
||
| #define configGENERATE_RUN_TIME_STATS 0 | ||
| #define configRECORD_STACK_HIGH_ADDRESS 1 | ||
| #define configUSE_TRACE_FACILITY 1 | ||
| #define configUSE_STATS_FORMATTING_FUNCTIONS 0 | ||
|
|
||
| #define configUSE_CO_ROUTINES 0 | ||
| #define configMAX_CO_ROUTINE_PRIORITIES 2 | ||
|
|
||
| #define configUSE_TIMERS 1 | ||
| #define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES - 2 ) | ||
| #define configTIMER_QUEUE_LENGTH 32 | ||
| #define configTIMER_TASK_STACK_DEPTH configMINIMAL_STACK_SIZE | ||
|
|
||
| #define INCLUDE_vTaskPrioritySet 0 | ||
| #define INCLUDE_uxTaskPriorityGet 0 | ||
| #define INCLUDE_vTaskDelete 0 | ||
| #define INCLUDE_vTaskSuspend 1 | ||
| #define INCLUDE_xResumeFromISR 0 | ||
| #define INCLUDE_vTaskDelayUntil 1 | ||
| #define INCLUDE_vTaskDelay 1 | ||
| #define INCLUDE_xTaskGetSchedulerState 0 | ||
| #define INCLUDE_xTaskGetCurrentTaskHandle 1 | ||
| #define INCLUDE_uxTaskGetStackHighWaterMark 0 | ||
| #define INCLUDE_xTaskGetIdleTaskHandle 0 | ||
| #define INCLUDE_xTimerGetTimerDaemonTaskHandle 0 | ||
| #define INCLUDE_pcTaskGetTaskName 0 | ||
| #define INCLUDE_eTaskGetState 0 | ||
| #define INCLUDE_xEventGroupSetBitFromISR 0 | ||
| #define INCLUDE_xTimerPendFunctionCall 0 | ||
|
|
||
| #define xPortPendSVHandler PendSV_Handler | ||
| #define xPortSysTickHandler SysTick_Handler | ||
| #define vPortSVCHandler SVC_Handler | ||
|
|
||
| #define configPRIO_BITS __NVIC_PRIO_BITS | ||
| #define configLIBRARY_LOWEST_INTERRUPT_PRIORITY ( ( 1 << configPRIO_BITS ) - 1 ) | ||
| #define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 2 | ||
| #define configKERNEL_INTERRUPT_PRIORITY ( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << ( 8 - configPRIO_BITS ) ) | ||
| #define configMAX_SYSCALL_INTERRUPT_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << ( 8 - configPRIO_BITS ) ) | ||
|
|
||
| #endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| set(PYOCD_TARGET py32f071xb) | ||
| set(PY32_SERIES PY32F071) | ||
| set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/py32f071xb.ld) | ||
|
|
||
| function(update_board TARGET) | ||
| target_compile_definitions(${TARGET} PUBLIC | ||
| PY32F071xB | ||
| CFG_EXAMPLE_MSC_DUAL_READONLY | ||
| CFG_EXAMPLE_VIDEO_READONLY | ||
| ) | ||
| endfunction() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| /* | ||
| * The MIT License (MIT) | ||
| * | ||
| * Copyright (c) 2026, Ha Thach (tinyusb.org) | ||
| * | ||
| * 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 the 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. | ||
| * | ||
| * This file is part of the TinyUSB stack. | ||
| */ | ||
|
|
||
| #ifndef BOARD_H_ | ||
| #define BOARD_H_ | ||
|
|
||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif | ||
|
|
||
| #define LED_PORT GPIOB | ||
| #define LED_PIN GPIO_PIN_2 | ||
| #define LED_STATE_ON 0 | ||
|
|
||
| #define BUTTON_PORT GPIOB | ||
| #define BUTTON_PIN GPIO_PIN_0 | ||
| #define BUTTON_STATE_ACTIVE 0 | ||
|
|
||
| static inline void board_py32f0_clock_init(void) { | ||
| RCC_OscInitTypeDef RCC_OscInitStruct = {0}; | ||
| RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; | ||
|
|
||
| RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE | RCC_OSCILLATORTYPE_HSI | | ||
| RCC_OSCILLATORTYPE_LSI | RCC_OSCILLATORTYPE_LSE; | ||
| RCC_OscInitStruct.HSIState = RCC_HSI_ON; | ||
| RCC_OscInitStruct.HSIDiv = RCC_HSI_DIV1; | ||
| RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_16MHz; | ||
| RCC_OscInitStruct.HSEState = RCC_HSE_ON; | ||
| RCC_OscInitStruct.HSEFreq = RCC_HSE_16_32MHz; | ||
| RCC_OscInitStruct.LSIState = RCC_LSI_OFF; | ||
| RCC_OscInitStruct.LSEState = RCC_LSE_OFF; | ||
| RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; | ||
| RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; | ||
| RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL2; | ||
| if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { | ||
| while (1) {} | ||
| } | ||
|
|
||
| RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1; | ||
| RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; | ||
| RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; | ||
| RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; | ||
| if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK) { | ||
| while (1) {} | ||
| } | ||
| } | ||
|
|
||
| #ifdef __cplusplus | ||
| } | ||
| #endif | ||
|
|
||
| #endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| PY32_SERIES = PY32F071 | ||
|
|
||
| CFLAGS += \ | ||
| -DPY32F071xB \ | ||
| -DCFG_EXAMPLE_MSC_DUAL_READONLY \ | ||
| -DCFG_EXAMPLE_VIDEO_READONLY | ||
|
|
||
| LD_FILE = $(BOARD_PATH)/py32f071xb.ld | ||
| PYOCD_TARGET = py32f071xb | ||
|
|
||
| flash: flash-pyocd |
105 changes: 105 additions & 0 deletions
105
hw/bsp/py32f0/boards/py32f071_dev_board/py32f071_hal_conf.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| /* | ||
| * The MIT License (MIT) | ||
| * | ||
| * Copyright (c) 2026, Ha Thach (tinyusb.org) | ||
| * | ||
| * 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 the 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. | ||
| * | ||
| * This file is part of the TinyUSB stack. | ||
| */ | ||
|
|
||
| #ifndef PY32F071_HAL_CONF_H_ | ||
| #define PY32F071_HAL_CONF_H_ | ||
|
|
||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif | ||
|
|
||
| #define HAL_MODULE_ENABLED | ||
| #define HAL_RCC_MODULE_ENABLED | ||
| #define HAL_FLASH_MODULE_ENABLED | ||
| #define HAL_GPIO_MODULE_ENABLED | ||
| #define HAL_PWR_MODULE_ENABLED | ||
| #define HAL_CORTEX_MODULE_ENABLED | ||
|
|
||
| #if !defined(HSI_VALUE) | ||
| #define HSI_VALUE ((uint32_t) 8000000) | ||
| #endif | ||
|
|
||
| #if !defined(HSE_VALUE) | ||
| #define HSE_VALUE ((uint32_t) 24000000) | ||
| #endif | ||
|
|
||
| #if !defined(HSE_STARTUP_TIMEOUT) | ||
| #define HSE_STARTUP_TIMEOUT ((uint32_t) 200) | ||
| #endif | ||
|
|
||
| #if !defined(LSI_VALUE) | ||
| #define LSI_VALUE ((uint32_t) 32768) | ||
| #endif | ||
|
|
||
| #if !defined(LSE_VALUE) | ||
| #define LSE_VALUE ((uint32_t) 32768) | ||
| #endif | ||
|
|
||
| #if !defined(LSE_STARTUP_TIMEOUT) | ||
| #define LSE_STARTUP_TIMEOUT ((uint32_t) 5000) | ||
| #endif | ||
|
|
||
| #define VDD_VALUE ((uint32_t) 3300) | ||
| #define TICK_INT_PRIORITY ((uint32_t) 3) | ||
| #define USE_RTOS 0 | ||
| #define PREFETCH_ENABLE 0 | ||
|
|
||
| #ifdef HAL_MODULE_ENABLED | ||
| #include "py32f0xx_hal.h" | ||
| #endif | ||
|
|
||
| #ifdef HAL_RCC_MODULE_ENABLED | ||
| #include "py32f071_hal_rcc.h" | ||
| #endif | ||
|
|
||
| #ifdef HAL_FLASH_MODULE_ENABLED | ||
| #include "py32f071_hal_flash.h" | ||
| #endif | ||
|
|
||
| #ifdef HAL_GPIO_MODULE_ENABLED | ||
| #include "py32f071_hal_gpio.h" | ||
| #endif | ||
|
|
||
| #ifdef HAL_PWR_MODULE_ENABLED | ||
| #include "py32f071_hal_pwr.h" | ||
| #endif | ||
|
|
||
| #ifdef HAL_CORTEX_MODULE_ENABLED | ||
| #include "py32f071_hal_cortex.h" | ||
| #endif | ||
|
|
||
| #ifdef USE_FULL_ASSERT | ||
| void assert_failed(uint8_t *file, uint32_t line); | ||
| #define assert_param(expr) ((expr) ? (void) 0U : assert_failed((uint8_t *) __FILE__, __LINE__)) | ||
| #else | ||
| #define assert_param(expr) ((void) 0U) | ||
| #endif | ||
|
|
||
| #ifdef __cplusplus | ||
| } | ||
| #endif | ||
|
|
||
| #endif |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A bit more specific than "1-dir ep"? Two dirs are possible with some scheduling, but probably very complex