Where is stm module source?
grep -r stm.GPIO
docs/pyboard/tutorial/assembler.rst: movwt(r0, stm.GPIOA)
does not find any that look like a file full of constants...
./stmhal/build-G30TH/genhdr/modstm_const.h is like it.
says: // Automatically generated from cmsis/stm32f401xe.h by make-stmconst.py
and here are the GPIO registers:
{ MP_OBJ_NEW_QSTR(MP_QSTR_GPIO_IDR), MP_OBJ_NEW_SMALL_INT(0x10) }, // 32-bits, GPIO port input data register
{ MP_OBJ_NEW_QSTR(MP_QSTR_GPIO_ODR), MP_OBJ_NEW_SMALL_INT(0x14) }, // 32-bits, GPIO port output data register
{ MP_OBJ_NEW_QSTR(MP_QSTR_GPIO_BSRRL), MP_OBJ_NEW_SMALL_INT(0x18) }, // 16-bits, GPIO port bit set/reset low register
{ MP_OBJ_NEW_QSTR(MP_QSTR_GPIO_BSRRH), MP_OBJ_NEW_SMALL_INT(0x1a) }, // 16-bits, GPIO port bit set/reset high register
{ MP_OBJ_NEW_QSTR(MP_QSTR_GPIO_LCKR), MP_OBJ_NEW_SMALL_INT(0x1c) }, // 32-bits, GPIO port configuration lock register
{ MP_OBJ_NEW_QSTR(MP_QSTR_GPIO_AFR0), MP_OBJ_NEW_SMALL_INT(0x20) }, // 32-bits, GPIO alternate function registers
{ MP_OBJ_NEW_QSTR(MP_QSTR_GPIO_AFR1), MP_OBJ_NEW_SMALL_INT(0x24) }, // 32-bits, GPIO alternate function registers
cmsis/stm32f401xe.h seems to come from ST, so that is my question answered with a lot of cross references.
[STM32F401CE] [pyb] import stm -- Where is stm module source? [found]
[STM32F401CE] [pyb] import stm -- Where is stm module source? [found]
John Griessen blog.kitmatic.com
Re: [STM32F401CE] [pyb] import stm -- Where is stm module source? [found]
The stm module originates from modstm.c:
https://github.com/micropython/micropyt ... 2/modstm.c
and you'll see that it has the following line: This is a generated file. The rules to make it can be found in the Makefile:
https://github.com/micropython/micropyt ... #L468-L470
It basically scans the MCU file from the CMSIS library (for the f405 this would be lib/stm32lib/CMSIS/STM32F4xx/Include/stm32f405xx.h
From that it extracts a bunch of constants.
https://github.com/micropython/micropyt ... 2/modstm.c
and you'll see that it has the following line:
Code: Select all
#include "genhdr/modstm_const.h"
https://github.com/micropython/micropyt ... #L468-L470
It basically scans the MCU file from the CMSIS library (for the f405 this would be lib/stm32lib/CMSIS/STM32F4xx/Include/stm32f405xx.h
From that it extracts a bunch of constants.
-
- Posts: 463
- Joined: Wed Apr 08, 2015 5:19 am
Re: [STM32F401CE] [pyb] import stm -- Where is stm module source? [found]
And to make the constants from that module actually usable to access the MCUs memory, it uses 'extmod/machine_mem.c/.h'
Re: [STM32F401CE] [pyb] import stm -- Where is stm module source? [found]
I'm still mystified about why the G30_TH board definition has
//#define MICROPY_HW_USB_VBUS_DETECT_PIN (pin_A9)
//#define MICROPY_HW_USB_OTG_ID_PIN (pin_A10)
They are commented out.
Since above, I found a ref to it from 2015 github where you all noticed it was always A9 pin on STM32F4, so put it off till needed change.
What is status of newer hardware definition API?
Is that anything to use on a STM32F401 new platform with a QFN chip that has need to delete some pins compared to G30TH?
//#define MICROPY_HW_USB_VBUS_DETECT_PIN (pin_A9)
//#define MICROPY_HW_USB_OTG_ID_PIN (pin_A10)
They are commented out.
Since above, I found a ref to it from 2015 github where you all noticed it was always A9 pin on STM32F4, so put it off till needed change.
What is status of newer hardware definition API?
Is that anything to use on a STM32F401 new platform with a QFN chip that has need to delete some pins compared to G30TH?
John Griessen blog.kitmatic.com
Re: [STM32F401CE] [pyb] import stm -- Where is stm module source? [found]
If you look at the schematics for the G30 TH board: http://old.ghielectronics.com/downloads ... TH_SCH.pdf
Pin A9 does NOT connect to VBUS, so it can't be used to detect if VBUS is present. Similarly pin PA10 is NOT connected to the USB connector's ID pin, so it can't be used to negotiate the ID for OTG purposes.
If you look at the pyboard schematics you'll see that PA9 is connected to VBUS and PA10 is connected to the ID pin. So these defines should be set match your actual hardware setup. It has nothing to do with the processor, but rather how the G30TH board was wired up.
In the case of VBUS detect, PA9 is the only pin that can be used, and similarly PA10 is the only pin that can be used for the ID pin.
Pin A9 does NOT connect to VBUS, so it can't be used to detect if VBUS is present. Similarly pin PA10 is NOT connected to the USB connector's ID pin, so it can't be used to negotiate the ID for OTG purposes.
If you look at the pyboard schematics you'll see that PA9 is connected to VBUS and PA10 is connected to the ID pin. So these defines should be set match your actual hardware setup. It has nothing to do with the processor, but rather how the G30TH board was wired up.
In the case of VBUS detect, PA9 is the only pin that can be used, and similarly PA10 is the only pin that can be used for the ID pin.
Re: [STM32F401CE] [pyb] import stm -- Where is stm module source? [found]
Thanks for clarifying Dave.Pin A9 does NOT connect to VBUS, so it can't be used to detect if VBUS is present. Similarly pin PA10 is NOT connected to the USB connector's ID pin, so it can't be used to negotiate the ID for OTG purposes.
John Griessen blog.kitmatic.com