Skip to content

Instantly share code, notes, and snippets.

@fanoush
Last active Nov 13, 2020
Embed
What would you like to do?
diff --git a/targetlibs/stm32f4/lib/stm32f4xx_conf.h b/targetlibs/stm32f4/lib/stm32f4xx_conf.h
index 2f33cd4f..885f551f 100755
--- a/targetlibs/stm32f4/lib/stm32f4xx_conf.h
+++ b/targetlibs/stm32f4/lib/stm32f4xx_conf.h
@@ -26,7 +26,7 @@
#if defined (HSE_VALUE)
/* Redefine the HSE value; it's equal to 8 MHz on the STM32F4-DISCOVERY Kit */
#undef HSE_VALUE
- #define HSE_VALUE ((uint32_t)8000000)
+ #define HSE_VALUE ((uint32_t)25000000)
#endif /* HSE_VALUE */
/* Includes ------------------------------------------------------------------*/
diff --git a/targetlibs/stm32f4/lib/system_stm32f4xx.c b/targetlibs/stm32f4/lib/system_stm32f4xx.c
index 39a00df2..6915304b 100644
--- a/targetlibs/stm32f4/lib/system_stm32f4xx.c
+++ b/targetlibs/stm32f4/lib/system_stm32f4xx.c
@@ -274,10 +274,15 @@
#endif /* STM32F401xx */
#if defined (STM32F411xx) // 100Mhz
-#undef PLL_Q
-#define PLL_N 384
-#define PLL_P 4
-#define PLL_Q 8
+//#undef PLL_Q
+//#define PLL_N 384
+//#define PLL_P 4
+//#define PLL_Q 8
+#define PLL_M 25
+#define PLL_Q 4
+#define PLL_N 192
+#define PLL_P 2
+
#endif /* STM32F411xx */
#if defined (STM32F413xx) // 100Mhz
@@ -328,7 +333,8 @@
#endif /* STM32F401xx */
#if defined (STM32F411xx)
- uint32_t SystemCoreClock = 100000000;
+// uint32_t SystemCoreClock = 100000000;
+ uint32_t SystemCoreClock = 96000000;
#endif /* STM32F411xx */
diff --git a/targets/stm32/jshardware.c b/targets/stm32/jshardware.c
index 7ecd4873..82cc23e4 100644
--- a/targets/stm32/jshardware.c
+++ b/targets/stm32/jshardware.c
@@ -950,6 +950,7 @@ JshPinState jshPinGetState(Pin pin) {
uint16_t pinn = stmPin(pin);
int pinNumber = pinInfo[pin].pin;
bool isOn = (port->ODR&pinn) != 0;
+ if (pinInfo[pin].port & JSH_PIN_NEGATED) isOn=!isOn;
#ifdef STM32F1
unsigned int crBits = ((pinNumber < 8) ? (port->CRL>>(pinNumber*4)) : (port->CRH>>((pinNumber-8)*4))) & 15;
unsigned int mode = crBits &3;
@@ -1034,6 +1035,7 @@ static NO_INLINE void jshPinSetFunction(Pin pin, JshPinFunction func) {
}
void jshPinSetValue(Pin pin, bool value) {
+if (pinInfo[pin].port & JSH_PIN_NEGATED) value=!value;
#ifdef STM32API2
if (value)
GPIO_SetBits(stmPort(pin), stmPin(pin));
@@ -1062,7 +1064,9 @@ void jshPinSetValue(Pin pin, bool value) {
}
bool jshPinGetValue(Pin pin) {
- return GPIO_ReadInputDataBit(stmPort(pin), stmPin(pin)) != 0;
+ bool value=GPIO_ReadInputDataBit(stmPort(pin), stmPin(pin)) != 0;
+if (pinInfo[pin].port & JSH_PIN_NEGATED) value=!value;
+ return value;
}
// ----------------------------------------------------------------------------
@@ -1102,7 +1106,7 @@ static void jshResetPeripherals() {
}
void jshInit() {
- jshInitDevices();
+// jshInitDevices();
int i;
// reset some vars
for (i=0;i<16;i++)
@@ -1149,6 +1153,7 @@ void jshInit() {
RCC_APB2Periph_GPIOG |
RCC_APB2Periph_AFIO, ENABLE);
#endif
+ jshInitDevices();
#ifdef ESPRUINOBOARD
// Enable the BusFault IRQ
@@ -1249,8 +1254,8 @@ void jshInit() {
#else
// On F2/F4, JTAG is just AF0
GPIO_PinAFConfig(GPIOA, GPIO_PinSource15, GPIO_AF_SPI1);
- GPIO_PinAFConfig(GPIOA, GPIO_PinSource14, GPIO_AF_SPI1);
- GPIO_PinAFConfig(GPIOA, GPIO_PinSource13, GPIO_AF_SPI1);
+// GPIO_PinAFConfig(GPIOA, GPIO_PinSource14, GPIO_AF_SPI1);
+// GPIO_PinAFConfig(GPIOA, GPIO_PinSource13, GPIO_AF_SPI1);
#endif
#else
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment