Skip to content

Commit 2623022

Browse files
committed
Initial work for STM32. Need to fix us delay and PulseIn still.
1 parent 6db11cf commit 2623022

21 files changed

Lines changed: 238 additions & 271 deletions

File tree

ports/stm/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ SRC_STM32 = \
172172
st_driver/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c \
173173
st_driver/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.c \
174174
st_driver/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.c \
175+
st_driver/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rtc.c \
176+
st_driver/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rtc_ex.c \
175177
st_driver/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.c \
176178
st_driver/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c \
177179
st_driver/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_exti.c \
@@ -193,7 +195,6 @@ SRC_C += \
193195
background.c \
194196
fatfs_port.c \
195197
mphalport.c \
196-
tick.c \
197198
boards/$(BOARD)/board.c \
198199
boards/$(BOARD)/pins.c \
199200
peripherals/stm32f4/$(MCU_SUB_VARIANT)/pins.c \

ports/stm/boards/feather_stm32f405_express/mpconfigboard.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636

3737
#define BOARD_OSC_DIV (12)
3838

39+
#define BOARD_RTC_CLOCK RCC_RTCCLKSOURCE_LSE
40+
3941
// On-board flash
4042
#define SPI_FLASH_MOSI_PIN (&pin_PB05)
4143
#define SPI_FLASH_MISO_PIN (&pin_PB04)

ports/stm/boards/feather_stm32f405_express/stm32f4xx_hal_conf.h

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
******************************************************************************
33
* @file stm32f4xx_hal_conf_template.h
44
* @author MCD Application Team
5-
* @brief HAL configuration template file.
5+
* @brief HAL configuration template file.
66
* This file should be copied to the application folder and renamed
77
* to stm32f4xx_hal_conf.h.
88
******************************************************************************
@@ -17,7 +17,7 @@
1717
* opensource.org/licenses/BSD-3-Clause
1818
*
1919
******************************************************************************
20-
*/
20+
*/
2121

2222
/* Define to prevent recursive inclusion -------------------------------------*/
2323
#ifndef __STM32F4xx_HAL_CONF_H
@@ -32,9 +32,9 @@
3232

3333
/* ########################## Module Selection ############################## */
3434
/**
35-
* @brief This is the list of modules to be used in the HAL driver
35+
* @brief This is the list of modules to be used in the HAL driver
3636
*/
37-
#define HAL_MODULE_ENABLED
37+
#define HAL_MODULE_ENABLED
3838

3939
#define HAL_ADC_MODULE_ENABLED
4040
/* #define HAL_CRYP_MODULE_ENABLED */
@@ -56,13 +56,13 @@
5656
/* #define HAL_IWDG_MODULE_ENABLED */
5757
/* #define HAL_LTDC_MODULE_ENABLED */
5858
#define HAL_RNG_MODULE_ENABLED
59-
/* #define HAL_RTC_MODULE_ENABLED */
59+
#define HAL_RTC_MODULE_ENABLED
6060
/* #define HAL_SAI_MODULE_ENABLED */
6161
/* #define HAL_SD_MODULE_ENABLED */
6262
/* #define HAL_MMC_MODULE_ENABLED */
6363
#define HAL_SPI_MODULE_ENABLED
6464
#define HAL_TIM_MODULE_ENABLED
65-
#define HAL_UART_MODULE_ENABLED
65+
#define HAL_UART_MODULE_ENABLED
6666
#define HAL_USART_MODULE_ENABLED
6767
/* #define HAL_IRDA_MODULE_ENABLED */
6868
/* #define HAL_SMARTCARD_MODULE_ENABLED */
@@ -90,9 +90,9 @@
9090
/**
9191
* @brief Adjust the value of External High Speed oscillator (HSE) used in your application.
9292
* This value is used by the RCC HAL module to compute the system frequency
93-
* (when HSE is used as system clock source, directly or through the PLL).
93+
* (when HSE is used as system clock source, directly or through the PLL).
9494
*/
95-
#if !defined (HSE_VALUE)
95+
#if !defined (HSE_VALUE)
9696
#define HSE_VALUE ((uint32_t)12000000) /*!< Value of the External oscillator in Hz */
9797
#endif /* HSE_VALUE */
9898

@@ -103,7 +103,7 @@
103103
/**
104104
* @brief Internal High Speed oscillator (HSI) value.
105105
* This value is used by the RCC HAL module to compute the system frequency
106-
* (when HSI is used as system clock source, directly or through the PLL).
106+
* (when HSI is used as system clock source, directly or through the PLL).
107107
*/
108108
#if !defined (HSI_VALUE)
109109
#define HSI_VALUE ((uint32_t)16000000) /*!< Value of the Internal oscillator in Hz*/
@@ -112,8 +112,8 @@
112112
/**
113113
* @brief Internal Low Speed oscillator (LSI) value.
114114
*/
115-
#if !defined (LSI_VALUE)
116-
#define LSI_VALUE ((uint32_t)40000)
115+
#if !defined (LSI_VALUE)
116+
#define LSI_VALUE ((uint32_t)40000)
117117
#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz
118118
The real value may vary depending on the variations
119119
in voltage and temperature. */
@@ -131,8 +131,8 @@
131131

132132
/**
133133
* @brief External clock source for I2S peripheral
134-
* This value is used by the I2S HAL module to compute the I2S clock source
135-
* frequency, this source is inserted directly through I2S_CKIN pad.
134+
* This value is used by the I2S HAL module to compute the I2S clock source
135+
* frequency, this source is inserted directly through I2S_CKIN pad.
136136
*/
137137
#if !defined (EXTERNAL_CLOCK_VALUE)
138138
#define EXTERNAL_CLOCK_VALUE ((uint32_t)12288000U) /*!< Value of the External audio frequency in Hz*/
@@ -145,16 +145,16 @@
145145
/**
146146
* @brief This is the HAL system configuration section
147147
*/
148-
#define VDD_VALUE ((uint32_t)3300U) /*!< Value of VDD in mv */
149-
#define TICK_INT_PRIORITY ((uint32_t)0U) /*!< tick interrupt priority */
150-
#define USE_RTOS 0U
148+
#define VDD_VALUE ((uint32_t)3300U) /*!< Value of VDD in mv */
149+
#define TICK_INT_PRIORITY ((uint32_t)0U) /*!< tick interrupt priority */
150+
#define USE_RTOS 0U
151151
#define PREFETCH_ENABLE 1U
152152
#define INSTRUCTION_CACHE_ENABLE 1U
153153
#define DATA_CACHE_ENABLE 1U
154154

155155
/* ########################## Assert Selection ############################## */
156156
/**
157-
* @brief Uncomment the line below to expanse the "assert_param" macro in the
157+
* @brief Uncomment the line below to expanse the "assert_param" macro in the
158158
* HAL drivers code
159159
*/
160160
/* #define USE_FULL_ASSERT 1U */
@@ -171,17 +171,17 @@
171171
#define MAC_ADDR4 0U
172172
#define MAC_ADDR5 0U
173173

174-
/* Definition of the Ethernet driver buffers size and count */
174+
/* Definition of the Ethernet driver buffers size and count */
175175
#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */
176176
#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */
177177
#define ETH_RXBUFNB ((uint32_t)4U) /* 4 Rx buffers of size ETH_RX_BUF_SIZE */
178178
#define ETH_TXBUFNB ((uint32_t)4U) /* 4 Tx buffers of size ETH_TX_BUF_SIZE */
179179

180180
/* Section 2: PHY configuration section */
181181

182-
/* DP83848_PHY_ADDRESS Address*/
182+
/* DP83848_PHY_ADDRESS Address*/
183183
#define DP83848_PHY_ADDRESS 0x01U
184-
/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/
184+
/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/
185185
#define PHY_RESET_DELAY ((uint32_t)0x000000FFU)
186186
/* PHY Configuration delay */
187187
#define PHY_CONFIG_DELAY ((uint32_t)0x00000FFFU)
@@ -193,7 +193,7 @@
193193

194194
#define PHY_BCR ((uint16_t)0x0000U) /*!< Transceiver Basic Control Register */
195195
#define PHY_BSR ((uint16_t)0x0001U) /*!< Transceiver Basic Status Register */
196-
196+
197197
#define PHY_RESET ((uint16_t)0x8000U) /*!< PHY Reset */
198198
#define PHY_LOOPBACK ((uint16_t)0x4000U) /*!< Select loop-back mode */
199199
#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100U) /*!< Set the full-duplex mode at 100 Mb/s */
@@ -208,7 +208,7 @@
208208
#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020U) /*!< Auto-Negotiation process completed */
209209
#define PHY_LINKED_STATUS ((uint16_t)0x0004U) /*!< Valid link established */
210210
#define PHY_JABBER_DETECTION ((uint16_t)0x0002U) /*!< Jabber condition detected */
211-
211+
212212
/* Section 4: Extended PHY Registers */
213213
#define PHY_SR ((uint16_t)0x10U) /*!< PHY status register Offset */
214214

@@ -226,7 +226,7 @@
226226

227227
/* Includes ------------------------------------------------------------------*/
228228
/**
229-
* @brief Include module's header file
229+
* @brief Include module's header file
230230
*/
231231

232232
#ifdef HAL_RCC_MODULE_ENABLED
@@ -244,7 +244,7 @@
244244
#ifdef HAL_DMA_MODULE_ENABLED
245245
#include "stm32f4xx_hal_dma.h"
246246
#endif /* HAL_DMA_MODULE_ENABLED */
247-
247+
248248
#ifdef HAL_CORTEX_MODULE_ENABLED
249249
#include "stm32f4xx_hal_cortex.h"
250250
#endif /* HAL_CORTEX_MODULE_ENABLED */
@@ -262,7 +262,7 @@
262262
#endif /* HAL_CRC_MODULE_ENABLED */
263263

264264
#ifdef HAL_CRYP_MODULE_ENABLED
265-
#include "stm32f4xx_hal_cryp.h"
265+
#include "stm32f4xx_hal_cryp.h"
266266
#endif /* HAL_CRYP_MODULE_ENABLED */
267267

268268
#ifdef HAL_DMA2D_MODULE_ENABLED
@@ -284,7 +284,7 @@
284284
#ifdef HAL_FLASH_MODULE_ENABLED
285285
#include "stm32f4xx_hal_flash.h"
286286
#endif /* HAL_FLASH_MODULE_ENABLED */
287-
287+
288288
#ifdef HAL_SRAM_MODULE_ENABLED
289289
#include "stm32f4xx_hal_sram.h"
290290
#endif /* HAL_SRAM_MODULE_ENABLED */
@@ -299,11 +299,11 @@
299299

300300
#ifdef HAL_PCCARD_MODULE_ENABLED
301301
#include "stm32f4xx_hal_pccard.h"
302-
#endif /* HAL_PCCARD_MODULE_ENABLED */
303-
302+
#endif /* HAL_PCCARD_MODULE_ENABLED */
303+
304304
#ifdef HAL_SDRAM_MODULE_ENABLED
305305
#include "stm32f4xx_hal_sdram.h"
306-
#endif /* HAL_SDRAM_MODULE_ENABLED */
306+
#endif /* HAL_SDRAM_MODULE_ENABLED */
307307

308308
#ifdef HAL_HASH_MODULE_ENABLED
309309
#include "stm32f4xx_hal_hash.h"
@@ -384,7 +384,7 @@
384384
#ifdef HAL_HCD_MODULE_ENABLED
385385
#include "stm32f4xx_hal_hcd.h"
386386
#endif /* HAL_HCD_MODULE_ENABLED */
387-
387+
388388
#ifdef HAL_DSI_MODULE_ENABLED
389389
#include "stm32f4xx_hal_dsi.h"
390390
#endif /* HAL_DSI_MODULE_ENABLED */
@@ -412,14 +412,14 @@
412412
#ifdef HAL_LPTIM_MODULE_ENABLED
413413
#include "stm32f4xx_hal_lptim.h"
414414
#endif /* HAL_LPTIM_MODULE_ENABLED */
415-
415+
416416
/* Exported macro ------------------------------------------------------------*/
417417
#ifdef USE_FULL_ASSERT
418418
/**
419419
* @brief The assert_param macro is used for function's parameters check.
420420
* @param expr: If expr is false, it calls assert_failed function
421421
* which reports the name of the source file and the source
422-
* line number of the call that failed.
422+
* line number of the call that failed.
423423
* If expr is true, it returns no value.
424424
* @retval None
425425
*/
@@ -428,13 +428,13 @@
428428
void assert_failed(uint8_t* file, uint32_t line);
429429
#else
430430
#define assert_param(expr) ((void)0U)
431-
#endif /* USE_FULL_ASSERT */
431+
#endif /* USE_FULL_ASSERT */
432432

433433
#ifdef __cplusplus
434434
}
435435
#endif
436436

437437
#endif /* __STM32F4xx_HAL_CONF_H */
438-
438+
439439

440440
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

ports/stm/boards/stm32f4_discovery/mpconfigboard.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,5 @@
3333
#define FLASH_PAGE_SIZE (0x4000)
3434

3535
#define BOARD_OSC_DIV (8)
36+
37+
#define BOARD_RTC_CLOCK RCC_RTCCLKSOURCE_LSE

0 commit comments

Comments
 (0)